├── docs ├── en │ └── index.md ├── man │ └── man3 │ │ ├── todo.3 │ │ ├── mathematics_statistics.3 │ │ ├── core.cpp.3 │ │ ├── core.hpp.3 │ │ ├── equations.cpp.3 │ │ ├── common.cpp.3 │ │ ├── equations.hpp.3 │ │ ├── statistics.cpp.3 │ │ ├── statistics.hpp.3 │ │ ├── libnumerixpp.cpp.3 │ │ ├── quadratic_equations.cpp.3 │ │ ├── quadratic_equations.hpp.3 │ │ ├── kinematics.hpp.3 │ │ ├── kinematics.cpp.3 │ │ ├── physics.3 │ │ ├── physics_kinematics.3 │ │ ├── mathematics_quadratic.3 │ │ ├── computerscience.3 │ │ └── mathematics.3 ├── ru │ ├── index.md │ └── article3.md ├── versions │ ├── v0.1.2.md │ └── v0.1.3.md └── README.md ├── .clangd ├── cmake ├── install-config.cmake ├── project-is-top-level.cmake ├── prelude.cmake ├── dev-mode.cmake ├── spell-targets.cmake ├── spell.cmake ├── folders.cmake ├── coverage.cmake ├── lint-targets.cmake ├── docs.cmake ├── lint.cmake ├── variables.cmake ├── install-rules.cmake └── docs-ci.cmake ├── include └── libnumerixpp │ ├── export.h │ ├── core │ └── common.hpp │ ├── libnumerixpp.hpp │ ├── physics │ ├── core.hpp │ └── kinematics.hpp │ ├── mathematics │ ├── quadratic_equations.hpp │ ├── statistics.hpp │ ├── equations.hpp │ └── core.hpp │ └── computerscience │ └── core.hpp ├── src ├── libnumerixpp.cpp ├── physics │ ├── core.cpp │ └── kinematics.cpp ├── core │ └── common.cpp ├── mathematics │ ├── statistics.cpp │ ├── quadratic_equations.cpp │ ├── equations.cpp │ └── core.cpp └── computerscience │ └── core.cpp ├── CONTRIBUTING.md ├── .gitignore ├── conanfile.py ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── static.yml ├── SECURITY.md ├── test ├── CMakeLists.txt └── source │ └── libnumerixpp_test.cpp ├── Doxygen.cmake ├── examples ├── example-1.cpp ├── example-4.cpp ├── example-3.cpp └── example-2.cpp ├── spacetabs.sh ├── CMakeUserPresets.json ├── CMakeLists.txt ├── BUILDING.md ├── format-code.py ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── HACKING.md ├── CMakePresets.json ├── .clang-tidy ├── .clang-format ├── LICENSE └── README.md /docs/en/index.md: -------------------------------------------------------------------------------- 1 | # libnumerixpp Russian Docs 2 | -------------------------------------------------------------------------------- /.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | CompilationDatabase: build/dev 3 | -------------------------------------------------------------------------------- /cmake/install-config.cmake: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | find_dependency(fmt) 3 | 4 | if(fmt_FOUND) 5 | include("${CMAKE_CURRENT_LIST_DIR}/libnumerixppTargets.cmake") 6 | endif() 7 | -------------------------------------------------------------------------------- /include/libnumerixpp/export.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef NUMERIXPP_STATIC_DEFINE 4 | # include 5 | #else 6 | # include 7 | #endif 8 | -------------------------------------------------------------------------------- /cmake/project-is-top-level.cmake: -------------------------------------------------------------------------------- 1 | # This variable is set by project() in CMake 3.21+ 2 | string( 3 | COMPARE EQUAL 4 | "${CMAKE_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}" 5 | PROJECT_IS_TOP_LEVEL 6 | ) 7 | -------------------------------------------------------------------------------- /src/libnumerixpp.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief A Powerful C++ Library for High-Performance Numerical Computing 4 | * @version 0.1.3 5 | * @date 2024-09-21 6 | * @authors alxvdev 7 | * @copyright Apache 2.0 License 8 | */ 9 | -------------------------------------------------------------------------------- /src/physics/core.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Core utils for physics 4 | * @authors alxvdev 5 | */ 6 | 7 | /** 8 | * @brief Basic physics utils 9 | * 10 | * @include example-1.cpp 11 | */ 12 | namespace physics {} 13 | -------------------------------------------------------------------------------- /include/libnumerixpp/core/common.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIBNUMERIXPP_COMMON_HPP 2 | #define LIBNUMERIXPP_COMMON_HPP 3 | 4 | #pragma once 5 | 6 | /** 7 | * @brief print credits 8 | */ 9 | void credits(); 10 | 11 | #endif // LIBNUMERIXPP_COMMON_HPP 12 | -------------------------------------------------------------------------------- /docs/man/man3/todo.3: -------------------------------------------------------------------------------- 1 | .TH "todo" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | todo \- Todo List 6 | .PP 7 | 8 | 9 | .PP 10 | .IP "\fBNamespace \fBphysics::kinematics\fP 11 | .IP "" 1c 12 | Add more kinematics equations 13 | 14 | .PP 15 | 16 | -------------------------------------------------------------------------------- /docs/ru/index.md: -------------------------------------------------------------------------------- 1 | # libnumerixpp Russian Docs 2 | 3 | + [Создаем свою C++ библиотеку с документацией, CMake и блекджеком](./article.md) 4 | + [Создаем свою C++ библиотеку с документацией, CMake и блекджеком: часть 2](./article2.md) 5 | + [Создаем свою C++ библиотеку с документацией, CMake и блекджеком: часть 3](./article3.md) 6 | -------------------------------------------------------------------------------- /docs/versions/v0.1.2.md: -------------------------------------------------------------------------------- 1 | tag v0.1.2 2 | Tagger: alexeev-dev 3 | Date: Fri Oct 4 21:52:38 2024 +0700 4 | 5 | alpha version 0.1.2 6 | 7 | commit 3e4247c67c65e74dfe6b14e3d74acf209ccf8cd2 8 | Author: alexeev-dev 9 | Date: Fri Oct 4 21:50:44 2024 +0700 10 | 11 | Trigger rebuild 12 | -------------------------------------------------------------------------------- /include/libnumerixpp/libnumerixpp.hpp: -------------------------------------------------------------------------------- 1 | #ifndef LIBNUMERIXPP_HPP 2 | #define LIBNUMERIXPP_HPP 3 | 4 | #include 5 | 6 | #pragma once 7 | 8 | /** 9 | * @brief Print string with new line 10 | * 11 | * @param[in] string The string 12 | */ 13 | void println(std::string string); 14 | 15 | #endif // LIBNUMERIXPP_HPP 16 | -------------------------------------------------------------------------------- /cmake/prelude.cmake: -------------------------------------------------------------------------------- 1 | # ---- In-source guard ---- 2 | 3 | if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) 4 | message( 5 | FATAL_ERROR 6 | "In-source builds are not supported. " 7 | "Please read the BUILDING document before trying to build this project. " 8 | "You may need to delete 'CMakeCache.txt' and 'CMakeFiles/' first." 9 | ) 10 | endif() 11 | -------------------------------------------------------------------------------- /include/libnumerixpp/physics/core.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Core utils for physics 4 | * @authors alxvdev 5 | */ 6 | #ifndef LIBNUMERIXPP_PHYSICS_CORE_HPP 7 | #define LIBNUMERIXPP_PHYSICS_CORE_HPP 8 | 9 | #pragma once 10 | 11 | /** 12 | * @brief Basic physics utils 13 | * 14 | * @include example-1.cpp 15 | */ 16 | namespace physics {} 17 | 18 | #endif // LIBNUMERIXPP_PHYSICS_CORE_HPP 19 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | ## Code of Conduct 3 | 4 | Please see the [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md) document. 5 | 6 | ## Getting started 7 | 8 | Helpful notes for developers can be found in the [`HACKING.md`](HACKING.md) 9 | document. 10 | 11 | In addition to he above, if you use the presets file as instructed, then you 12 | should NOT check it into source control, just as the CMake documentation 13 | suggests. 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | build/ 35 | -------------------------------------------------------------------------------- /conanfile.py: -------------------------------------------------------------------------------- 1 | from conan import ConanFile 2 | 3 | 4 | class Recipe(ConanFile): 5 | settings = "os", "compiler", "build_type", "arch" 6 | generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" 7 | 8 | def layout(self): 9 | self.folders.generators = "conan" 10 | 11 | def requirements(self): 12 | self.requires("fmt/11.0.2") 13 | 14 | def build_requirements(self): 15 | self.test_requires("catch2/3.7.0") 16 | -------------------------------------------------------------------------------- /src/core/common.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Core common utils for libnumerixpp 4 | * @authors alxvdev 5 | */ 6 | #include 7 | 8 | void credits() { 9 | std::cout << "libnumerixpp v0.1.1 - A powerful C++ Library for " 10 | "High-Performance Numerical Computing" 11 | << '\n'; 12 | std::cout << "Licensed by Apache License" << '\n'; 13 | std::cout << "Developed&maintained by @alxvdev" << '\n'; 14 | std::cout << '\n'; 15 | } 16 | -------------------------------------------------------------------------------- /docs/man/man3/mathematics_statistics.3: -------------------------------------------------------------------------------- 1 | .TH "mathematics::statistics" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | mathematics::statistics \- Statistics namespace\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SH "Detailed Description" 11 | .PP 12 | Statistics namespace\&. 13 | 14 | 15 | .PP 16 | .nf 17 | 18 | 19 | .fi 20 | .PP 21 | 22 | .SH "Author" 23 | .PP 24 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 25 | -------------------------------------------------------------------------------- /cmake/dev-mode.cmake: -------------------------------------------------------------------------------- 1 | include(cmake/folders.cmake) 2 | 3 | include(CTest) 4 | if(BUILD_TESTING) 5 | add_subdirectory(test) 6 | endif() 7 | 8 | option(BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) 9 | if(BUILD_MCSS_DOCS) 10 | include(cmake/docs.cmake) 11 | endif() 12 | 13 | option(ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF) 14 | if(ENABLE_COVERAGE) 15 | include(cmake/coverage.cmake) 16 | endif() 17 | 18 | include(cmake/lint-targets.cmake) 19 | include(cmake/spell-targets.cmake) 20 | 21 | add_folders(Project) 22 | -------------------------------------------------------------------------------- /docs/man/man3/core.cpp.3: -------------------------------------------------------------------------------- 1 | .TH "src/physics/core.cpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | src/physics/core.cpp \- Core utils for physics\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Namespaces" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "namespace \fBphysics\fP" 15 | .br 16 | .RI "Basic physics utils\&. " 17 | .in -1c 18 | .SH "Detailed Description" 19 | .PP 20 | Core utils for physics\&. 21 | 22 | 23 | .PP 24 | \fBAuthors\fP 25 | .RS 4 26 | alxvdev 27 | .RE 28 | .PP 29 | 30 | .SH "Author" 31 | .PP 32 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 33 | -------------------------------------------------------------------------------- /docs/man/man3/core.hpp.3: -------------------------------------------------------------------------------- 1 | .TH "include/libnumerixpp/physics/core.hpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | include/libnumerixpp/physics/core.hpp \- Core utils for physics\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Namespaces" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "namespace \fBphysics\fP" 15 | .br 16 | .RI "Basic physics utils\&. " 17 | .in -1c 18 | .SH "Detailed Description" 19 | .PP 20 | Core utils for physics\&. 21 | 22 | 23 | .PP 24 | \fBAuthors\fP 25 | .RS 4 26 | alxvdev 27 | .RE 28 | .PP 29 | 30 | .SH "Author" 31 | .PP 32 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 33 | -------------------------------------------------------------------------------- /docs/man/man3/equations.cpp.3: -------------------------------------------------------------------------------- 1 | .TH "src/mathematics/equations.cpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | src/mathematics/equations.cpp \- Mathematics utils for equations\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Namespaces" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "namespace \fBmathematics\fP" 15 | .br 16 | .RI "Basic mathematics utils\&. " 17 | .in -1c 18 | .SH "Detailed Description" 19 | .PP 20 | Mathematics utils for equations\&. 21 | 22 | 23 | .PP 24 | \fBAuthors\fP 25 | .RS 4 26 | alxvdev 27 | .RE 28 | .PP 29 | 30 | .SH "Author" 31 | .PP 32 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 33 | -------------------------------------------------------------------------------- /cmake/spell-targets.cmake: -------------------------------------------------------------------------------- 1 | set(SPELL_COMMAND codespell CACHE STRING "Spell checker to use") 2 | 3 | add_custom_target( 4 | spell-check 5 | COMMAND "${CMAKE_COMMAND}" 6 | -D "SPELL_COMMAND=${SPELL_COMMAND}" 7 | -P "${PROJECT_SOURCE_DIR}/cmake/spell.cmake" 8 | WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 9 | COMMENT "Checking spelling" 10 | VERBATIM 11 | ) 12 | 13 | add_custom_target( 14 | spell-fix 15 | COMMAND "${CMAKE_COMMAND}" 16 | -D "SPELL_COMMAND=${SPELL_COMMAND}" 17 | -D FIX=YES 18 | -P "${PROJECT_SOURCE_DIR}/cmake/spell.cmake" 19 | WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 20 | COMMENT "Fixing spelling errors" 21 | VERBATIM 22 | ) 23 | -------------------------------------------------------------------------------- /docs/man/man3/common.cpp.3: -------------------------------------------------------------------------------- 1 | .TH "src/core/common.cpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | src/core/common.cpp \- Core common utils for libnumerixpp\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | \fR#include \fP 11 | .br 12 | 13 | .SS "Functions" 14 | 15 | .in +1c 16 | .ti -1c 17 | .RI "void \fBcredits\fP (void)" 18 | .br 19 | .RI "print credits " 20 | .in -1c 21 | .SH "Detailed Description" 22 | .PP 23 | Core common utils for libnumerixpp\&. 24 | 25 | 26 | .PP 27 | \fBAuthors\fP 28 | .RS 4 29 | alxvdev 30 | .RE 31 | .PP 32 | 33 | .SH "Author" 34 | .PP 35 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 0.1.3 | :white_check_mark: | 11 | | 0.1.2 | :white_check_mark: | 12 | | 0.1.1 | :x: | 13 | | 0.1.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /docs/man/man3/equations.hpp.3: -------------------------------------------------------------------------------- 1 | .TH "include/libnumerixpp/mathematics/equations.hpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | include/libnumerixpp/mathematics/equations.hpp \- Mathematics utils for equations\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Namespaces" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "namespace \fBmathematics\fP" 15 | .br 16 | .RI "Basic mathematics utils\&. " 17 | .in -1c 18 | .SH "Detailed Description" 19 | .PP 20 | Mathematics utils for equations\&. 21 | 22 | 23 | .PP 24 | \fBAuthors\fP 25 | .RS 4 26 | alxvdev 27 | .RE 28 | .PP 29 | 30 | .SH "Author" 31 | .PP 32 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 33 | -------------------------------------------------------------------------------- /cmake/spell.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | macro(default name) 4 | if(NOT DEFINED "${name}") 5 | set("${name}" "${ARGN}") 6 | endif() 7 | endmacro() 8 | 9 | default(SPELL_COMMAND codespell) 10 | default(FIX NO) 11 | 12 | set(flag "") 13 | if(FIX) 14 | set(flag -w) 15 | endif() 16 | 17 | execute_process( 18 | COMMAND "${SPELL_COMMAND}" ${flag} 19 | WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" 20 | RESULT_VARIABLE result 21 | ) 22 | 23 | if(result EQUAL "65") 24 | message(FATAL_ERROR "Run again with FIX=YES to fix these errors.") 25 | elseif(result EQUAL "64") 26 | message(FATAL_ERROR "Spell checker printed the usage info. Bad arguments?") 27 | elseif(NOT result EQUAL "0") 28 | message(FATAL_ERROR "Spell checker returned with ${result}") 29 | endif() 30 | -------------------------------------------------------------------------------- /docs/man/man3/statistics.cpp.3: -------------------------------------------------------------------------------- 1 | .TH "src/mathematics/statistics.cpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | src/mathematics/statistics.cpp \- Mathematics utils for statistics\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Namespaces" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "namespace \fBmathematics\fP" 15 | .br 16 | .RI "Basic mathematics utils\&. " 17 | .ti -1c 18 | .RI "namespace \fBmathematics::statistics\fP" 19 | .br 20 | .RI "Statistics namespace\&. " 21 | .in -1c 22 | .SH "Detailed Description" 23 | .PP 24 | Mathematics utils for statistics\&. 25 | 26 | 27 | .PP 28 | \fBAuthors\fP 29 | .RS 4 30 | alxvdev 31 | .RE 32 | .PP 33 | 34 | .SH "Author" 35 | .PP 36 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 37 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | project(libnumerixppTests LANGUAGES CXX) 4 | 5 | include(../cmake/project-is-top-level.cmake) 6 | include(../cmake/folders.cmake) 7 | 8 | # ---- Dependencies ---- 9 | 10 | if(PROJECT_IS_TOP_LEVEL) 11 | find_package(libnumerixpp REQUIRED) 12 | enable_testing() 13 | endif() 14 | 15 | find_package(Catch2 REQUIRED) 16 | include(Catch) 17 | 18 | # ---- Tests ---- 19 | 20 | add_executable(libnumerixpp_test source/libnumerixpp_test.cpp) 21 | target_link_libraries( 22 | libnumerixpp_test PRIVATE 23 | libnumerixpp::libnumerixpp 24 | Catch2::Catch2WithMain 25 | ) 26 | target_compile_features(libnumerixpp_test PRIVATE cxx_std_17) 27 | 28 | catch_discover_tests(libnumerixpp_test) 29 | 30 | # ---- End-of-file commands ---- 31 | 32 | add_folders(Test) 33 | -------------------------------------------------------------------------------- /docs/man/man3/statistics.hpp.3: -------------------------------------------------------------------------------- 1 | .TH "include/libnumerixpp/mathematics/statistics.hpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | include/libnumerixpp/mathematics/statistics.hpp \- Mathematics utils for statistics\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Namespaces" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "namespace \fBmathematics\fP" 15 | .br 16 | .RI "Basic mathematics utils\&. " 17 | .ti -1c 18 | .RI "namespace \fBmathematics::statistics\fP" 19 | .br 20 | .RI "Statistics namespace\&. " 21 | .in -1c 22 | .SH "Detailed Description" 23 | .PP 24 | Mathematics utils for statistics\&. 25 | 26 | 27 | .PP 28 | \fBAuthors\fP 29 | .RS 4 30 | alxvdev 31 | .RE 32 | .PP 33 | 34 | .SH "Author" 35 | .PP 36 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 37 | -------------------------------------------------------------------------------- /Doxygen.cmake: -------------------------------------------------------------------------------- 1 | function(Doxygen input output) 2 | find_package(Doxygen) 3 | if (NOT DOXYGEN_FOUND) 4 | add_custom_target(doxygen COMMAND false 5 | COMMENT "Doxygen not found") 6 | return() 7 | endif() 8 | 9 | set(DOXYGEN_GENERATE_HTML YES) 10 | set(DOXYGEN_HTML_OUTPUT ${PROJECT_BINARY_DIR}/${output}) 11 | 12 | UseDoxygenAwesomeCss() 13 | 14 | doxygen_add_docs(doxygen 15 | ${PROJECT_SOURCE_DIR}/${input} 16 | COMMENT "Generate HTML documentation" 17 | ) 18 | endfunction() 19 | 20 | macro(UseDoxygenAwesomeCss) 21 | set(DOXYGEN_GENERATE_TREEVIEW YES) 22 | set(DOXYGEN_HAVE_DOT YES) 23 | set(DOXYGEN_DOT_IMAGE_FORMAT svg) 24 | set(DOXYGEN_DOT_TRANSPARENT YES) 25 | set(DOXYGEN_HTML_EXTRA_STYLESHEET 26 | ${CMAKE_CURRENT_SOURCE_DIR}/doxygen-awesome.css) 27 | endmacro() 28 | -------------------------------------------------------------------------------- /cmake/folders.cmake: -------------------------------------------------------------------------------- 1 | set_property(GLOBAL PROPERTY USE_FOLDERS YES) 2 | 3 | # Call this function at the end of a directory scope to assign a folder to 4 | # targets created in that directory. Utility targets will be assigned to the 5 | # UtilityTargets folder, otherwise to the ${name}Targets folder. If a target 6 | # already has a folder assigned, then that target will be skipped. 7 | function(add_folders name) 8 | get_property(targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS) 9 | foreach(target IN LISTS targets) 10 | get_property(folder TARGET "${target}" PROPERTY FOLDER) 11 | if(DEFINED folder) 12 | continue() 13 | endif() 14 | set(folder Utility) 15 | get_property(type TARGET "${target}" PROPERTY TYPE) 16 | if(NOT type STREQUAL "UTILITY") 17 | set(folder "${name}") 18 | endif() 19 | set_property(TARGET "${target}" PROPERTY FOLDER "${folder}Targets") 20 | endforeach() 21 | endfunction() 22 | -------------------------------------------------------------------------------- /cmake/coverage.cmake: -------------------------------------------------------------------------------- 1 | # ---- Variables ---- 2 | 3 | # We use variables separate from what CTest uses, because those have 4 | # customization issues 5 | set( 6 | COVERAGE_TRACE_COMMAND 7 | lcov -c -q 8 | -o "${PROJECT_BINARY_DIR}/coverage.info" 9 | -d "${PROJECT_BINARY_DIR}" 10 | --include "${PROJECT_SOURCE_DIR}/*" 11 | CACHE STRING 12 | "; separated command to generate a trace for the 'coverage' target" 13 | ) 14 | 15 | set( 16 | COVERAGE_HTML_COMMAND 17 | genhtml --legend -f -q 18 | "${PROJECT_BINARY_DIR}/coverage.info" 19 | -p "${PROJECT_SOURCE_DIR}" 20 | -o "${PROJECT_BINARY_DIR}/coverage_html" 21 | CACHE STRING 22 | "; separated command to generate an HTML report for the 'coverage' target" 23 | ) 24 | 25 | # ---- Coverage target ---- 26 | 27 | add_custom_target( 28 | coverage 29 | COMMAND ${COVERAGE_TRACE_COMMAND} 30 | COMMAND ${COVERAGE_HTML_COMMAND} 31 | COMMENT "Generating coverage report" 32 | VERBATIM 33 | ) 34 | -------------------------------------------------------------------------------- /cmake/lint-targets.cmake: -------------------------------------------------------------------------------- 1 | set( 2 | FORMAT_PATTERNS 3 | source/*.cpp source/*.hpp 4 | include/*.hpp 5 | test/*.cpp test/*.hpp 6 | CACHE STRING 7 | "; separated patterns relative to the project source dir to format" 8 | ) 9 | 10 | set(FORMAT_COMMAND clang-format CACHE STRING "Formatter to use") 11 | 12 | add_custom_target( 13 | format-check 14 | COMMAND "${CMAKE_COMMAND}" 15 | -D "FORMAT_COMMAND=${FORMAT_COMMAND}" 16 | -D "PATTERNS=${FORMAT_PATTERNS}" 17 | -P "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" 18 | WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 19 | COMMENT "Linting the code" 20 | VERBATIM 21 | ) 22 | 23 | add_custom_target( 24 | format-fix 25 | COMMAND "${CMAKE_COMMAND}" 26 | -D "FORMAT_COMMAND=${FORMAT_COMMAND}" 27 | -D "PATTERNS=${FORMAT_PATTERNS}" 28 | -D FIX=YES 29 | -P "${PROJECT_SOURCE_DIR}/cmake/lint.cmake" 30 | WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" 31 | COMMENT "Fixing the code" 32 | VERBATIM 33 | ) 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /examples/example-1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "libnumerixpp/core/common.hpp" 5 | #include "libnumerixpp/libnumerixpp.hpp" 6 | #include "libnumerixpp/physics/kinematics.hpp" 7 | 8 | auto main() -> int { 9 | credits(); 10 | println("LIBNUMERIXPP"); 11 | 12 | double speed = 10.0; 13 | double time = 5.0; 14 | 15 | double const path = physics::kinematics::calculate_path(speed, time); 16 | speed = physics::kinematics::calculate_speed(path, time); 17 | time = physics::kinematics::calculate_time(path, speed); 18 | 19 | std::cout << "Calculate: speed=" << speed << "m/s" << "; time=" << time << "s" 20 | << "; path=" << path << "m" << '\n'; 21 | 22 | double const final_velocity = physics::kinematics::calculate_final_velocity(10.0, 10.0, 10.0); 23 | std::cout << "final velocity (10.0, 10.0, 10.0) = " << final_velocity << '\n'; 24 | 25 | double const final_position = 26 | physics::kinematics::calculate_final_position(10.0, 10.0, 10.0, 10.0); 27 | std::cout << "final position (10.0, 10.0, 10.0, 10.0) = " << final_velocity << '\n'; 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /examples/example-4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "libnumerixpp/core/common.hpp" 6 | #include "libnumerixpp/libnumerixpp.hpp" 7 | #include "libnumerixpp/mathematics/equations.hpp" 8 | 9 | void test_eq_sa(double (*f_eq)(double), double x0, const std::string &eq) { 10 | int const iterations = 100; 11 | 12 | double z = NAN; 13 | 14 | std::cout << "Equation solution " << eq << ":\t"; 15 | 16 | z = mathematics::equations::successive_approximations_finding_root(f_eq, x0, iterations); 17 | 18 | std::cout << z << '\n'; 19 | 20 | std::cout << "Check finding solution:\t"; 21 | 22 | std::cout << z << " = " << f_eq(z) << '\n'; 23 | 24 | for (int i = 0; i <= 50; i++) { 25 | std::cout << "-"; 26 | } 27 | 28 | std::cout << '\n'; 29 | } 30 | 31 | auto main() -> int { 32 | credits(); 33 | println("LIBNUMERIXPP"); 34 | 35 | test_eq_sa(mathematics::equations::f_eq, 0, "x=0.5cos(x)"); 36 | test_eq_sa(mathematics::equations::g_eq, 0, "x=exp(-x)"); 37 | test_eq_sa(mathematics::equations::h_eq, 1, "x=(x*x+6)/5"); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /docs/man/man3/libnumerixpp.cpp.3: -------------------------------------------------------------------------------- 1 | .TH "src/libnumerixpp.cpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | src/libnumerixpp.cpp \- A Powerful C++ Library for High-Performance Numerical Computing\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | \fR#include \fP 11 | .br 12 | 13 | .SS "Functions" 14 | 15 | .in +1c 16 | .ti -1c 17 | .RI "void \fBprintln\fP (std::string string)" 18 | .br 19 | .RI "Print string with new line\&. " 20 | .in -1c 21 | .SH "Detailed Description" 22 | .PP 23 | A Powerful C++ Library for High-Performance Numerical Computing\&. 24 | 25 | 26 | .PP 27 | \fBVersion\fP 28 | .RS 4 29 | 0\&.1\&.0 30 | .RE 31 | .PP 32 | \fBDate\fP 33 | .RS 4 34 | 2024-09-21 35 | .RE 36 | .PP 37 | \fBAuthors\fP 38 | .RS 4 39 | alxvdev 40 | .RE 41 | .PP 42 | \fBCopyright\fP 43 | .RS 4 44 | Apache 2\&.0 License 45 | .RE 46 | .PP 47 | 48 | .SH "Function Documentation" 49 | .PP 50 | .SS "void println (std::string string)" 51 | 52 | .PP 53 | Print string with new line\&. 54 | .PP 55 | \fBParameters\fP 56 | .RS 4 57 | \fIstring\fP The string 58 | .RE 59 | .PP 60 | 61 | .SH "Author" 62 | .PP 63 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 64 | -------------------------------------------------------------------------------- /src/mathematics/statistics.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Mathematics utils for statistics 4 | * @authors alxvdev 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace mathematics::statistics { 12 | auto get_average(const double numbers[], int length) -> double { 13 | double sum = 0; 14 | 15 | for (int i = 0; i < length; i++) { 16 | sum += numbers[i]; 17 | } 18 | 19 | return sum / length; 20 | } 21 | 22 | auto factorial(size_t n) -> size_t { 23 | if (n == 0) { 24 | return 1; 25 | } 26 | return n * factorial(n - 1); 27 | } 28 | 29 | auto combinations(size_t n, size_t k) -> size_t { 30 | return factorial(n) / (factorial(k) * factorial(n - k)); 31 | } 32 | 33 | auto median(std::vector data) -> double { 34 | std::sort(data.begin(), data.end()); 35 | const size_t size = data.size(); 36 | if (size % 2 == 0) { 37 | return (data[size / 2 - 1] + data[size / 2]) / 2.0; 38 | } 39 | return data[size / 2]; 40 | } 41 | 42 | auto probability(size_t favorable_outcomes, size_t total_outcomes) -> double { 43 | return static_cast(favorable_outcomes) / total_outcomes; 44 | } 45 | 46 | auto conditional_probability(size_t a_and_b, size_t b) -> double { 47 | return static_cast(a_and_b) / b; 48 | } 49 | } // namespace mathematics::statistics 50 | -------------------------------------------------------------------------------- /src/physics/kinematics.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Physics utils for kinematics 4 | * @authors alxvdev 5 | */ 6 | 7 | namespace physics::kinematics { 8 | 9 | auto calculate_path(double speed, double time) -> double { return speed * time; } 10 | 11 | auto calculate_speed(double path, double time) -> double { return path / time; } 12 | 13 | auto calculate_time(double path, double speed) -> double { return path / speed; } 14 | 15 | auto calculate_final_velocity(double initial_velocity, double acceleration, 16 | double time) -> double { 17 | return initial_velocity + acceleration * time; 18 | } 19 | 20 | auto calculate_final_position(double initial_position, double initial_velocity, 21 | double acceleration, double time) -> double { 22 | return initial_position + initial_velocity * time + 0.5 * acceleration * time * time; 23 | } 24 | 25 | auto calculate_acceleration_of_rectilinear_motion(double start_speed, double end_speed, 26 | double time) -> double { 27 | double const acceleration = (end_speed - start_speed) / time; 28 | 29 | return acceleration; 30 | } 31 | 32 | auto calculate_speed_of_rectilinear_motion(double end_speed, double acceleration, 33 | double time) -> double { 34 | double const speed = end_speed + acceleration * time; 35 | 36 | return speed; 37 | } 38 | } // namespace physics::kinematics 39 | -------------------------------------------------------------------------------- /src/mathematics/quadratic_equations.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Math utils for quadratic 4 | * @authors alxvdev 5 | */ 6 | #include 7 | 8 | #include "libnumerixpp/mathematics/core.hpp" 9 | 10 | namespace mathematics::quadratic { 11 | 12 | auto calculate_discriminant(double a, double b, double c) -> double { 13 | double const d = mathematics::square_it_up(b) - 4 * a * c; 14 | 15 | return d; 16 | } 17 | 18 | auto calculate_roots_by_discriminant(double discriminant, double a, 19 | double b) -> std::vector { 20 | std::vector roots; 21 | 22 | if (discriminant > 0) { 23 | double const x1 = (-b + get_square_root(discriminant)) / (2 * a); 24 | double const x2 = (-b - get_square_root(discriminant)) / (2 * a); 25 | 26 | roots.push_back(x1); 27 | roots.push_back(x2); 28 | } else if (discriminant == 0) { 29 | double const x1 = -b + get_square_root(discriminant) / (2 * a); 30 | roots.push_back(x1); 31 | } 32 | 33 | return roots; 34 | } 35 | 36 | auto get_roots_by_vieta_theorem(double a, double b, double c) -> std::vector { 37 | std::vector roots; 38 | 39 | if (a == 0) { 40 | return roots; 41 | } 42 | 43 | double const roots_sum = -(b / a); 44 | double const roots_mul = c / a; 45 | 46 | roots.push_back(roots_sum); 47 | roots.push_back(roots_mul); 48 | 49 | return roots; 50 | } 51 | } // namespace mathematics::quadratic 52 | -------------------------------------------------------------------------------- /src/mathematics/equations.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Mathematics utils for equations 4 | * @authors alxvdev 5 | */ 6 | #include 7 | 8 | namespace mathematics::equations { 9 | auto successive_approximations_finding_root(double (*f_eq)(double), double x0, 10 | int n) -> double { 11 | double x = x0; 12 | 13 | for (int i = 1; i <= n; i++) { 14 | x = f_eq(x); 15 | } 16 | 17 | return x; 18 | } 19 | 20 | auto half_division_finding_root(double (*f_hd_eq)(double), double a, double b, 21 | double dx) -> double { 22 | double x = (a + b) / 2; 23 | 24 | while ((b - a) / 2 > dx) { 25 | if (f_hd_eq(a) == 0) { 26 | return a; 27 | } 28 | 29 | if (f_hd_eq(b) == 0) { 30 | return b; 31 | } 32 | 33 | if (f_hd_eq(x) == 0) { 34 | return x; 35 | } 36 | 37 | if (f_hd_eq(a) * f_hd_eq(x) > 0) { 38 | a = x; 39 | } else { 40 | b = x; 41 | } 42 | 43 | x = (a + b) / 2; 44 | } 45 | 46 | return x; 47 | } 48 | 49 | auto f_hd_eq(double x) -> double { return 0.5 * cos(x) - x; } 50 | 51 | auto g_hd_eq(double x) -> double { return exp(-x) - x; } 52 | 53 | auto h_hg_eq(double x) -> double { return x * x - 5 * x + 6; } 54 | 55 | auto f_eq(double x) -> double { return 0.5 * cos(x); } 56 | 57 | auto g_eq(double x) -> double { return exp(-x); } 58 | 59 | auto h_eq(double x) -> double { return (x * x + 6) / 5; } 60 | } // namespace mathematics::equations 61 | -------------------------------------------------------------------------------- /docs/man/man3/quadratic_equations.cpp.3: -------------------------------------------------------------------------------- 1 | .TH "src/mathematics/quadratic_equations.cpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | src/mathematics/quadratic_equations.cpp \- Math utils for quadratic\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | \fR#include \fP 11 | .br 12 | \fR#include 'libnumerixpp/mathematics/core\&.hpp'\fP 13 | .br 14 | 15 | .SS "Namespaces" 16 | 17 | .in +1c 18 | .ti -1c 19 | .RI "namespace \fBmathematics\fP" 20 | .br 21 | .RI "Basic mathematics utils\&. " 22 | .ti -1c 23 | .RI "namespace \fBmathematics::quadratic\fP" 24 | .br 25 | .in -1c 26 | .SS "Functions" 27 | 28 | .in +1c 29 | .ti -1c 30 | .RI "double \fBmathematics::quadratic::calculateDiscriminant\fP (double a, double b, double c)" 31 | .br 32 | .RI "Calculates the discriminant\&. " 33 | .ti -1c 34 | .RI "std::vector< double > \fBmathematics::quadratic::calculateRootsByDiscriminant\fP (double discriminant, double a, double b)" 35 | .br 36 | .RI "Calculates the roots by discriminant\&. " 37 | .ti -1c 38 | .RI "std::vector< double > \fBmathematics::quadratic::getRootsByVietaTheorem\fP (double a, double b, double c)" 39 | .br 40 | .RI "Gets the roots by vieta theorem\&. " 41 | .in -1c 42 | .SH "Detailed Description" 43 | .PP 44 | Math utils for quadratic\&. 45 | 46 | 47 | .PP 48 | \fBAuthors\fP 49 | .RS 4 50 | alxvdev 51 | .RE 52 | .PP 53 | 54 | .SH "Author" 55 | .PP 56 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 57 | -------------------------------------------------------------------------------- /cmake/docs.cmake: -------------------------------------------------------------------------------- 1 | # ---- Dependencies ---- 2 | 3 | set(extract_timestamps "") 4 | if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") 5 | set(extract_timestamps DOWNLOAD_EXTRACT_TIMESTAMP YES) 6 | endif() 7 | 8 | include(FetchContent) 9 | FetchContent_Declare( 10 | mcss URL 11 | https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip 12 | URL_MD5 00cd2757ebafb9bcba7f5d399b3bec7f 13 | SOURCE_DIR "${PROJECT_BINARY_DIR}/mcss" 14 | UPDATE_DISCONNECTED YES 15 | ${extract_timestamps} 16 | ) 17 | FetchContent_MakeAvailable(mcss) 18 | 19 | find_package(Python3 3.6 REQUIRED) 20 | 21 | # ---- Declare documentation target ---- 22 | 23 | set( 24 | DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/docs" 25 | CACHE PATH "Path for the generated Doxygen documentation" 26 | ) 27 | 28 | set(working_dir "${PROJECT_BINARY_DIR}/docs") 29 | 30 | foreach(file IN ITEMS Doxyfile conf.py) 31 | configure_file("docs/${file}.in" "${working_dir}/${file}" @ONLY) 32 | endforeach() 33 | 34 | set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") 35 | set(config "${working_dir}/conf.py") 36 | 37 | add_custom_target( 38 | docs 39 | COMMAND "${CMAKE_COMMAND}" -E remove_directory 40 | "${DOXYGEN_OUTPUT_DIRECTORY}/html" 41 | "${DOXYGEN_OUTPUT_DIRECTORY}/xml" 42 | COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" 43 | COMMENT "Building documentation using Doxygen and m.css" 44 | WORKING_DIRECTORY "${working_dir}" 45 | VERBATIM 46 | ) 47 | -------------------------------------------------------------------------------- /docs/man/man3/quadratic_equations.hpp.3: -------------------------------------------------------------------------------- 1 | .TH "include/libnumerixpp/mathematics/quadratic_equations.hpp" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | include/libnumerixpp/mathematics/quadratic_equations.hpp \- Quadratic utils for mathematics\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | \fR#include \fP 11 | .br 12 | \fR#include 'libnumerixpp/mathematics/core\&.hpp'\fP 13 | .br 14 | 15 | .SS "Namespaces" 16 | 17 | .in +1c 18 | .ti -1c 19 | .RI "namespace \fBmathematics\fP" 20 | .br 21 | .RI "Basic mathematics utils\&. " 22 | .ti -1c 23 | .RI "namespace \fBmathematics::quadratic\fP" 24 | .br 25 | .in -1c 26 | .SS "Functions" 27 | 28 | .in +1c 29 | .ti -1c 30 | .RI "double \fBmathematics::quadratic::calculateDiscriminant\fP (double a, double b, double c)" 31 | .br 32 | .RI "Calculates the discriminant\&. " 33 | .ti -1c 34 | .RI "std::vector< double > \fBmathematics::quadratic::calculateRootsByDiscriminant\fP (double discriminant, double a, double b)" 35 | .br 36 | .RI "Calculates the roots by discriminant\&. " 37 | .ti -1c 38 | .RI "std::vector< double > \fBmathematics::quadratic::getRootsByVietaTheorem\fP (double a, double b, double c)" 39 | .br 40 | .RI "Gets the roots by vieta theorem\&. " 41 | .in -1c 42 | .SH "Detailed Description" 43 | .PP 44 | Quadratic utils for mathematics\&. 45 | 46 | 47 | .PP 48 | \fBAuthors\fP 49 | .RS 4 50 | alxvdev 51 | .RE 52 | .PP 53 | 54 | .SH "Author" 55 | .PP 56 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 57 | -------------------------------------------------------------------------------- /cmake/lint.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | macro(default name) 4 | if(NOT DEFINED "${name}") 5 | set("${name}" "${ARGN}") 6 | endif() 7 | endmacro() 8 | 9 | default(FORMAT_COMMAND clang-format) 10 | default( 11 | PATTERNS 12 | source/*.cpp source/*.hpp 13 | include/*.hpp 14 | test/*.cpp test/*.hpp 15 | ) 16 | default(FIX NO) 17 | 18 | set(flag --output-replacements-xml) 19 | set(args OUTPUT_VARIABLE output) 20 | if(FIX) 21 | set(flag -i) 22 | set(args "") 23 | endif() 24 | 25 | file(GLOB_RECURSE files ${PATTERNS}) 26 | set(badly_formatted "") 27 | set(output "") 28 | string(LENGTH "${CMAKE_SOURCE_DIR}/" path_prefix_length) 29 | 30 | foreach(file IN LISTS files) 31 | execute_process( 32 | COMMAND "${FORMAT_COMMAND}" --style=file "${flag}" "${file}" 33 | WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" 34 | RESULT_VARIABLE result 35 | ${args} 36 | ) 37 | if(NOT result EQUAL "0") 38 | message(FATAL_ERROR "'${file}': formatter returned with ${result}") 39 | endif() 40 | if(NOT FIX AND output MATCHES "\n 26 | #include "libnumerixpp/libnumerixpp\&.hpp" 27 | #include "libnumerixpp/core/common\&.hpp" 28 | #include "libnumerixpp/physics/core\&.hpp" 29 | #include "libnumerixpp/physics/kinematics\&.hpp" 30 | 31 | int main() { 32 | credits(); 33 | println("LIBNUMERIXPP"); 34 | 35 | double speed = 10\&.0; 36 | double time = 5\&.0; 37 | 38 | double path = physics::kinematics::calculatePath(speed, time); 39 | speed = physics::kinematics::calculateSpeed(path, time); 40 | time = physics::kinematics::calculateSpeed(path, speed); 41 | 42 | std::cout << "Calculate: speed=" << speed << "m/s" << "; time=" << time << "s" << "; path=" << path << "m" << std::endl; 43 | 44 | double finalVelocity = physics::kinematics::calculateFinalVelocity(10\&.0, 10\&.0, 10\&.0); 45 | std::cout << "final velocity (10\&.0, 10\&.0, 10\&.0) = " << finalVelocity << std::endl; 46 | 47 | double finalPosition = physics::kinematics::calculateFinalPosition(10\&.0, 10\&.0, 10\&.0, 10\&.0); 48 | std::cout << "final position (10\&.0, 10\&.0, 10\&.0, 10\&.0) = " << finalVelocity << std::endl; 49 | 50 | return 0; 51 | } 52 | 53 | .fi 54 | .PP 55 | 56 | .SH "Author" 57 | .PP 58 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 59 | -------------------------------------------------------------------------------- /spacetabs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Define color codes for output 4 | RED='\e[31m' 5 | GREEN='\e[32m' 6 | YELLOW='\e[33m' 7 | NC='\e[0m' # No Color 8 | 9 | # Function to display usage instructions 10 | usage() { 11 | echo -e "${YELLOW}Usage: $0 ${NC}" 12 | echo -e ": spaces or tabs" 13 | exit 1 14 | } 15 | 16 | # Function to display error messages 17 | error() { 18 | echo -e "${RED}Error: $1${NC}" 19 | exit 1 20 | } 21 | 22 | # Function to perform conversion 23 | convert_tabs() { 24 | local file="$1" 25 | local tab_size="$2" 26 | local conversion_type="$3" 27 | 28 | if [[ "$conversion_type" == "spaces" ]]; then 29 | echo -e "${GREEN}Converting tabs to spaces...${NC}" 30 | expand -t "$tab_size" "$file" > "${file}.tmp" && mv "${file}.tmp" "$file" 31 | elif [[ "$conversion_type" == "tabs" ]]; then 32 | echo -e "${GREEN}Converting spaces to tabs...${NC}" 33 | unexpand -t "$tab_size" "$file" > "${file}.tmp" && mv "${file}.tmp" "$file" 34 | else 35 | error "Invalid conversion type: $conversion_type. Use 'spaces' or 'tabs'." 36 | fi 37 | } 38 | 39 | # Main script execution 40 | if [[ "$#" -ne 3 ]]; then 41 | usage 42 | fi 43 | 44 | FILE="$1" 45 | TAB_SIZE="$2" 46 | CONVERSION_TYPE="$3" 47 | 48 | # Check if the provided file exists 49 | if [[ ! -f "$FILE" ]]; then 50 | error "File not found: $FILE" 51 | fi 52 | 53 | # Validate tab size is a positive integer 54 | if ! [[ "$TAB_SIZE" =~ ^[1-9][0-9]*$ ]]; then 55 | error "Tab size must be a positive integer." 56 | fi 57 | 58 | # Perform the conversion 59 | convert_tabs "$FILE" "$TAB_SIZE" "$CONVERSION_TYPE" 60 | 61 | echo -e "${GREEN}Conversion completed successfully: $FILE${NC}" 62 | -------------------------------------------------------------------------------- /include/libnumerixpp/mathematics/quadratic_equations.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Quadratic utils for mathematics 4 | * @authors alxvdev 5 | */ 6 | #ifndef LIBNUMERIXPP_MATHEMATICS_QUADRATIC_EQUATIONS_HPP 7 | #define LIBNUMERIXPP_MATHEMATICS_QUADRATIC_EQUATIONS_HPP 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | /** 14 | * mathematics utils for quadratic equations and other 15 | * 16 | * @include example-2.cpp 17 | */ 18 | namespace mathematics::quadratic { 19 | /** 20 | * @brief Calculates the discriminant. 21 | * 22 | * @details Based on discriminant formula: \f$b^{2} - 4ac\f$ 23 | * 24 | * @param[in] a a 25 | * @param[in] b b 26 | * @param[in] c c 27 | * 28 | * @return The discriminant. 29 | */ 30 | auto calculate_discriminant(double a, double b, double c) -> double; 31 | 32 | /** 33 | * @brief Calculates the roots by discriminant. 34 | * 35 | * @details Calculate the roots by discriminant \f$\frac{-b +- 36 | * \sqrt{D}}{2a}\f$. D > 0 = 2 roots, D == 0 = 1 root, D 37 | *< 0 = 0 roots. 38 | * 39 | * @param[in] discriminant The discriminant 40 | * @param[in] a a 41 | * @param[in] b b 42 | * 43 | * @return The roots by discriminant. 44 | */ 45 | auto calculate_roots_by_discriminant(double discriminant, double a, 46 | double b) -> std::vector; 47 | 48 | /** 49 | * @brief Gets the roots by vieta theorem. 50 | * 51 | * @param[in] a a 52 | * @param[in] b b 53 | * @param[in] c c 54 | * 55 | * @return The roots by vieta theorem. 56 | */ 57 | auto get_roots_by_vieta_theorem(double a, double b, double c) -> std::vector; 58 | } // namespace mathematics::quadratic 59 | 60 | #endif // LIBNUMERIXPP_MATHEMATICS_QUADRATIC_EQUATIONS_HPP 61 | -------------------------------------------------------------------------------- /examples/example-3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "libnumerixpp/computerscience/core.hpp" 5 | #include "libnumerixpp/core/common.hpp" 6 | #include "libnumerixpp/libnumerixpp.hpp" 7 | 8 | auto main() -> int { 9 | credits(); 10 | println("LIBNUMERIXPP"); 11 | 12 | int const decimal_number = 777; 13 | std::string binary_number = computerscience::convert_decimal_to_binary(decimal_number); 14 | int const decimal_number2 = computerscience::convert_binary_to_decimal(binary_number); 15 | std::string hexadecimal_number = 16 | computerscience::convert_decimal_to_hexadecimal(decimal_number); 17 | int const decimal_number3 = computerscience::convert_hexadecimal_to_decimal(hexadecimal_number); 18 | std::string const hexadecimal_number2 = 19 | computerscience::convert_binary_to_hexadecimal(binary_number); 20 | std::string const binary_number2 = 21 | computerscience::convert_hexadecimal_to_binary(hexadecimal_number); 22 | long long const bytes = 1024 * 1024; 23 | 24 | std::cout << "Convert decimal " << decimal_number << " to binary: " << binary_number << '\n'; 25 | std::cout << "Convert binary " << binary_number << " to decimal: " << decimal_number2 << '\n'; 26 | std::cout << "Convert decimal " << decimal_number << " to hexadecimal: " << hexadecimal_number 27 | << '\n'; 28 | std::cout << "Convert hexadecimal " << hexadecimal_number << " to decimal: " << decimal_number3 29 | << '\n'; 30 | std::cout << "Convert binary " << binary_number << " to hexadecimal: " << hexadecimal_number2 31 | << '\n'; 32 | std::cout << "Convert hexadecimal " << hexadecimal_number << " to binary: " << binary_number2 33 | << '\n'; 34 | std::cout << "Convert " << bytes << ": " << computerscience::humanize_bytes_size(bytes) << '\n'; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /include/libnumerixpp/mathematics/statistics.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Mathematics utils for statistics 4 | * @authors alxvdev 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | /** 14 | * @brief Statistics namespace 15 | */ 16 | namespace mathematics::statistics { 17 | 18 | /** 19 | * @brief Gets the average. 20 | * 21 | * @param numbers The numbers 22 | * @param[in] length The length 23 | * 24 | * @return The average. 25 | */ 26 | auto get_average(const double numbers[], int length) -> double; 27 | 28 | /** 29 | * @brief calculate factorial 30 | * 31 | * @param[in] n number 32 | * 33 | * @return factorial 34 | */ 35 | auto factorial(size_t n) -> size_t; 36 | 37 | /** 38 | * @brief get combinations 39 | * 40 | * @param[in] n n value 41 | * @param[in] k k value 42 | * 43 | * @return { description_of_the_return_value } 44 | */ 45 | auto combinations(size_t n, size_t k) -> size_t; 46 | 47 | /** 48 | * @brief variance 49 | * 50 | * @param[in] data The data 51 | * 52 | * @return value 53 | */ 54 | auto variance(const std::vector &data) -> double; 55 | 56 | /** 57 | * @brief probability 58 | * 59 | * @param[in] favorable_outcomes The favorable outcomes 60 | * @param[in] total_outcomes The total outcomes 61 | * 62 | * @return result 63 | */ 64 | auto probability(size_t favorable_outcomes, size_t total_outcomes) -> double; 65 | 66 | /** 67 | * @brief conditional probability 68 | * 69 | * @param[in] a_and_b A and b 70 | * @param[in] b b value 71 | * 72 | * @return value 73 | */ 74 | auto conditional_probability(size_t a_and_b, size_t b) -> double; 75 | } // namespace mathematics::statistics 76 | -------------------------------------------------------------------------------- /CMakeUserPresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "cmakeMinimumRequired": { 4 | "major": 3, 5 | "minor": 14, 6 | "patch": 0 7 | }, 8 | "configurePresets": [ 9 | { 10 | "name": "dev-common", 11 | "hidden": true, 12 | "inherits": ["dev-mode", "conan", "clang-tidy", "cppcheck"], 13 | "cacheVariables": { 14 | "BUILD_MCSS_DOCS": "ON" 15 | } 16 | }, 17 | { 18 | "name": "dev-linux", 19 | "binaryDir": "${sourceDir}/build/dev-linux", 20 | "inherits": ["dev-common", "ci-linux"], 21 | "cacheVariables": { 22 | "CMAKE_BUILD_TYPE": "Debug", 23 | "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" 24 | } 25 | }, 26 | { 27 | "name": "dev-darwin", 28 | "binaryDir": "${sourceDir}/build/dev-darwin", 29 | "inherits": ["dev-common", "ci-darwin"] 30 | }, 31 | { 32 | "name": "dev-win64", 33 | "binaryDir": "${sourceDir}/build/dev-win64", 34 | "inherits": ["dev-common", "ci-win64"], 35 | "environment": { 36 | "UseMultiToolTask": "true", 37 | "EnforceProcessCountAcrossBuilds": "true" 38 | } 39 | }, 40 | { 41 | "name": "dev", 42 | "binaryDir": "${sourceDir}/build/dev", 43 | "inherits": "dev-linux" 44 | }, 45 | { 46 | "name": "dev-coverage", 47 | "binaryDir": "${sourceDir}/build/coverage", 48 | "inherits": ["dev-mode", "coverage-linux", "conan"] 49 | } 50 | ], 51 | "buildPresets": [ 52 | { 53 | "name": "dev", 54 | "configurePreset": "dev", 55 | "configuration": "Debug", 56 | "jobs": 2 57 | } 58 | ], 59 | "testPresets": [ 60 | { 61 | "name": "dev", 62 | "configurePreset": "dev", 63 | "configuration": "Debug", 64 | "output": { 65 | "outputOnFailure": true 66 | }, 67 | "execution": { 68 | "jobs": 2, 69 | "noTestsAction": "error" 70 | } 71 | } 72 | ] 73 | } 74 | -------------------------------------------------------------------------------- /cmake/install-rules.cmake: -------------------------------------------------------------------------------- 1 | if(PROJECT_IS_TOP_LEVEL) 2 | set( 3 | CMAKE_INSTALL_INCLUDEDIR "include" 4 | CACHE STRING "" 5 | ) 6 | set_property(CACHE CMAKE_INSTALL_INCLUDEDIR PROPERTY TYPE PATH) 7 | endif() 8 | 9 | include(CMakePackageConfigHelpers) 10 | include(GNUInstallDirs) 11 | 12 | # find_package() call for consumers to find this project 13 | set(package libnumerixpp) 14 | 15 | install( 16 | DIRECTORY 17 | include/ 18 | "${PROJECT_BINARY_DIR}/export/" 19 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 20 | COMPONENT libnumerixpp_Development 21 | ) 22 | 23 | install( 24 | TARGETS libnumerixpp_libnumerixpp 25 | EXPORT libnumerixppTargets 26 | RUNTIME # 27 | COMPONENT libnumerixpp_Runtime 28 | LIBRARY # 29 | COMPONENT libnumerixpp_Runtime 30 | NAMELINK_COMPONENT libnumerixpp_Development 31 | ARCHIVE # 32 | COMPONENT libnumerixpp_Development 33 | INCLUDES # 34 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" 35 | ) 36 | 37 | write_basic_package_version_file( 38 | "${package}ConfigVersion.cmake" 39 | COMPATIBILITY SameMajorVersion 40 | ) 41 | 42 | # Allow package maintainers to freely override the path for the configs 43 | set( 44 | libnumerixpp_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${package}" 45 | CACHE STRING "CMake package config location relative to the install prefix" 46 | ) 47 | set_property(CACHE libnumerixpp_INSTALL_CMAKEDIR PROPERTY TYPE PATH) 48 | mark_as_advanced(libnumerixpp_INSTALL_CMAKEDIR) 49 | 50 | install( 51 | FILES cmake/install-config.cmake 52 | DESTINATION "${libnumerixpp_INSTALL_CMAKEDIR}" 53 | RENAME "${package}Config.cmake" 54 | COMPONENT libnumerixpp_Development 55 | ) 56 | 57 | install( 58 | FILES "${PROJECT_BINARY_DIR}/${package}ConfigVersion.cmake" 59 | DESTINATION "${libnumerixpp_INSTALL_CMAKEDIR}" 60 | COMPONENT libnumerixpp_Development 61 | ) 62 | 63 | install( 64 | EXPORT libnumerixppTargets 65 | NAMESPACE libnumerixpp:: 66 | DESTINATION "${libnumerixpp_INSTALL_CMAKEDIR}" 67 | COMPONENT libnumerixpp_Development 68 | ) 69 | 70 | if(PROJECT_IS_TOP_LEVEL) 71 | include(CPack) 72 | endif() 73 | -------------------------------------------------------------------------------- /include/libnumerixpp/computerscience/core.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Core utils for computer science 4 | * @authors alxvdev 5 | */ 6 | #ifndef LIBNUMERIXPP_COMPUTERSCIENCE_CORE_HPP 7 | #define LIBNUMERIXPP_COMPUTERSCIENCE_CORE_HPP 8 | 9 | #pragma once 10 | 11 | #include 12 | 13 | /** 14 | * @brief Basic Computer science utils 15 | * @include example-3.cpp 16 | */ 17 | namespace computerscience { 18 | 19 | /** 20 | * @brief convert decimal to binary 21 | * 22 | * @param[in] decimal The decimal 23 | * 24 | * @return binary number string 25 | */ 26 | auto convert_decimal_to_binary(int decimal) -> std::string; 27 | 28 | /** 29 | * @brief convert binary to decimal 30 | * 31 | * @param binary The binary 32 | * 33 | * @return decimal integer 34 | */ 35 | auto convert_binary_to_decimal(std::string &binary) -> int; 36 | 37 | /** 38 | * @brief convert decimal to hexadecimal 39 | * 40 | * @param[in] decimal The decimal 41 | * 42 | * @return hexadecimal number string 43 | */ 44 | auto convert_decimal_to_hexadecimal(int decimal) -> std::string; 45 | 46 | /** 47 | * @brief convert hexadecimal to decimal 48 | * 49 | * @param hexadecimal The hexadecimal 50 | * 51 | * @return decimal integer 52 | */ 53 | auto convert_hexadecimal_to_decimal(std::string &hexadecimal) -> int; 54 | 55 | /** 56 | * @brief convert binary to hexadecimal 57 | * 58 | * @param binary The binary 59 | * 60 | * @return hexadecimal number string 61 | */ 62 | auto convert_binary_to_hexadecimal(std::string &binary) -> std::string; 63 | 64 | /** 65 | * @brief convert hexadecimal to binary 66 | * 67 | * @param[in] hexadecimal The hexadecimal 68 | * 69 | * @return binary number string 70 | */ 71 | auto convert_hexadecimal_to_binary(std::string hexadecimal) -> std::string; 72 | 73 | /** 74 | * @brief Scale bytes to its proper format 75 | * 76 | * @param[in] bytes The bytes 77 | * @param[in] suffix The suffix 78 | * 79 | * @return humanized size 80 | */ 81 | auto humanize_bytes_size(long long bytes, const std::string &suffix = "B") -> std::string; 82 | } // namespace computerscience 83 | 84 | #endif // LIBNUMERIXPP_COMPUTERSCIENCE_CORE_HPP 85 | -------------------------------------------------------------------------------- /src/computerscience/core.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Core utils for computer science (informatics) 4 | * @authors alxvdev 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace computerscience { 14 | auto convert_decimal_to_binary(int decimal) -> std::string { 15 | std::string binary; 16 | 17 | if (decimal == 0) { 18 | return "0"; 19 | } 20 | 21 | while (decimal > 0) { 22 | binary = std::to_string(decimal % 2) + binary; 23 | decimal /= 2; 24 | } 25 | 26 | return binary; 27 | } 28 | 29 | auto convert_binary_to_decimal(std::string &binary) -> int { 30 | int decimal = 0; 31 | 32 | for (char const bit : binary) { 33 | decimal = decimal * 2 + (bit - '0'); 34 | } 35 | 36 | return decimal; 37 | } 38 | 39 | auto convert_decimal_to_hexadecimal(int decimal) -> std::string { 40 | std::string hexadecimal; 41 | const char hex_digits[] = "0123456789ABCDEF"; 42 | 43 | while (decimal > 0) { 44 | hexadecimal = hex_digits[decimal % 16] + hexadecimal; 45 | decimal /= 16; 46 | } 47 | 48 | return hexadecimal.empty() ? "0" : hexadecimal; 49 | } 50 | 51 | auto convert_hexadecimal_to_decimal(std::string &hexadecimal) -> int { 52 | int decimal = 0; 53 | 54 | for (char const digit : hexadecimal) { 55 | decimal = 56 | decimal * 16 + ((isdigit(digit) != 0) ? digit - '0' : toupper(digit) - 'A' + 10); 57 | } 58 | 59 | return decimal; 60 | } 61 | 62 | auto convert_binary_to_hexadecimal(std::string &binary) -> std::string { 63 | int const decimal = convert_binary_to_decimal(binary); 64 | std::string hexadecimal = convert_decimal_to_hexadecimal(decimal); 65 | 66 | return hexadecimal; 67 | } 68 | 69 | auto convert_hexadecimal_to_binary(std::string &hexadecimal) -> std::string { 70 | int const decimal = convert_hexadecimal_to_decimal(hexadecimal); 71 | std::string binary = convert_decimal_to_binary(decimal); 72 | 73 | return binary; 74 | } 75 | 76 | auto humanize_bytes_size(long long bytes, const std::string &suffix = "B") -> std::string { 77 | double const factor = 1024.0; 78 | std::string const units[] = { "", "K", "M", "G", "T", "P" }; 79 | 80 | int i = 0; 81 | 82 | while (bytes >= factor) { 83 | bytes /= factor; 84 | i++; 85 | } 86 | 87 | std::stringstream ss; 88 | ss << std::fixed << std::setprecision(2) << static_cast(bytes) << units[i] 89 | << suffix; 90 | return ss.str(); 91 | } 92 | } // namespace computerscience 93 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | include(cmake/prelude.cmake) 4 | 5 | project( 6 | libnumerixpp 7 | VERSION 0.1.3 8 | DESCRIPTION "A Powerful C++ Library for High-Performance Numerical Computing" 9 | HOMEPAGE_URL "https://alexeev-prog.github.io/libnumerixpp" 10 | LANGUAGES CXX 11 | ) 12 | 13 | include(cmake/project-is-top-level.cmake) 14 | include(cmake/variables.cmake) 15 | 16 | # ---- Declare library ---- 17 | 18 | add_library( 19 | libnumerixpp_libnumerixpp 20 | src/libnumerixpp.cpp 21 | src/core/common.cpp 22 | src/mathematics/equations.cpp 23 | src/mathematics/core.cpp 24 | src/mathematics/quadratic_equations.cpp 25 | src/mathematics/statistics.cpp 26 | src/physics/core.cpp 27 | src/physics/kinematics.cpp 28 | src/computerscience/core.cpp 29 | ) 30 | add_library(libnumerixpp::libnumerixpp ALIAS libnumerixpp_libnumerixpp) 31 | 32 | include(GenerateExportHeader) 33 | generate_export_header( 34 | libnumerixpp_libnumerixpp 35 | BASE_NAME libnumerixpp 36 | EXPORT_FILE_NAME export/libnumerixpp/libnumerixpp_export.hpp 37 | CUSTOM_CONTENT_FROM_VARIABLE pragma_suppress_c4251 38 | ) 39 | 40 | if(NOT BUILD_SHARED_LIBS) 41 | target_compile_definitions(libnumerixpp_libnumerixpp PUBLIC LIBNUMERIXPP_STATIC_DEFINE) 42 | endif() 43 | 44 | set_target_properties( 45 | libnumerixpp_libnumerixpp PROPERTIES 46 | CXX_VISIBILITY_PRESET hidden 47 | VISIBILITY_INLINES_HIDDEN YES 48 | VERSION "${PROJECT_VERSION}" 49 | SOVERSION "${PROJECT_VERSION_MAJOR}" 50 | EXPORT_NAME libnumerixpp 51 | OUTPUT_NAME libnumerixpp 52 | ) 53 | 54 | target_include_directories( 55 | libnumerixpp_libnumerixpp ${warning_guard} 56 | PUBLIC 57 | "\$" 58 | ) 59 | 60 | target_include_directories( 61 | libnumerixpp_libnumerixpp SYSTEM 62 | PUBLIC 63 | "\$" 64 | ) 65 | 66 | target_compile_features(libnumerixpp_libnumerixpp PUBLIC cxx_std_17) 67 | 68 | find_package(fmt REQUIRED) 69 | target_link_libraries(libnumerixpp_libnumerixpp PRIVATE fmt::fmt) 70 | 71 | # ---- Install rules ---- 72 | 73 | if(NOT CMAKE_SKIP_INSTALL_RULES) 74 | include(cmake/install-rules.cmake) 75 | endif() 76 | 77 | # ---- Developer mode ---- 78 | 79 | if(NOT libnumerixpp_DEVELOPER_MODE) 80 | return() 81 | elseif(NOT PROJECT_IS_TOP_LEVEL) 82 | message( 83 | AUTHOR_WARNING 84 | "Developer mode is intended for developers of libnumerixpp" 85 | ) 86 | endif() 87 | 88 | include(cmake/dev-mode.cmake) 89 | -------------------------------------------------------------------------------- /examples/example-2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "libnumerixpp/core/common.hpp" 5 | #include "libnumerixpp/libnumerixpp.hpp" 6 | #include "libnumerixpp/mathematics/core.hpp" 7 | #include "libnumerixpp/mathematics/quadratic_equations.hpp" 8 | 9 | auto main() -> int { 10 | credits(); 11 | println("LIBNUMERIXPP"); 12 | 13 | // SQUARE AND SQR // 14 | 15 | double const num = 100.0; 16 | double const num_sq = mathematics::square_it_up(num); 17 | double const num_sqr = mathematics::get_square_root(num); 18 | std::cout << "Square " << num << ": " << num_sq << '\n'; 19 | std::cout << "Square root " << num << ": " << num_sqr << '\n'; 20 | 21 | std::cout << '\n'; 22 | 23 | // CALCULATE QUADRATIC EQUATION BY DISCRIMINANT // 24 | 25 | double const a = -2; 26 | double const b = 5; 27 | double const c = 5; 28 | 29 | double const d = mathematics::quadratic::calculate_discriminant(a, b, c); 30 | std::vector const roots = 31 | mathematics::quadratic::calculate_roots_by_discriminant(d, a, b); 32 | 33 | std::cout << "Quadratic Equation: a=" << a << "; b=" << b << "; c=" << c << '\n'; 34 | std::cout << "D=" << d << '\n'; 35 | std::cout << "Roots:" << '\n'; 36 | 37 | for (double const root : roots) { 38 | std::cout << root << '\n'; 39 | } 40 | 41 | std::cout << '\n'; 42 | 43 | // PERCENTAGE // 44 | 45 | double const nump = mathematics::add_percent_to_number(100.0, 10.0); 46 | std::cout << "100+10%: " << nump << '\n'; 47 | 48 | std::cout << '\n'; 49 | 50 | // POWER / Algorithms for fast exponentiation // 51 | 52 | double const best_pow_val = 100; 53 | double const pow_results[5] = { mathematics::old_approximate_power(10.0, 2.0), 54 | mathematics::another_approximate_power(10.0, 2.0), 55 | mathematics::binary_power(10.0, 2), 56 | mathematics::fast_power_dividing(10.0, 2.0), 57 | mathematics::fast_power_fractional(10.0, 2.0) }; 58 | 59 | std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << '\n'; 60 | std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << '\n'; 61 | std::cout << "2 binaryPower : base 10 exponent 2: " << pow_results[2] 62 | << '\n'; 63 | std::cout << "3 fastPowerDividing : base 10 exponent 2: " << pow_results[3] << '\n'; 64 | std::cout << "4 fastPowerFractional : base 10 exponent 2: " << pow_results[4] << '\n'; 65 | 66 | for (int i = 0; i < sizeof(pow_results) / sizeof(pow_results[0]); i++) { 67 | double const error = best_pow_val - pow_results[i]; 68 | 69 | std::cout << "POW Algorithm #" << i << ": error=" << error << '\n'; 70 | } 71 | 72 | std::cout << '\n'; 73 | 74 | // Other // 75 | 76 | std::cout << "-10 number module: " << mathematics::intabs(-10) << '\n'; 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /BUILDING.md: -------------------------------------------------------------------------------- 1 | # Building with CMake 2 | 3 | ## Dependencies 4 | 5 | For a list of dependencies, please refer to [conanfile.py](conanfile.py). 6 | 7 | ## Build 8 | 9 | This project doesn't require any special command-line flags to build to keep 10 | things simple. 11 | 12 | Here are the steps for building in release mode with a single-configuration 13 | generator, like the Unix Makefiles one: 14 | 15 | ```sh 16 | cmake -S . -B build -D CMAKE_BUILD_TYPE=Release 17 | cmake --build build 18 | ``` 19 | 20 | Here are the steps for building in release mode with a multi-configuration 21 | generator, like the Visual Studio ones: 22 | 23 | ```sh 24 | cmake -S . -B build 25 | cmake --build build --config Release 26 | ``` 27 | 28 | ### Building with MSVC 29 | 30 | Note that MSVC by default is not standards compliant and you need to pass some 31 | flags to make it behave properly. See the `flags-msvc` preset in the 32 | [CMakePresets.json](CMakePresets.json) file for the flags and with what 33 | variable to provide them to CMake during configuration. 34 | 35 | ### Building on Apple Silicon 36 | 37 | CMake supports building on Apple Silicon properly since 3.20.1. Make sure you 38 | have the [latest version][1] installed. 39 | 40 | ## Install 41 | 42 | This project doesn't require any special command-line flags to install to keep 43 | things simple. As a prerequisite, the project has to be built with the above 44 | commands already. 45 | 46 | The below commands require at least CMake 3.15 to run, because that is the 47 | version in which [Install a Project][2] was added. 48 | 49 | Here is the command for installing the release mode artifacts with a 50 | single-configuration generator, like the Unix Makefiles one: 51 | 52 | ```sh 53 | cmake --install build 54 | ``` 55 | 56 | Here is the command for installing the release mode artifacts with a 57 | multi-configuration generator, like the Visual Studio ones: 58 | 59 | ```sh 60 | cmake --install build --config Release 61 | ``` 62 | 63 | ### CMake package 64 | 65 | This project exports a CMake package to be used with the [`find_package`][3] 66 | command of CMake: 67 | 68 | * Package name: `libnumerixpp` 69 | * Target name: `libnumerixpp::libnumerixpp` 70 | 71 | Example usage: 72 | 73 | ```cmake 74 | find_package(libnumerixpp REQUIRED) 75 | # Declare the imported target as a build requirement using PRIVATE, where 76 | # project_target is a target created in the consuming project 77 | target_link_libraries( 78 | project_target PRIVATE 79 | libnumerixpp::libnumerixpp 80 | ) 81 | ``` 82 | 83 | ### Note to packagers 84 | 85 | The `CMAKE_INSTALL_INCLUDEDIR` is set to a path other than just `include` if 86 | the project is configured as a top level project to avoid indirectly including 87 | other libraries when installed to a common prefix. Please review the 88 | [install-rules.cmake](cmake/install-rules.cmake) file for the full set of 89 | install rules. 90 | 91 | [1]: https://cmake.org/download/ 92 | [2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project 93 | [3]: https://cmake.org/cmake/help/latest/command/find_package.html 94 | -------------------------------------------------------------------------------- /src/mathematics/core.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Core utils for mathematics 4 | * @authors alxvdev 5 | */ 6 | #include 7 | 8 | namespace mathematics { 9 | 10 | auto old_approximate_power(double base, double exponent) -> double { 11 | union { 12 | double d; 13 | long long i; 14 | } u = { base }; 15 | 16 | long long const magic_num = 4606853616395542500L; 17 | 18 | u.i = static_cast(magic_num + exponent * (u.i - magic_num)); 19 | 20 | return u.d; 21 | } 22 | 23 | auto binary_power(double base, unsigned long long exponent) -> double { 24 | double v = 1.0; 25 | 26 | while (exponent != 0) { 27 | if ((exponent & 1) != 0) { 28 | v *= base; 29 | } 30 | 31 | base *= base; 32 | exponent >>= 1; 33 | } 34 | 35 | return v; 36 | } 37 | 38 | auto fast_power_dividing(double base, double exponent) -> double { 39 | if (base == 1.0 || exponent == 0.0) { 40 | return 1.0; 41 | } 42 | 43 | double const e_abs = fabs(exponent); 44 | double const el = ceil(e_abs); 45 | double const base_part = old_approximate_power(base, e_abs / el); 46 | double const result = binary_power(base_part, static_cast(el)); 47 | 48 | if (exponent < 0.0) { 49 | return 1.0 / result; 50 | } 51 | 52 | return result; 53 | } 54 | 55 | auto another_approximate_power(double base, double exponent) -> double { 56 | union { 57 | double d; 58 | int x[2]; 59 | } u = { base }; 60 | 61 | u.x[1] = static_cast(exponent * (u.x[1] - 1072632447) + 1072632447); 62 | u.x[0] = 0; 63 | 64 | return u.d; 65 | } 66 | 67 | auto fast_power_fractional(double base, double exponent) -> double { 68 | if (base == 1.0 || exponent == 0.0) { 69 | return 1.0; 70 | } 71 | 72 | double const abs_exp = fabs(exponent); 73 | unsigned long long const e_int_part = static_cast(abs_exp); 74 | double const e_fract_part = abs_exp - e_int_part; 75 | double const result = 76 | old_approximate_power(base, e_fract_part) * binary_power(base, e_int_part); 77 | 78 | if (exponent < 0.0) { 79 | return 1.0 / result; 80 | } 81 | 82 | return result; 83 | } 84 | 85 | auto add_percent_to_number(double number, double percentage) -> double { 86 | double const oneperc = number / 100; 87 | double const result = number + (oneperc * percentage); 88 | 89 | return result; 90 | } 91 | 92 | auto square_it_up(double num) -> double { return num * num; } 93 | 94 | auto get_square_root(double num) -> double { 95 | if (num <= 0) { 96 | return 0; 97 | } 98 | 99 | int exp = 0; 100 | 101 | num = frexp(num, &exp); 102 | 103 | if ((exp & 1) != 0) { 104 | exp--; 105 | num *= 2; 106 | } 107 | 108 | double y = (1 + num) / 2; 109 | double z = 0; 110 | 111 | while (y != z) { 112 | z = y; 113 | y = (y + num / y) / 2; 114 | } 115 | 116 | return ldexp(y, exp / 2); 117 | } 118 | 119 | auto intabs(int x) -> int { 120 | int const minus_flag = x >> 0x1F; 121 | 122 | int y = minus_flag ^ x; 123 | 124 | y -= minus_flag; 125 | 126 | return y; 127 | } 128 | } // namespace mathematics 129 | -------------------------------------------------------------------------------- /docs/ru/article3.md: -------------------------------------------------------------------------------- 1 | # Создаем и улучшаем нашу библиотеку на C++ с CMake, тестами, документацией и блекджеком: часть 3 2 | В мире программирования создание собственных библиотек - это не просто возможность пополнения своего портфолио или способ структурировать код, а настоящий акт творческого самовыражения (и иногда велосипедостроения). Каждый разработчик иногда использовал в нескольких своих проектах однообразный код, который приходилось каждый раз перемещать. Да и хотя-бы как упаковать свои идеи и знания в удобный и доступный формат, которым можно будет поделиться с сообществом. 3 | 4 | Если вы ловили себя на мысли: "А почему мне бы не создать свою полноценную библиотеку?", то я рекомендую прочитать вам мою статью. 5 | 6 | Эту статью вы можете использовать как шпаргалку для создания проектов, и не только библиотек. 7 | 8 | Некоторые из вас могут подумать что мы изобретаем велосипед. А я в ответ скажу - сможете ли вы прямо сейчас, без подсказок, только по памяти, нарисовать велосипед без ошибок? 9 | 10 | Добро пожаловать в третью, скорее всего финальную (наверное) часть статьи! Здесь мы окончательно допишем код, исправим некоторые ошибки. 11 | 12 | Первая часть доступна по [этой ссылке](https://habr.com/ru/companies/timeweb/articles/845074/), вторая часть доступна по [другой ссылке](https://habr.com/ru/companies/timeweb/articles/846736/). 13 | 14 | --- 15 | 16 | Итак, в прошлых двух статьях мы сделали: 17 | 18 | + Автоматическую генерацию документации с ее публикацией на GitHub Pages 19 | + Продвинутую сборку при помощи CMake 20 | + Инструменты для форматирования и линтинга кода 21 | 22 | В этой статье мы будем работать над архитектурной частью, над библиотекой, улучшим ее аспекты, и конечно-же, продолжим писать C++ код. 23 | 24 | # Внешний вид библиотеки 25 | Человека встречают по одежке, а open source проект - по его описанию, README. Для того, чтобы пользователь мог понять, что к чему, следует в описании отвечать на следующие вопросы: 26 | 27 | 1. Какое назначение проекта? Описание должно быть лаконичным и отражающим суть проекта. 28 | 2. Почему проект полезен? Он должен решать определенные проблемы, поэтому необходимо явно написать о них, чтобы потенциальный пользователь мог понять, будет ли библиотека полезной для него. Нужно выделить преимущества своего решения по сравнению с аналогами, желательно с конкретными цифрами и бенчмарками, иначе потенциальный пользователь установит более эффективную или популярную библиотеку. 29 | 3. Как приступить к работе с библиотекой? Этап с установкой и настройкой библиотеки необходимо описать самым детальным образом. Ведь далеко не всегда то, что очевидно вам — очевидно другим. Решением могут пользоваться люди, у которых совершенно другой опыт. Нужно, чтобы любой желающий, кто хочет установить решение, понял, как это сделать. 30 | 4. Где можно получить дополнительную помощь, если она мне понадобится? Обязательно оставить свои контакты или другую предпочитаемую форму взаимодействия. 31 | 32 | Можно использовать свой README для ответа на другие вопросы. Например, дальнейшие цели в развитии проекта, информация о лицензиях, важных изменениях в коде. 33 | 34 | Для этого можно использовать даже ChatGPT, да простит меня хабро-бог за эту фразу. 35 | 36 | ## Содержание 37 | 38 | + [Первая часть](https://habr.com/ru/companies/timeweb/articles/845074/) 39 | + [Вторая часть]((https://habr.com/ru/companies/timeweb/articles/846736/) 40 | -------------------------------------------------------------------------------- /include/libnumerixpp/mathematics/equations.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Mathematics utils for equations 4 | * @authors alxvdev 5 | */ 6 | #ifndef LIBNUMERIXPP_MATHEMATICS_EQUATIONS_HPP 7 | #define LIBNUMERIXPP_MATHEMATICS_EQUATIONS_HPP 8 | 9 | #pragma once 10 | 11 | /** 12 | * @brief namespace for equation solving namespace 13 | * @include example-4.cpp 14 | */ 15 | namespace mathematics::equations { 16 | 17 | /** 18 | * @brief Function for solving equations by the method of successive 19 | * approximations. 20 | * 21 | * @details When solving an equation (\f$x = \Phi(x)\f$), under some 22 | * additional conditions, the method of successive 23 | * approximations can be used. Its essence boils down to 24 | *the fact that the initial position x0 is specified for the root of the 25 | *equation, after which, using an iterative procedure, each subsequent 26 | *approximation is calculated based on the previous one in accordance with the 27 | *formula @f$x_{n + 1} = \Phi(x_{n})\f$. Example equations: @f$x = 0,5 * 28 | *\cos(x)\f$; 29 | * @f$x = \exp(-x)\f$; @f$x = (x^{2} + 6) / 5\f$. 30 | * 31 | * @param[in] f The f 32 | * @param[in] x0 The x 0 33 | * @param[in] n n value 34 | * 35 | * @return equation root 36 | */ 37 | auto successive_approximations_finding_root(double (*f_eq)(double), double x0, int n) -> double; 38 | 39 | /** 40 | * @brief Function for solving equations by the method of half 41 | *division. 42 | * 43 | * @details The half division method for solving an algebraic equation of 44 | *the form f(x) = 0 implies that the sought root is localized in the interval a 45 | *<= x <= b, and at the boundaries of the root search interval the function f(x) 46 | *must take values of different signs (which can be written as the condition 47 | *f(a)f(b) < 0). 48 | * 49 | * @param[in] f_hd_eq The f_eq function for half division 50 | * @param[in] a a value 51 | * @param[in] b b value 52 | * @param[in] dx dx value 53 | * 54 | * @return equation root 55 | */ 56 | auto half_division_finding_root(double (*f_hd_eq)(double), double a, double b, 57 | double dx) -> double; 58 | 59 | /** 60 | * @brief Function f for determining the right side of solved equations 61 | * 62 | * @param[in] x x value 63 | * 64 | * @return value 65 | */ 66 | auto f_eq(double x) -> double; 67 | 68 | /** 69 | * @brief Function g for determining the right side of solved equations 70 | * 71 | * @param[in] x x value 72 | * 73 | * @return value 74 | */ 75 | auto g_eq(double x) -> double; 76 | 77 | /** 78 | * @brief Function h for determining the right side of solved equations 79 | * 80 | * @param[in] x x value 81 | * 82 | * @return value 83 | */ 84 | auto h_eq(double x) -> double; 85 | 86 | /** 87 | * @brief Function f for determining the right side of solved equations 88 | * (half division) 89 | * 90 | * @param[in] x x value 91 | * 92 | * @return value 93 | */ 94 | auto f_hd_eq(double x) -> double; 95 | 96 | /** 97 | * @brief Function g for determining the right side of solved equations 98 | * (half division) 99 | * 100 | * @param[in] x x value 101 | * 102 | * @return value 103 | */ 104 | auto g_hd_eq(double x) -> double; 105 | 106 | /** 107 | * @brief Function h for determining the right side of solved equations 108 | * (half division) 109 | * 110 | * @param[in] x x value 111 | * 112 | * @return value 113 | */ 114 | auto h_hg_eq(double x) -> double; 115 | 116 | } // namespace mathematics::equations 117 | 118 | #endif // LIBNUMERIXPP_MATHEMATICS_EQUATIONS_HPP 119 | -------------------------------------------------------------------------------- /test/source/libnumerixpp_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "libnumerixpp/computerscience/core.hpp" 5 | #include "libnumerixpp/mathematics/core.hpp" 6 | #include "libnumerixpp/mathematics/equations.hpp" 7 | #include "libnumerixpp/mathematics/quadratic_equations.hpp" 8 | #include "libnumerixpp/mathematics/statistics.hpp" 9 | #include "libnumerixpp/physics/kinematics.hpp" 10 | 11 | TEST_CASE("Check physics module", "[physics]") { 12 | auto speed = 10.0; 13 | auto time = 5.0; 14 | 15 | auto path = physics::kinematics::calculate_path(speed, time); 16 | 17 | REQUIRE(physics::kinematics::calculate_acceleration_of_rectilinear_motion(10.0, 15.0, 3) == 18 | 1.66666666666666674); 19 | REQUIRE(path == 50.0); 20 | REQUIRE(physics::kinematics::calculate_speed(path, time) == 10.0); 21 | REQUIRE(physics::kinematics::calculate_path(speed, time) == path); 22 | REQUIRE(physics::kinematics::calculate_time(path, speed) == time); 23 | REQUIRE(physics::kinematics::calculate_final_velocity(10.0, 10.0, 10.0) == 110.0); 24 | REQUIRE(physics::kinematics::calculate_final_position(10.0, 10.0, 10.0, 10.0) == 610.0); 25 | REQUIRE(physics::kinematics::calculate_speed_of_rectilinear_motion(10.0, 5.0, 5.0) == 35.0); 26 | } 27 | 28 | TEST_CASE("Check mathematics-quadratic", "[mathematics-quadratic]") { 29 | auto num = 100.0; 30 | auto a = -2; 31 | auto b = 5; 32 | auto c = 5; 33 | auto d = mathematics::quadratic::calculate_discriminant(a, b, c); 34 | auto nump = mathematics::add_percent_to_number(100.0, 10.0); 35 | 36 | REQUIRE(mathematics::square_it_up(num) == 10000); 37 | REQUIRE(mathematics::get_square_root(num) == 10); 38 | REQUIRE(d == 65.0); 39 | REQUIRE(mathematics::quadratic::calculate_roots_by_discriminant(d, a, b) == 40 | (std::vector){ -0.76556443707463728, 3.26556443707463728 }); 41 | REQUIRE(nump == 110.0); 42 | REQUIRE(mathematics::intabs(-10) == 10); 43 | } 44 | 45 | TEST_CASE("Check computerscience", "[computerscience]") { 46 | int const decimal_number = 777; 47 | auto binary_number = computerscience::convert_decimal_to_binary(decimal_number); 48 | int const decimal_number2 = computerscience::convert_binary_to_decimal(binary_number); 49 | auto hexadecimal_number = computerscience::convert_decimal_to_hexadecimal(decimal_number); 50 | int const decimal_number3 = computerscience::convert_hexadecimal_to_decimal(hexadecimal_number); 51 | auto hexadecimal_number2 = computerscience::convert_binary_to_hexadecimal(binary_number); 52 | long long const bytes = 1024 * 1024; 53 | 54 | REQUIRE(binary_number == "1100001001"); 55 | REQUIRE(decimal_number2 == 777); 56 | REQUIRE(hexadecimal_number == "309"); 57 | REQUIRE(decimal_number3 == 777); 58 | REQUIRE(hexadecimal_number2 == "309"); 59 | REQUIRE(computerscience::humanize_bytes_size(bytes) == "1.00MB"); 60 | } 61 | 62 | TEST_CASE("Check mathematics-equations", "[mathematics-equations]") { 63 | auto z_f = mathematics::equations::successive_approximations_finding_root( 64 | mathematics::equations::f_eq, 0.0, 100); 65 | auto z_g = mathematics::equations::successive_approximations_finding_root( 66 | mathematics::equations::g_eq, 0.0, 100); 67 | auto z_h = mathematics::equations::successive_approximations_finding_root( 68 | mathematics::equations::h_eq, 1.0, 100); 69 | 70 | REQUIRE(z_f == mathematics::equations::f_eq(z_f)); 71 | REQUIRE(z_g == mathematics::equations::g_eq(z_g)); 72 | REQUIRE(z_h == mathematics::equations::h_eq(z_h)); 73 | } 74 | 75 | TEST_CASE("Check mathematics-statistics", "[mathematics-statistics]") { 76 | const double numbers[3] = { 1.0, 1.0, 1.0 }; 77 | int const list_length = sizeof(numbers) / sizeof(numbers[0]); 78 | double const average = mathematics::statistics::get_average(numbers, list_length); 79 | 80 | REQUIRE(average == 1.0); 81 | } 82 | -------------------------------------------------------------------------------- /cmake/docs-ci.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | 3 | foreach(var IN ITEMS PROJECT_BINARY_DIR PROJECT_SOURCE_DIR) 4 | if(NOT DEFINED "${var}") 5 | message(FATAL_ERROR "${var} must be defined") 6 | endif() 7 | endforeach() 8 | set(bin "${PROJECT_BINARY_DIR}") 9 | set(src "${PROJECT_SOURCE_DIR}") 10 | 11 | # ---- Dependencies ---- 12 | 13 | set(mcss_SOURCE_DIR "${bin}/docs/.ci") 14 | if(NOT IS_DIRECTORY "${mcss_SOURCE_DIR}") 15 | file(MAKE_DIRECTORY "${mcss_SOURCE_DIR}") 16 | file( 17 | DOWNLOAD 18 | https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip 19 | "${mcss_SOURCE_DIR}/mcss.zip" 20 | STATUS status 21 | EXPECTED_MD5 00cd2757ebafb9bcba7f5d399b3bec7f 22 | ) 23 | if(NOT status MATCHES "^0;") 24 | message(FATAL_ERROR "Download failed with ${status}") 25 | endif() 26 | execute_process( 27 | COMMAND "${CMAKE_COMMAND}" -E tar xf mcss.zip 28 | WORKING_DIRECTORY "${mcss_SOURCE_DIR}" 29 | RESULT_VARIABLE result 30 | ) 31 | if(NOT result EQUAL "0") 32 | message(FATAL_ERROR "Extraction failed with ${result}") 33 | endif() 34 | file(REMOVE "${mcss_SOURCE_DIR}/mcss.zip") 35 | endif() 36 | 37 | find_program(Python3_EXECUTABLE NAMES python3 python) 38 | if(NOT Python3_EXECUTABLE) 39 | message(FATAL_ERROR "Python executable was not found") 40 | endif() 41 | 42 | # ---- Process project() call in CMakeLists.txt ---- 43 | 44 | file(READ "${src}/CMakeLists.txt" content) 45 | 46 | string(FIND "${content}" "project(" index) 47 | if(index EQUAL "-1") 48 | message(FATAL_ERROR "Could not find \"project(\"") 49 | endif() 50 | string(SUBSTRING "${content}" "${index}" -1 content) 51 | 52 | string(FIND "${content}" "\n)\n" index) 53 | if(index EQUAL "-1") 54 | message(FATAL_ERROR "Could not find \"\\n)\\n\"") 55 | endif() 56 | string(SUBSTRING "${content}" 0 "${index}" content) 57 | 58 | file(WRITE "${bin}/docs-ci.project.cmake" "docs_${content}\n)\n") 59 | 60 | macro(list_pop_front list out) 61 | list(GET "${list}" 0 "${out}") 62 | list(REMOVE_AT "${list}" 0) 63 | endmacro() 64 | 65 | function(docs_project name) 66 | cmake_parse_arguments(PARSE_ARGV 1 "" "" "VERSION;DESCRIPTION;HOMEPAGE_URL" LANGUAGES) 67 | set(PROJECT_NAME "${name}" PARENT_SCOPE) 68 | if(DEFINED _VERSION) 69 | set(PROJECT_VERSION "${_VERSION}" PARENT_SCOPE) 70 | string(REGEX MATCH "^[0-9]+(\\.[0-9]+)*" versions "${_VERSION}") 71 | string(REPLACE . ";" versions "${versions}") 72 | set(suffixes MAJOR MINOR PATCH TWEAK) 73 | while(NOT versions STREQUAL "" AND NOT suffixes STREQUAL "") 74 | list_pop_front(versions version) 75 | list_pop_front(suffixes suffix) 76 | set("PROJECT_VERSION_${suffix}" "${version}" PARENT_SCOPE) 77 | endwhile() 78 | endif() 79 | if(DEFINED _DESCRIPTION) 80 | set(PROJECT_DESCRIPTION "${_DESCRIPTION}" PARENT_SCOPE) 81 | endif() 82 | if(DEFINED _HOMEPAGE_URL) 83 | set(PROJECT_HOMEPAGE_URL "${_HOMEPAGE_URL}" PARENT_SCOPE) 84 | endif() 85 | endfunction() 86 | 87 | include("${bin}/docs-ci.project.cmake") 88 | 89 | # ---- Generate docs ---- 90 | 91 | if(NOT DEFINED DOXYGEN_OUTPUT_DIRECTORY) 92 | set(DOXYGEN_OUTPUT_DIRECTORY "${bin}/docs") 93 | endif() 94 | set(out "${DOXYGEN_OUTPUT_DIRECTORY}") 95 | 96 | foreach(file IN ITEMS Doxyfile conf.py) 97 | configure_file("${src}/docs/${file}.in" "${bin}/docs/${file}" @ONLY) 98 | endforeach() 99 | 100 | set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") 101 | set(config "${bin}/docs/conf.py") 102 | 103 | file(REMOVE_RECURSE "${out}/html" "${out}/xml") 104 | 105 | execute_process( 106 | COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" 107 | WORKING_DIRECTORY "${bin}/docs" 108 | RESULT_VARIABLE result 109 | ) 110 | if(NOT result EQUAL "0") 111 | message(FATAL_ERROR "m.css returned with ${result}") 112 | endif() 113 | -------------------------------------------------------------------------------- /format-code.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Python program to format C/C++ files using clang-format 3 | import os 4 | import sys 5 | import subprocess 6 | 7 | # Define color codes for output 8 | RED = '\033[31m' 9 | GREEN = '\033[32m' 10 | YELLOW = '\033[33m' 11 | NC = '\033[0m' # No Color 12 | BOLD = '\033[1m' # No Color 13 | 14 | # File Extension filter. You can add new extension 15 | cpp_extensions = (".cxx",".cpp",".c", ".hxx", ".hh", ".cc", ".hpp") 16 | IGNORED_DIRS = ['build', '.git', 'cmake', 'docs'] 17 | 18 | CLANG_FORMAT = 'clang-format' 19 | SPACETABS = './space-tabs.sh' 20 | 21 | print(f'libnumerixpp code-formatter: {CLANG_FORMAT}; Extensions: {" ".join(cpp_extensions)}') 22 | 23 | 24 | def print_usage(): 25 | """Print the usage instructions.""" 26 | print(f"{YELLOW}Usage: convert_tabs(file_path, tab_size, conversion_type){NC}") 27 | print(f": 'spaces' or 'tabs'") 28 | 29 | 30 | def print_error(message): 31 | """Print error messages.""" 32 | print(f"{RED}Error: {message}{NC}") 33 | 34 | 35 | def validate_positive_integer(value): 36 | """Validate if the value is a positive integer.""" 37 | try: 38 | int_value = int(value) 39 | if int_value < 1: 40 | raise ValueError 41 | return int_value 42 | except ValueError: 43 | print_error("Tab size must be a positive integer.") 44 | return None 45 | 46 | 47 | def file_exists(file_path): 48 | """Check if the file exists.""" 49 | if not os.path.isfile(file_path): 50 | print_error(f"File not found: {file_path}") 51 | return False 52 | return True 53 | 54 | 55 | def convert_tabs(file_path, tab_size, conversion_type): 56 | """Convert tabs to spaces or spaces to tabs based on conversion type.""" 57 | try: 58 | if conversion_type == "spaces": 59 | print(f"{BOLD}Converting tabs to spaces...{NC}") 60 | subprocess.run(["expand", "-t", str(tab_size), file_path], stdout=open(f"{file_path}.tmp", "w")) 61 | elif conversion_type == "tabs": 62 | print(f"{BOLD}Converting spaces to tabs...{NC}") 63 | subprocess.run(["unexpand", "-t", str(tab_size), file_path], stdout=open(f"{file_path}.tmp", "w")) 64 | else: 65 | print_error(f"Invalid conversion type: {conversion_type}. Use 'spaces' or 'tabs'.") 66 | return 67 | 68 | os.replace(f"{file_path}.tmp", file_path) 69 | print(f"{GREEN}Conversion completed successfully: {file_path}{NC}") 70 | except Exception as e: 71 | print_error(f"Conversion failed: {str(e)}") 72 | 73 | 74 | def convert_file(file_path, tab_size, conversion_type): 75 | """Main function to manage conversion.""" 76 | tab_size = validate_positive_integer(tab_size) 77 | if tab_size is None: 78 | return 79 | 80 | if not file_exists(file_path): 81 | return 82 | 83 | convert_tabs(file_path, tab_size, conversion_type) 84 | 85 | 86 | def main(): 87 | # Set the current working directory for scanning c/c++ sources (including 88 | # header files) and apply the clang formatting 89 | # Please note "-style" is for standard style options 90 | # and "-i" is in-place editing 91 | 92 | if len(sys.argv) > 1: 93 | print(f"{BOLD}Format {sys.argv[1]}{NC}") 94 | os.system(f'codespell -w {sys.argv[1]}') 95 | os.system(f'clang-tidy --fix {sys.argv[1]}') 96 | os.system(f"{CLANG_FORMAT} -i -style=file {sys.argv[1]}") 97 | print(f"{GREEN}Formatting completed successfully: {sys.argv[1]}{NC}") 98 | convert_file(f'{sys.argv[1]}', "4", "tabs") 99 | return 100 | 101 | for root, dirs, files in os.walk(os.getcwd()): 102 | if len(set(root.split('/')).intersection(IGNORED_DIRS)) > 0: 103 | continue 104 | for file in files: 105 | if file.endswith(cpp_extensions): 106 | print(f"{BOLD}Format {file}: {root}/{file}{NC}") 107 | os.system(f'codespell -w {root}/{file}') 108 | os.system(f'clang-tidy --fix {root}/{file}') 109 | os.system(f"{CLANG_FORMAT} -i -style=file {root}/{file}") 110 | print(f"{GREEN}Formatting completed successfully: {root}/{file}{NC}") 111 | convert_file(f'{root}/{file}', "4", "tabs") 112 | 113 | 114 | if __name__ == '__main__': 115 | main() 116 | -------------------------------------------------------------------------------- /include/libnumerixpp/physics/kinematics.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Physics utils for kinematics 4 | * @authors alxvdev 5 | */ 6 | #ifndef LIBNUMERIXPP_PHYSICS_KINEMATICS_HPP 7 | #define LIBNUMERIXPP_PHYSICS_KINEMATICS_HPP 8 | 9 | #pragma once 10 | 11 | /** 12 | * @brief Namespace of kinematics (physics) 13 | * 14 | * @todo Add more kinematics equations 15 | */ 16 | namespace physics::kinematics { 17 | 18 | /** 19 | * @brief Calculates the path. 20 | * 21 | * This function is based on basic formula: S = v * t 22 | * where: 23 | * + S - path (m) 24 | * + v - speed (m/s) 25 | * + t - time (s) 26 | * 27 | * @param[in] speed The speed 28 | * @param[in] time The time 29 | * 30 | * @return The path. 31 | */ 32 | auto calculate_path(double speed, double time) -> double; 33 | 34 | /** 35 | * @brief Calculates the speed. 36 | * 37 | * This function is based on basic formula: S = v * t 38 | * where: 39 | * + S - path (m) 40 | * + v - speed (m/s) 41 | * + t - time (s) 42 | * 43 | * @param[in] path The path 44 | * @param[in] time The time 45 | * 46 | * @return The speed. 47 | */ 48 | auto calculate_speed(double path, double time) -> double; 49 | 50 | /** 51 | * @brief Calculates the time. 52 | * 53 | * This function is based on basic formula: S = v * t 54 | * where: 55 | * + S - path (m) 56 | * + v - speed (m/s) 57 | * + t - time (s) 58 | * 59 | * @param[in] path The path 60 | * @param[in] speed The speed 61 | * 62 | * @return The time. 63 | */ 64 | auto calculate_time(double path, double speed) -> double; 65 | 66 | /** 67 | * @brief Calculates the final velocity. 68 | * 69 | * This function is based on the basic kinematics equation: v = u + at 70 | * where: 71 | * + v - final velocity (m/s) 72 | * + u - start speed (m/s) 73 | * + a - acceleration (m/s^2) 74 | * + t - time (s) 75 | * 76 | * @param[in] initial_velocity The initial velocity 77 | * @param[in] acceleration The acceleration 78 | * @param[in] time The time 79 | * 80 | * @return The final velocity. 81 | */ 82 | auto calculate_final_velocity(double initial_velocity, double acceleration, 83 | double time) -> double; 84 | 85 | /** 86 | * @brief Calculates the final position. 87 | * 88 | * This function is based on the kinematics equation: s = u*t + 0.5 * a * t^2 89 | * where: 90 | * + s - final position (m) 91 | * + u - start speed (m/s) 92 | * + a - acceleration (m/s^2) 93 | * + t - time (s) 94 | * 95 | * @param[in] initial_position The initial position 96 | * @param[in] initial_velocity The initial velocity 97 | * @param[in] acceleration The acceleration 98 | * @param[in] time The time 99 | * 100 | * @return The final position. 101 | */ 102 | auto calculate_final_position(double initial_position, double initial_velocity, 103 | double acceleration, double time) -> double; 104 | 105 | /** 106 | * @brief Calculates the acceleration of rectilinear motion. 107 | * 108 | * Equally variable motion is a motion in which, over any equal periods of time, a material 109 | * point changes its speed by the same amount. Acceleration is calculated by the formula \f$a = 110 | * \frac{V - V_{0}}{t}\f$, where v0 and v are the initial and final speed of the body, t is the 111 | * time of movement 112 | * 113 | * @param[in] start_speed The start speed 114 | * @param[in] end_speed The end speed 115 | * @param[in] time The time 116 | * 117 | * @return The acceleration of rectilinear motion. 118 | */ 119 | auto calculate_acceleration_of_rectilinear_motion(double start_speed, double end_speed, 120 | double time) -> double; 121 | 122 | /** 123 | * @brief Calculates the speed of rectilinear motion. 124 | * 125 | * To calculate speed, you can use the formula V0 + a * t, where v is speed, t is time. 126 | * 127 | * @param[in] end_speed The end speed 128 | * @param[in] acceleration The acceleration 129 | * @param[in] time The time 130 | * 131 | * @return The speed of rectilinear motion. 132 | */ 133 | auto calculate_speed_of_rectilinear_motion(double end_speed, double acceleration, 134 | double time) -> double; 135 | } // namespace physics::kinematics 136 | 137 | #endif // LIBNUMERIXPP_PHYSICS_KINEMATICS_HPP 138 | -------------------------------------------------------------------------------- /docs/man/man3/physics_kinematics.3: -------------------------------------------------------------------------------- 1 | .TH "physics::kinematics" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | physics::kinematics \- Namespace of kinematics (physics) 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Functions" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "double \fBcalculatePath\fP (double speed, double time)" 15 | .br 16 | .RI "Calculates the path\&. " 17 | .ti -1c 18 | .RI "double \fBcalculateSpeed\fP (double path, double time)" 19 | .br 20 | .RI "Calculates the speed\&. " 21 | .ti -1c 22 | .RI "double \fBcalculateTime\fP (double path, double speed)" 23 | .br 24 | .RI "Calculates the time\&. " 25 | .ti -1c 26 | .RI "double \fBcalculateFinalVelocity\fP (double initial_velocity, double acceleration, double time)" 27 | .br 28 | .RI "Calculates the final velocity\&. " 29 | .ti -1c 30 | .RI "double \fBcalculateFinalPosition\fP (double initial_position, double initial_velocity, double acceleration, double time)" 31 | .br 32 | .RI "Calculates the final position\&. " 33 | .in -1c 34 | .SH "Detailed Description" 35 | .PP 36 | Namespace of kinematics (physics) 37 | 38 | 39 | .PP 40 | \fBTodo\fP 41 | .RS 4 42 | Add more kinematics equations 43 | .RE 44 | .PP 45 | 46 | .SH "Function Documentation" 47 | .PP 48 | .SS "double physics::kinematics::calculateFinalPosition (double initial_position, double initial_velocity, double acceleration, double time)" 49 | 50 | .PP 51 | Calculates the final position\&. This function is based on the kinematics equation: s = u*t + 0\&.5 * a * t^2 where: 52 | .IP "\(bu" 2 53 | s - final position (m) 54 | .IP "\(bu" 2 55 | u - start speed (m/s) 56 | .IP "\(bu" 2 57 | a - acceleration (m/s^2) 58 | .IP "\(bu" 2 59 | t - time (s) 60 | .PP 61 | 62 | .PP 63 | \fBParameters\fP 64 | .RS 4 65 | \fIinitial_position\fP The initial position 66 | .br 67 | \fIinitial_velocity\fP The initial velocity 68 | .br 69 | \fIacceleration\fP The acceleration 70 | .br 71 | \fItime\fP The time 72 | .RE 73 | .PP 74 | \fBReturns\fP 75 | .RS 4 76 | The final position\&. 77 | .RE 78 | .PP 79 | 80 | .SS "double physics::kinematics::calculateFinalVelocity (double initial_velocity, double acceleration, double time)" 81 | 82 | .PP 83 | Calculates the final velocity\&. This function is based on the basic kinematics equation: v = u + at where: 84 | .IP "\(bu" 2 85 | v - final velocity (m/s) 86 | .IP "\(bu" 2 87 | u - start speed (m/s) 88 | .IP "\(bu" 2 89 | a - accelaration (m/s^2) 90 | .IP "\(bu" 2 91 | t - time (s) 92 | .PP 93 | 94 | .PP 95 | \fBParameters\fP 96 | .RS 4 97 | \fIinitial_velocity\fP The initial velocity 98 | .br 99 | \fIacceleration\fP The acceleration 100 | .br 101 | \fItime\fP The time 102 | .RE 103 | .PP 104 | \fBReturns\fP 105 | .RS 4 106 | The final velocity\&. 107 | .RE 108 | .PP 109 | 110 | .SS "double physics::kinematics::calculatePath (double speed, double time)" 111 | 112 | .PP 113 | Calculates the path\&. This function is based on basic formule: S = v * t where: 114 | .IP "\(bu" 2 115 | S - path (m) 116 | .IP "\(bu" 2 117 | v - speed (m/s) 118 | .IP "\(bu" 2 119 | t - time (s) 120 | .PP 121 | 122 | .PP 123 | \fBParameters\fP 124 | .RS 4 125 | \fIspeed\fP The speed 126 | .br 127 | \fItime\fP The time 128 | .RE 129 | .PP 130 | \fBReturns\fP 131 | .RS 4 132 | The path\&. 133 | .RE 134 | .PP 135 | 136 | .SS "double physics::kinematics::calculateSpeed (double path, double time)" 137 | 138 | .PP 139 | Calculates the speed\&. This function is based on basic formule: S = v * t where: 140 | .IP "\(bu" 2 141 | S - path (m) 142 | .IP "\(bu" 2 143 | v - speed (m/s) 144 | .IP "\(bu" 2 145 | t - time (s) 146 | .PP 147 | 148 | .PP 149 | \fBParameters\fP 150 | .RS 4 151 | \fIpath\fP The path 152 | .br 153 | \fItime\fP The time 154 | .RE 155 | .PP 156 | \fBReturns\fP 157 | .RS 4 158 | The speed\&. 159 | .RE 160 | .PP 161 | 162 | .SS "double physics::kinematics::calculateTime (double path, double speed)" 163 | 164 | .PP 165 | Calculates the time\&. This function is based on basic formule: S = v * t where: 166 | .IP "\(bu" 2 167 | S - path (m) 168 | .IP "\(bu" 2 169 | v - speed (m/s) 170 | .IP "\(bu" 2 171 | t - time (s) 172 | .PP 173 | 174 | .PP 175 | \fBParameters\fP 176 | .RS 4 177 | \fIpath\fP The path 178 | .br 179 | \fIspeed\fP The speed 180 | .RE 181 | .PP 182 | \fBReturns\fP 183 | .RS 4 184 | The time\&. 185 | .RE 186 | .PP 187 | 188 | .SH "Author" 189 | .PP 190 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 191 | -------------------------------------------------------------------------------- /include/libnumerixpp/mathematics/core.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Core utils for mathematics 4 | * @authors alxvdev 5 | */ 6 | #ifndef LIBNUMERIXPP_MATHEMATICS_CORE_HPP 7 | #define LIBNUMERIXPP_MATHEMATICS_CORE_HPP 8 | 9 | #pragma once 10 | 11 | /** 12 | * @brief Basic mathematics utils 13 | * @include example-2.cpp 14 | */ 15 | namespace mathematics { 16 | /** 17 | * @brief Algorithm for fast exponentiation "'Old' approximation" 18 | * 19 | * @details If accuracy is not important to you and the degrees are in 20 | * the range from -1 to 1, you can use this method (see 21 | *also 'another' approximation: anotherApproximatePower()). This method is based 22 | *on the algorithm used in the 2005 game Quake III Arena. He raised the number x 23 | *to the power -0.5, i.e. found the value: \f$\frac{1}{\sqrt{x}}\f$ 24 | * 25 | * @param[in] base The base 26 | * @param[in] exponent The exponent 27 | * 28 | * @return raised value 29 | */ 30 | auto old_approximate_power(double base, double exponent) -> double; 31 | 32 | /** 33 | * @brief Algorithm for fast exponentiation "'Another' approximation" 34 | * 35 | * @details Speed increase: ~9 times. Accuracy: <1.5%. Limitations: 36 | * accuracy drops rapidly as the absolute value of the 37 | *degree increases and remains acceptable in the range [-10, 10] (see also 'old' 38 | *approximation: oldApproximatePower()). 39 | * 40 | * @param[in] base The base 41 | * @param[in] exponent The exponent 42 | * 43 | * @return raised value 44 | */ 45 | auto another_approximate_power(double base, double exponent) -> double; 46 | 47 | /** 48 | * @brief Algorithm: Binary exponentiation 49 | * @details Speed increase: ~7.5 times on average, the advantage remains 50 | * until numbers are raised to a power of 134217728, 51 | *Speed increase: ~7.5 times on average, the advantage remains until the numbers 52 | *are raised to the power of 134217728. Error: none, but it is worth noting that 53 | *the multiplication operation is not associative for floating point numbers, 54 | *i.e. 1.21 * 1.21 is not the same as 1.1 * 1.1 * 1.1 * 1.1, however, when 55 | *compared with standard functions, errors do not arise, as mentioned earlier. 56 | *Restrictions: the degree must be an integer not less than 0 57 | * 58 | * @param[in] base base 59 | * @param[in] exponent exponent 60 | * 61 | * @return raised value 62 | */ 63 | auto binary_power(double b, unsigned long long e) -> double; 64 | 65 | /** 66 | * @brief Algorithm: "Dividing fast power" 67 | * 68 | * @details Speed increase: ~3.5 times. Accuracy: ~13%. The code below 69 | * contains checks for special input data. Without them, 70 | *the code runs only 10% faster, but the error increases tenfold (especially 71 | *when using negative powers). 72 | * 73 | * @param[in] base The base 74 | * @param[in] exponent The exponent 75 | * 76 | * @return raised value 77 | */ 78 | auto fast_power_dividing(double base, double exponent) -> double; 79 | 80 | /** 81 | * @brief Algorithm: "Fractional fast power" 82 | * @details Speed increase: ~4.4 times. Accuracy: ~0.7% 83 | * 84 | * @param[in] base The base 85 | * @param[in] exponent The exponent 86 | * 87 | * @return raised value 88 | */ 89 | auto fast_power_fractional(double base, double exponent) -> double; 90 | 91 | /** 92 | * @brief Adds a percent to number. 93 | * 94 | * @param[in] number The number 95 | * @param[in] percentage The percentage 96 | * 97 | * @return number 98 | */ 99 | auto add_percent_to_number(double number, double percentage) -> double; 100 | 101 | /** 102 | * @brief Gets the number square (N^2). 103 | * 104 | * @param[in] num The number 105 | * 106 | * @return The number square. 107 | */ 108 | auto square_it_up(double num) -> double; 109 | 110 | /** 111 | * @brief Gets the square root. 112 | * 113 | * @param[in] num The number 114 | * 115 | * @return The square root. 116 | */ 117 | auto get_square_root(double num) -> double; 118 | 119 | /** 120 | * @brief Getting the modulus of a number without a comparison 121 | * operation 122 | * 123 | * @param[in] x number 124 | * 125 | * @return modulus of number 126 | */ 127 | auto intabs(int x) -> int; 128 | } // namespace mathematics 129 | 130 | #endif // LIBNUMERIXPP_MATHEMATICS_CORE_HPP 131 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | commit ac6c8d3d892a643c23887f51ec4d4adfbf9fb54f 2 | Author: alexeev-prog 3 | Date: Sat Oct 5 20:50:56 2024 +0700 4 | 5 | docs/fix: update docs, fix example 6 | 7 | commit a6a9ec417c5377e4249268d2b7399bcb18b309d4 8 | Author: alexeev-prog 9 | Date: Fri Oct 4 22:15:43 2024 +0700 10 | 11 | docs: update docs 12 | 13 | commit f6ae621a34044602378c45862483217c3cc70653 14 | Author: alexeev-prog 15 | Date: Fri Oct 4 22:13:36 2024 +0700 16 | 17 | docs: update docs 18 | 19 | commit e48ce12297fa2a497024d1a56e085503ad0cef0a 20 | Author: alexeev-prog 21 | Date: Fri Oct 4 22:03:26 2024 +0700 22 | 23 | Trigger rebuild 24 | 25 | commit 69d2c6453df62e853db1144cbfb56b81cb04b892 26 | Author: alexeev-prog 27 | Date: Fri Oct 4 21:58:30 2024 +0700 28 | 29 | docs: update docs 30 | 31 | commit e0dc361414ba20087978848081e6228016f708a8 32 | Author: alexeev-dev 33 | Date: Fri Oct 4 21:53:36 2024 +0700 34 | 35 | docs: update docs 36 | 37 | commit 3a44d6838e6f0b6a1f0aa3d8cf07e79fd548c7a1 38 | Author: alexeev-dev 39 | Date: Fri Oct 4 21:53:23 2024 +0700 40 | 41 | build.sh 42 | 43 | commit 3e4247c67c65e74dfe6b14e3d74acf209ccf8cd2 44 | Author: alexeev-dev 45 | Date: Fri Oct 4 21:50:44 2024 +0700 46 | 47 | Trigger rebuild 48 | 49 | commit 38c6e9a7d9bfba350b4230daa9badd2683a53971 50 | Author: Alexeev Bronislav 51 | Date: Fri Oct 4 21:48:54 2024 +0700 52 | 53 | Create static.yml 54 | 55 | commit 4bb27f8f472542ccb78ba10fe0bfda634f89e8ce 56 | Author: alexeev-dev 57 | Date: Fri Oct 4 21:47:45 2024 +0700 58 | 59 | docs 60 | 61 | commit 6519eda9c3c8e53e320070a222b11e5176525976 62 | Author: alexeev-dev 63 | Date: Fri Oct 4 21:42:23 2024 +0700 64 | 65 | Trigger rebuild 66 | 67 | commit 716437c1697141e3b1d5132e47cffa3be06c8bfe 68 | Author: alexeev-dev 69 | Date: Fri Oct 4 21:37:48 2024 +0700 70 | 71 | docs: improve docs 72 | 73 | commit 59141d383e16ba82d6000b97db7b396df568bd5d 74 | Author: alexeev-dev 75 | Date: Fri Oct 4 21:37:13 2024 +0700 76 | 77 | docs: improve docs 78 | 79 | commit 50cd02893d94c8983bb7f420f0296b54c4dd7436 80 | Author: Alexeev Bronislav 81 | Date: Fri Oct 4 21:22:02 2024 +0700 82 | 83 | Create SECURITY.md 84 | 85 | commit f7c4079fb94dc5f2c55ea91a37b9604881cf166e 86 | Author: Alexeev Bronislav 87 | Date: Fri Oct 4 21:20:22 2024 +0700 88 | 89 | Update issue templates 90 | 91 | commit a87af0b449443678416a8f53c9fdb05ac3a85f15 92 | Author: Alexeev Bronislav 93 | Date: Fri Oct 4 21:18:11 2024 +0700 94 | 95 | Create CONTRIBUTING.md 96 | 97 | commit 51c0d291acc4a6d70b3227dd899dcc41a6271b01 98 | Author: Alexeev Bronislav 99 | Date: Fri Oct 4 21:15:32 2024 +0700 100 | 101 | Create CODE_OF_CONDUCT.md 102 | 103 | commit 19ef8021965c2db23dfb65384cd3fc948ecf3f80 104 | Author: alexeev-dev 105 | Date: Fri Oct 4 21:15:09 2024 +0700 106 | 107 | docs: update&improve docs 108 | 109 | commit 5628fdf61c790946fd2b1f69780ae3b644a10702 110 | Author: alexeev-dev 111 | Date: Fri Oct 4 19:30:29 2024 +0700 112 | 113 | refactor/feat: improve physics/kinematics 114 | 115 | commit 00da6707b22227491a42187f0a5b6cb4d671f2e8 116 | Author: alexeev-dev 117 | Date: Fri Oct 4 18:48:43 2024 +0700 118 | 119 | feat: add more functions in physics/kinematics, other small changes 120 | 121 | commit aad6c8e28ca94c038bdc17395a7f3df41481181a 122 | Author: alexeev-dev 123 | Date: Fri Oct 4 17:40:00 2024 +0700 124 | 125 | fix/refactor: fix bug in computerscience/core module, improve formatting 126 | 127 | commit 67cd872b95878f0a9a64fd0ce2eebf39d49efb9e 128 | Author: alexeev-dev 129 | Date: Mon Sep 30 23:36:06 2024 +0700 130 | 131 | fix docs 132 | 133 | commit 9f7fa529941412ad4f88bda58ab0a43cb22ea9d4 134 | Author: Alexeev Bronislav 135 | Date: Mon Sep 30 23:34:55 2024 +0700 136 | 137 | Create static.yml 138 | 139 | commit 682c635dd2a35a401e7fb550691e502cfc5fbb00 140 | Author: alexeev-dev 141 | Date: Mon Sep 30 23:32:25 2024 +0700 142 | 143 | Initial commit / move repo 144 | -------------------------------------------------------------------------------- /docs/man/man3/mathematics_quadratic.3: -------------------------------------------------------------------------------- 1 | .TH "mathematics::quadratic" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | mathematics::quadratic 6 | .SH SYNOPSIS 7 | .br 8 | .PP 9 | .SS "Functions" 10 | 11 | .in +1c 12 | .ti -1c 13 | .RI "double \fBcalculateDiscriminant\fP (double a, double b, double c)" 14 | .br 15 | .RI "Calculates the discriminant\&. " 16 | .ti -1c 17 | .RI "std::vector< double > \fBcalculateRootsByDiscriminant\fP (double discriminant, double a, double b)" 18 | .br 19 | .RI "Calculates the roots by discriminant\&. " 20 | .ti -1c 21 | .RI "std::vector< double > \fBgetRootsByVietaTheorem\fP (double a, double b, double c)" 22 | .br 23 | .RI "Gets the roots by vieta theorem\&. " 24 | .in -1c 25 | .SH "Detailed Description" 26 | .PP 27 | mathematics utils for quadratic equations and other 28 | 29 | .PP 30 | .PP 31 | .nf 32 | #include 33 | #include 34 | #include "libnumerixpp/libnumerixpp\&.hpp" 35 | #include "libnumerixpp/core/common\&.hpp" 36 | #include "libnumerixpp/mathematics/core\&.hpp" 37 | #include "libnumerixpp/mathematics/quadratic_equations\&.hpp" 38 | 39 | int main() { 40 | credits(); 41 | println("LIBNUMERIXPP"); 42 | 43 | // SQUARE AND SQR // 44 | 45 | double num = 100\&.0; 46 | double num_sq = mathematics::square_it_up(num); 47 | double num_sqr = mathematics::get_square_root(num); 48 | std::cout << "Square " << num << ": " << num_sq << std::endl; 49 | std::cout << "Square root " << num << ": " << num_sqr << std::endl; 50 | 51 | std::cout << std::endl; 52 | 53 | // CALCULATE QUADRATIC EQUATION BY DISCRIMINANT // 54 | 55 | double a = \-2; 56 | double b = 5; 57 | double c = 5; 58 | 59 | double d = mathematics::quadratic::calculateDiscriminant(a, b, c); 60 | std::vector roots = mathematics::quadratic::calculateRootsByDiscriminant(d, a, b); 61 | 62 | std::cout << "Quadratic Equation: a=" << a << "; b=" << b << "; c=" << c << std::endl; 63 | std::cout << "D=" << d << std::endl; 64 | std::cout << "Roots:" << std::endl; 65 | 66 | for (double root : roots) { 67 | std::cout << root << std::endl; 68 | } 69 | 70 | std::cout << std::endl; 71 | 72 | // PERCENTAGE // 73 | 74 | double nump = mathematics::add_percent_to_number(100\&.0, 10\&.0); 75 | std::cout << "100+10%: " << nump << std::endl; 76 | 77 | std::cout << std::endl; 78 | 79 | // POWER / Algorithms for fast exponentiation // 80 | 81 | double bestPowVal = 100; 82 | double pow_results[5] = { 83 | mathematics::oldApproximatePower(10\&.0, 2\&.0), 84 | mathematics::anotherApproximatePower(10\&.0, 2\&.0), 85 | mathematics::binaryPower(10\&.0, 2), 86 | mathematics::fastPowerDividing(10\&.0, 2\&.0), 87 | mathematics::fastPowerFractional(10\&.0, 2\&.0) 88 | }; 89 | 90 | std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << std::endl; 91 | std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << std::endl; 92 | std::cout << "2 binaryPower : base 10 exponent 2: " << pow_results[2] << std::endl; 93 | std::cout << "3 fastPowerDividing : base 10 exponent 2: " << pow_results[3] << std::endl; 94 | std::cout << "4 fastPowerFractional : base 10 exponent 2: " << pow_results[4] << std::endl; 95 | 96 | for (int i = 0; i < sizeof(pow_results) / sizeof(pow_results[0]); i++) { 97 | double error = bestPowVal \- pow_results[i]; 98 | 99 | std::cout << "POW Algorithm #" << i << ": error=" << error << std::endl; 100 | } 101 | 102 | std::cout << std::endl; 103 | 104 | // Other // 105 | 106 | std::cout << "\-10 number module: " << mathematics::intabs(\-10) << std::endl; 107 | 108 | return 0; 109 | } 110 | .fi 111 | .PP 112 | 113 | .SH "Function Documentation" 114 | .PP 115 | .SS "double mathematics::quadratic::calculateDiscriminant (double a, double b, double c)" 116 | 117 | .PP 118 | Calculates the discriminant\&. Based on discriminant formula: $b^{2} - 4ac$ 119 | 120 | .PP 121 | \fBParameters\fP 122 | .RS 4 123 | \fIa\fP a 124 | .br 125 | \fIb\fP b 126 | .br 127 | \fIc\fP c 128 | .RE 129 | .PP 130 | \fBReturns\fP 131 | .RS 4 132 | The discriminant\&. 133 | .RE 134 | .PP 135 | 136 | .SS "std::vector< double > mathematics::quadratic::calculateRootsByDiscriminant (double discriminant, double a, double b)" 137 | 138 | .PP 139 | Calculates the roots by discriminant\&. Calculate the roots by discriminant $\frac{-b +- 140 | \sqrt{D}}{2a}$\&. D > 0 = 2 roots, D == 0 = 1 root, D < 0 = 0 roots\&. 141 | 142 | .PP 143 | \fBParameters\fP 144 | .RS 4 145 | \fIdiscriminant\fP The discriminant 146 | .br 147 | \fIa\fP a 148 | .br 149 | \fIb\fP b 150 | .RE 151 | .PP 152 | \fBReturns\fP 153 | .RS 4 154 | The roots by discriminant\&. 155 | .RE 156 | .PP 157 | 158 | .SS "std::vector< double > mathematics::quadratic::getRootsByVietaTheorem (double a, double b, double c)" 159 | 160 | .PP 161 | Gets the roots by vieta theorem\&. 162 | .PP 163 | \fBParameters\fP 164 | .RS 4 165 | \fIa\fP a 166 | .br 167 | \fIb\fP b 168 | .br 169 | \fIc\fP c 170 | .RE 171 | .PP 172 | \fBReturns\fP 173 | .RS 4 174 | The roots by vieta theorem\&. 175 | .RE 176 | .PP 177 | 178 | .SH "Author" 179 | .PP 180 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 181 | -------------------------------------------------------------------------------- /docs/man/man3/computerscience.3: -------------------------------------------------------------------------------- 1 | .TH "computerscience" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | computerscience \- Basic Computer science utils\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Functions" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "std::string \fBconvertDecimalToBinary\fP (int decimal)" 15 | .br 16 | .RI "convert decimal to binary " 17 | .ti -1c 18 | .RI "int \fBconvertBinaryToDecimal\fP (std::string &binary)" 19 | .br 20 | .RI "convert binary to decimal " 21 | .ti -1c 22 | .RI "std::string \fBconvertDecimalToHexadecimal\fP (int decimal)" 23 | .br 24 | .RI "convert decimal to hexadecimal " 25 | .ti -1c 26 | .RI "int \fBconvertHexadecimalToDecimal\fP (std::string &hexadecimal)" 27 | .br 28 | .RI "convert hexadecimal to decimal " 29 | .ti -1c 30 | .RI "std::string \fBconvertBinaryToHexadecimal\fP (std::string &binary)" 31 | .br 32 | .RI "convert binary to hexadecimal " 33 | .ti -1c 34 | .RI "std::string \fBconvertHexadecimalToBinary\fP (std::string hexadecimal)" 35 | .br 36 | .RI "convert hexadecimal to binary " 37 | .ti -1c 38 | .RI "std::string \fBhumanizeBytesSize\fP (long long bytes, const std::string &suffix='B')" 39 | .br 40 | .RI "Scale bytes to its proper format\&. " 41 | .in -1c 42 | .SH "Detailed Description" 43 | .PP 44 | Basic Computer science utils\&. 45 | 46 | 47 | .PP 48 | .nf 49 | #include 50 | #include 51 | #include "libnumerixpp/libnumerixpp\&.hpp" 52 | #include "libnumerixpp/core/common\&.hpp" 53 | #include "libnumerixpp/computerscience/core\&.hpp" 54 | 55 | #include 56 | 57 | int main() { 58 | credits(); 59 | println("LIBNUMERIXPP"); 60 | 61 | int decimalNumber = 777; 62 | std::string binaryNumber = computerscience::convertDecimalToBinary(decimalNumber); 63 | int decimalNumber2 = computerscience::convertBinaryToDecimal(binaryNumber); 64 | std::string hexadecimalNumber = computerscience::convertDecimalToHexadecimal(decimalNumber); 65 | int decimalNumber3 = computerscience::convertHexadecimalToDecimal(hexadecimalNumber); 66 | std::string hexadecimalNumber2 = computerscience::convertBinaryToHexadecimal(binaryNumber); 67 | std::string binaryNumber2 = computerscience::convertHexadecimalToBinary(hexadecimalNumber); 68 | long long bytes = 1024 * 1024; 69 | 70 | std::cout << "Convert decimal " << decimalNumber << " to binary: " << binaryNumber << std::endl; 71 | std::cout << "Convert binary " << binaryNumber << " to decimal: " << decimalNumber2 << std::endl; 72 | std::cout << "Convert decimal " << decimalNumber << " to hexadecimal: " << hexadecimalNumber << std::endl; 73 | std::cout << "Convert hexadecimal " << hexadecimalNumber << " to decimal: " << decimalNumber3 << std::endl; 74 | std::cout << "Convert binary " << binaryNumber << " to hexadecimal: " << hexadecimalNumber2 << std::endl; 75 | std::cout << "Convert hexadecimal " << hexadecimalNumber << " to binary: " << binaryNumber2 << std::endl; 76 | std::cout << "Convert " << bytes << ": " << computerscience::humanizeBytesSize(bytes) << std::endl; 77 | 78 | return 0; 79 | } 80 | 81 | .fi 82 | .PP 83 | 84 | .SH "Function Documentation" 85 | .PP 86 | .SS "int computerscience::convertBinaryToDecimal (std::string & binary)" 87 | 88 | .PP 89 | convert binary to decimal 90 | .PP 91 | \fBParameters\fP 92 | .RS 4 93 | \fIbinary\fP The binary 94 | .RE 95 | .PP 96 | \fBReturns\fP 97 | .RS 4 98 | decimal integer 99 | .RE 100 | .PP 101 | 102 | .SS "std::string computerscience::convertBinaryToHexadecimal (std::string & binary)" 103 | 104 | .PP 105 | convert binary to hexadecimal 106 | .PP 107 | \fBParameters\fP 108 | .RS 4 109 | \fIbinary\fP The binary 110 | .RE 111 | .PP 112 | \fBReturns\fP 113 | .RS 4 114 | hexadecimal number string 115 | .RE 116 | .PP 117 | 118 | .SS "std::string computerscience::convertDecimalToBinary (int decimal)" 119 | 120 | .PP 121 | convert decimal to binary 122 | .PP 123 | \fBParameters\fP 124 | .RS 4 125 | \fIdecimal\fP The decimal 126 | .RE 127 | .PP 128 | \fBReturns\fP 129 | .RS 4 130 | binary number string 131 | .RE 132 | .PP 133 | 134 | .SS "std::string computerscience::convertDecimalToHexadecimal (int decimal)" 135 | 136 | .PP 137 | convert decimal to hexadecimal 138 | .PP 139 | \fBParameters\fP 140 | .RS 4 141 | \fIdecimal\fP The decimal 142 | .RE 143 | .PP 144 | \fBReturns\fP 145 | .RS 4 146 | hexadecimal number string 147 | .RE 148 | .PP 149 | 150 | .SS "std::string computerscience::convertHexadecimalToBinary (std::string hexadecimal)" 151 | 152 | .PP 153 | convert hexadecimal to binary 154 | .PP 155 | \fBParameters\fP 156 | .RS 4 157 | \fIhexadecimal\fP The hexadecimal 158 | .RE 159 | .PP 160 | \fBReturns\fP 161 | .RS 4 162 | binary number string 163 | .RE 164 | .PP 165 | 166 | .SS "int computerscience::convertHexadecimalToDecimal (std::string & hexadecimal)" 167 | 168 | .PP 169 | convert hexadecimal to decimal 170 | .PP 171 | \fBParameters\fP 172 | .RS 4 173 | \fIhexadecimal\fP The hexadecimal 174 | .RE 175 | .PP 176 | \fBReturns\fP 177 | .RS 4 178 | decimal integer 179 | .RE 180 | .PP 181 | 182 | .SS "std::string computerscience::humanizeBytesSize (long long bytes, const std::string & suffix = \fR'B'\fP)" 183 | 184 | .PP 185 | Scale bytes to its proper format\&. 186 | .PP 187 | \fBParameters\fP 188 | .RS 4 189 | \fIbytes\fP The bytes 190 | .br 191 | \fIsuffix\fP The suffix 192 | .RE 193 | .PP 194 | \fBReturns\fP 195 | .RS 4 196 | humanized size 197 | .RE 198 | .PP 199 | 200 | .SH "Author" 201 | .PP 202 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 203 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | dev.alexeev@inbox.ru. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /docs/versions/v0.1.3.md: -------------------------------------------------------------------------------- 1 | tag v0.1.3 2 | Tagger: alexeev-prog 3 | Date: Sat Oct 5 20:51:14 2024 +0700 4 | 5 | alpha version 0.1.3 6 | 7 | commit ac6c8d3d892a643c23887f51ec4d4adfbf9fb54f 8 | Author: alexeev-prog 9 | Date: Sat Oct 5 20:50:56 2024 +0700 10 | 11 | docs/fix: update docs, fix example 12 | 13 | diff --git a/CMakeLists.txt b/CMakeLists.txt 14 | index 83c664c..867b976 100644 15 | --- a/CMakeLists.txt 16 | +++ b/CMakeLists.txt 17 | @@ -4,9 +4,9 @@ include(cmake/prelude.cmake) 18 | 19 | project( 20 | libnumerixpp 21 | - VERSION 0.1.2 22 | + VERSION 0.1.3 23 | DESCRIPTION "A Powerful C++ Library for High-Performance Numerical Computing" 24 | - HOMEPAGE_URL "https://alxvdev.github.io/libnumerixpp" 25 | + HOMEPAGE_URL "https://alexeev-prog.github.io/libnumerixpp" 26 | LANGUAGES CXX 27 | ) 28 | 29 | diff --git a/Doxyfile b/Doxyfile 30 | index e4736dd..2e1cd88 100644 31 | --- a/Doxyfile 32 | +++ b/Doxyfile 33 | @@ -48,7 +48,7 @@ PROJECT_NAME = "libnumerixpp" 34 | # could be handy for archiving the generated documentation or if some version 35 | # control system is used. 36 | 37 | -PROJECT_NUMBER = "0.1.2" 38 | +PROJECT_NUMBER = "0.1.3" 39 | 40 | # Using the PROJECT_BRIEF tag one can provide an optional one line description 41 | # for a project that appears at the top of each page and should give viewer a 42 | diff --git a/README.md b/README.md 43 | index 1da533e..7ed80ac 100644 44 | --- a/README.md 45 | +++ b/README.md 46 | @@ -32,7 +32,22 @@ You can join to our [small russian telegram blog](https://t.me/hex_warehouse). 47 | 48 | > You can view docs for libnumerixpp [here](https://alexeev-prog.github.io/libnumerixpp). 49 | 50 | - > Current version: 0.1.2 51 | + > Current version: 0.1.3 52 | + 53 | +## Comparison to Alternatives 🤔 54 | +To help you decide whether libnumerixpp is the right choice for your project, here's a comparison table with some popular numerical computation libraries: 55 | + 56 | +| Feature | libnumerixpp | Eigen | Boost.Numeric | LAPACK | 57 | +| --- | --- | --- | --- | --- | 58 | +| Multi-disciplinary Approach | ✅ | ❌ | ❌ | ❌ | 59 | +| Equation Solving | ✅ | ❌ | ✅ | ❌ | 60 | +| Statistical Functions | ❌ | ❌ | ✅ | ❌ | 61 | +| Kinematics Calculations | ✅ | ❌ | ❌ | ❌ | 62 | +| Number System Conversion | ✅ | ❌ | ❌ | ❌ | 63 | +| Doxygen Documentation | ✅ | ✅ | ✅ | ❌ | 64 | +| Unit Tests | ✅ | ✅ | ✅ | ✅ | 65 | +| Cross-platform Support | ✅ | ✅ | ✅ | ✅ | 66 | +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. 67 | 68 | ## Key Features 🔑 69 | The libnumerixpp library boasts an impressive array of features that set it apart from its competitors: 70 | @@ -59,21 +74,6 @@ Robust Infrastructure: 71 | - CMake build system 🛠️ for cross-platform compatibility and easy installation 72 | - clang-format code formatting 💅 for consistent and readable code 73 | 74 | -## Comparison to Alternatives 🤔 75 | -To help you decide whether libnumerixpp is the right choice for your project, here's a comparison table with some popular numerical computation libraries: 76 | - 77 | -| Feature | libnumerixpp | Eigen | Boost.Numeric | LAPACK | 78 | -| --- | --- | --- | --- | --- | 79 | -| Multi-disciplinary Approach | ✅ | ❌ | ❌ | ❌ | 80 | -| Equation Solving | ✅ | ❌ | ✅ | ❌ | 81 | -| Statistical Functions | ❌ | ❌ | ✅ | ❌ | 82 | -| Kinematics Calculations | ✅ | ❌ | ❌ | ❌ | 83 | -| Number System Conversion | ✅ | ❌ | ❌ | ❌ | 84 | -| Doxygen Documentation | ✅ | ✅ | ✅ | ❌ | 85 | -| Unit Tests | ✅ | ✅ | ✅ | ✅ | 86 | -| Cross-platform Support | ✅ | ✅ | ✅ | ✅ | 87 | -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. 88 | - 89 | ## Getting Started 🚀 90 | 91 | To get started with libnumerixpp, follow these simple steps: 92 | diff --git a/SECURITY.md b/SECURITY.md 93 | index 5eaa436..abda353 100644 94 | --- a/SECURITY.md 95 | +++ b/SECURITY.md 96 | @@ -7,6 +7,7 @@ currently being supported with security updates. 97 | 98 | | Version | Supported | 99 | | ------- | ------------------ | 100 | +| 0.1.3 | :white_check_mark: | 101 | | 0.1.2 | :white_check_mark: | 102 | | 0.1.1 | :x: | 103 | | 0.1.0 | :x: | 104 | diff --git a/docs/ru/article3.md b/docs/ru/article3.md 105 | index 424434b..bfbd91e 100644 106 | --- a/docs/ru/article3.md 107 | +++ b/docs/ru/article3.md 108 | @@ -31,6 +31,8 @@ 109 | 110 | Можно использовать свой README для ответа на другие вопросы. Например, дальнейшие цели в развитии проекта, информация о лицензиях, важных изменениях в коде. 111 | 112 | +Для этого можно использовать даже ChatGPT, да простит меня хабро-бог за эту фразу. 113 | + 114 | ## Содержание 115 | 116 | + [Первая часть](https://habr.com/ru/companies/timeweb/articles/845074/) 117 | diff --git a/examples/example-4.cpp b/examples/example-4.cpp 118 | index c5eb6ab..1f847e7 100644 119 | --- a/examples/example-4.cpp 120 | +++ b/examples/example-4.cpp 121 | @@ -13,7 +13,7 @@ void test_eq_sa(double (*f_eq)(double), double x0, const std::string &eq) { 122 | 123 | std::cout << "Equation solution " << eq << ":\t"; 124 | 125 | - z = mathematics::equations::successiveApproximationsFindingRoot(f_eq, x0, iterations); 126 | + z = mathematics::equations::successive_approximations_finding_root(f_eq, x0, iterations); 127 | 128 | std::cout << z << '\n'; 129 | 130 | diff --git a/src/libnumerixpp.cpp b/src/libnumerixpp.cpp 131 | index 5f70c45..1ac3876 100644 132 | --- a/src/libnumerixpp.cpp 133 | +++ b/src/libnumerixpp.cpp 134 | @@ -1,7 +1,7 @@ 135 | /** 136 | * @file 137 | * @brief A Powerful C++ Library for High-Performance Numerical Computing 138 | - * @version 0.1.2 139 | + * @version 0.1.3 140 | * @date 2024-09-21 141 | * @authors alxvdev 142 | * @copyright Apache 2.0 License 143 | -------------------------------------------------------------------------------- /HACKING.md: -------------------------------------------------------------------------------- 1 | # Hacking 2 | 3 | Here is some wisdom to help you build and test this project as a developer and 4 | potential contributor. 5 | 6 | If you plan to contribute, please read the [CONTRIBUTING](CONTRIBUTING.md) 7 | guide. 8 | 9 | ## Developer mode 10 | 11 | Build system targets that are only useful for developers of this project are 12 | hidden if the `libnumerixpp_DEVELOPER_MODE` option is disabled. Enabling this 13 | option makes tests and other developer targets and options available. Not 14 | enabling this option means that you are a consumer of this project and thus you 15 | have no need for these targets and options. 16 | 17 | Developer mode is always set to on in CI workflows. 18 | 19 | ### Presets 20 | 21 | This project makes use of [presets][1] to simplify the process of configuring 22 | the project. As a developer, you are recommended to always have the [latest 23 | CMake version][2] installed to make use of the latest Quality-of-Life 24 | additions. 25 | 26 | You have a few options to pass `libnumerixpp_DEVELOPER_MODE` to the configure 27 | command, but this project prefers to use presets. 28 | 29 | As a developer, you should create a `CMakeUserPresets.json` file at the root of 30 | the project: 31 | 32 | ```json 33 | { 34 | "version": 2, 35 | "cmakeMinimumRequired": { 36 | "major": 3, 37 | "minor": 14, 38 | "patch": 0 39 | }, 40 | "configurePresets": [ 41 | { 42 | "name": "dev", 43 | "binaryDir": "${sourceDir}/build/dev", 44 | "inherits": ["dev-mode", "conan", "ci-"], 45 | "cacheVariables": { 46 | "CMAKE_BUILD_TYPE": "Debug" 47 | } 48 | } 49 | ], 50 | "buildPresets": [ 51 | { 52 | "name": "dev", 53 | "configurePreset": "dev", 54 | "configuration": "Debug" 55 | } 56 | ], 57 | "testPresets": [ 58 | { 59 | "name": "dev", 60 | "configurePreset": "dev", 61 | "configuration": "Debug", 62 | "output": { 63 | "outputOnFailure": true 64 | } 65 | } 66 | ] 67 | } 68 | ``` 69 | 70 | You should replace `` in your newly created presets file with the name of 71 | the operating system you have, which may be `win64`, `linux` or `darwin`. You 72 | can see what these correspond to in the 73 | [`CMakePresets.json`](CMakePresets.json) file. 74 | 75 | `CMakeUserPresets.json` is also the perfect place in which you can put all 76 | sorts of things that you would otherwise want to pass to the configure command 77 | in the terminal. 78 | 79 | > **Note** 80 | > Some editors are pretty greedy with how they open projects with presets. 81 | > Some just randomly pick a preset and start configuring without your consent, 82 | > which can be confusing. Make sure that your editor configures when you 83 | > actually want it to, for example in CLion you have to make sure only the 84 | > `dev-dev preset` has `Enable profile` ticked in 85 | > `File > Settings... > Build, Execution, Deployment > CMake` and in Visual 86 | > Studio you have to set the option `Never run configure step automatically` 87 | > in `Tools > Options > CMake` **prior to opening the project**, after which 88 | > you can manually configure using `Project > Configure Cache`. 89 | 90 | ### Dependency manager 91 | 92 | The above preset will make use of the [conan][conan] dependency manager. After 93 | installing it, make sure you have a [Conan profile][profile] setup, then 94 | download the dependencies and generate the necessary CMake files by running 95 | this command in the project root: 96 | 97 | ```sh 98 | conan install . -s build_type=Debug -b missing 99 | ``` 100 | 101 | Note that if your conan profile does not specify the same compiler, standard 102 | level, build type and runtime library as CMake, then that could potentially 103 | cause issues. See the link above for profiles documentation. 104 | 105 | [conan]: https://conan.io/ 106 | [profile]: https://docs.conan.io/2/reference/config_files/profiles.html 107 | 108 | ### Configure, build and test 109 | 110 | If you followed the above instructions, then you can configure, build and test 111 | the project respectively with the following commands from the project root on 112 | any operating system with any build system: 113 | 114 | ```sh 115 | cmake --preset=dev 116 | cmake --build --preset=dev 117 | ctest --preset=dev 118 | ``` 119 | 120 | If you are using a compatible editor (e.g. VSCode) or IDE (e.g. CLion, VS), you 121 | will also be able to select the above created user presets for automatic 122 | integration. 123 | 124 | Please note that both the build and test commands accept a `-j` flag to specify 125 | the number of jobs to use, which should ideally be specified to the number of 126 | threads your CPU has. You may also want to add that to your preset using the 127 | `jobs` property, see the [presets documentation][1] for more details. 128 | 129 | ### Developer mode targets 130 | 131 | These are targets you may invoke using the build command from above, with an 132 | additional `-t ` flag: 133 | 134 | #### `coverage` 135 | 136 | Available if `ENABLE_COVERAGE` is enabled. This target processes the output of 137 | the previously run tests when built with coverage configuration. The commands 138 | this target runs can be found in the `COVERAGE_TRACE_COMMAND` and 139 | `COVERAGE_HTML_COMMAND` cache variables. The trace command produces an info 140 | file by default, which can be submitted to services with CI integration. The 141 | HTML command uses the trace command's output to generate an HTML document to 142 | `/coverage_html` by default. 143 | 144 | #### `docs` 145 | 146 | Available if `BUILD_MCSS_DOCS` is enabled. Builds to documentation using 147 | Doxygen and m.css. The output will go to `/docs` by default 148 | (customizable using `DOXYGEN_OUTPUT_DIRECTORY`). 149 | 150 | #### `format-check` and `format-fix` 151 | 152 | These targets run the clang-format tool on the codebase to check errors and to 153 | fix them respectively. Customization available using the `FORMAT_PATTERNS` and 154 | `FORMAT_COMMAND` cache variables. 155 | 156 | #### `spell-check` and `spell-fix` 157 | 158 | These targets run the codespell tool on the codebase to check errors and to fix 159 | them respectively. Customization available using the `SPELL_COMMAND` cache 160 | variable. 161 | 162 | [1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html 163 | [2]: https://cmake.org/download/ 164 | -------------------------------------------------------------------------------- /CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "cmakeMinimumRequired": { 4 | "major": 3, 5 | "minor": 14, 6 | "patch": 0 7 | }, 8 | "configurePresets": [ 9 | { 10 | "name": "cmake-pedantic", 11 | "hidden": true, 12 | "warnings": { 13 | "dev": true, 14 | "deprecated": true, 15 | "uninitialized": true, 16 | "unusedCli": true, 17 | "systemVars": false 18 | }, 19 | "errors": { 20 | "dev": true, 21 | "deprecated": true 22 | } 23 | }, 24 | { 25 | "name": "dev-mode", 26 | "hidden": true, 27 | "inherits": "cmake-pedantic", 28 | "cacheVariables": { 29 | "libnumerixpp_DEVELOPER_MODE": "ON" 30 | } 31 | }, 32 | { 33 | "name": "conan", 34 | "hidden": true, 35 | "cacheVariables": { 36 | "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/conan/conan_toolchain.cmake", 37 | "CMAKE_POLICY_DEFAULT_CMP0091": "NEW" 38 | } 39 | }, 40 | { 41 | "name": "cppcheck", 42 | "hidden": true, 43 | "cacheVariables": { 44 | "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr" 45 | } 46 | }, 47 | { 48 | "name": "clang-tidy", 49 | "hidden": true, 50 | "cacheVariables": { 51 | "CMAKE_CXX_CLANG_TIDY": "clang-tidy;--header-filter=^${sourceDir}/" 52 | } 53 | }, 54 | { 55 | "name": "ci-std", 56 | "description": "This preset makes sure the project actually builds with at least the specified standard", 57 | "hidden": true, 58 | "cacheVariables": { 59 | "CMAKE_CXX_EXTENSIONS": "OFF", 60 | "CMAKE_CXX_STANDARD": "17", 61 | "CMAKE_CXX_STANDARD_REQUIRED": "ON" 62 | } 63 | }, 64 | { 65 | "name": "flags-gcc-clang", 66 | "description": "These flags are supported by both GCC and Clang", 67 | "hidden": true, 68 | "cacheVariables": { 69 | "CMAKE_CXX_FLAGS": "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS=1 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast", 70 | "CMAKE_EXE_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now,-z,nodlopen", 71 | "CMAKE_SHARED_LINKER_FLAGS": "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now,-z,nodlopen" 72 | } 73 | }, 74 | { 75 | "name": "flags-appleclang", 76 | "hidden": true, 77 | "cacheVariables": { 78 | "CMAKE_CXX_FLAGS": "-fstack-protector-strong -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wimplicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wold-style-cast" 79 | } 80 | }, 81 | { 82 | "name": "flags-msvc", 83 | "description": "Note that all the flags after /W4 are required for MSVC to conform to the language standard", 84 | "hidden": true, 85 | "cacheVariables": { 86 | "CMAKE_CXX_FLAGS": "/sdl /guard:cf /utf-8 /diagnostics:caret /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w45038 /W4 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc", 87 | "CMAKE_EXE_LINKER_FLAGS": "/machine:x64 /guard:cf", 88 | "CMAKE_SHARED_LINKER_FLAGS": "/machine:x64 /guard:cf" 89 | } 90 | }, 91 | { 92 | "name": "ci-linux", 93 | "inherits": ["flags-gcc-clang", "ci-std"], 94 | "generator": "Unix Makefiles", 95 | "hidden": true, 96 | "cacheVariables": { 97 | "CMAKE_BUILD_TYPE": "Release" 98 | } 99 | }, 100 | { 101 | "name": "ci-darwin", 102 | "inherits": ["flags-appleclang", "ci-std"], 103 | "generator": "Xcode", 104 | "hidden": true, 105 | "cacheVariables": { 106 | "CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE": "PRE_TEST" 107 | } 108 | }, 109 | { 110 | "name": "ci-win64", 111 | "inherits": ["flags-msvc", "ci-std"], 112 | "generator": "Visual Studio 17 2022", 113 | "architecture": "x64", 114 | "hidden": true 115 | }, 116 | { 117 | "name": "coverage-linux", 118 | "binaryDir": "${sourceDir}/build/coverage", 119 | "inherits": "ci-linux", 120 | "hidden": true, 121 | "cacheVariables": { 122 | "ENABLE_COVERAGE": "ON", 123 | "CMAKE_BUILD_TYPE": "Coverage", 124 | "CMAKE_CXX_FLAGS_COVERAGE": "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions", 125 | "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage", 126 | "CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage", 127 | "CMAKE_MAP_IMPORTED_CONFIG_COVERAGE": "Coverage;RelWithDebInfo;Release;Debug;" 128 | } 129 | }, 130 | { 131 | "name": "ci-coverage", 132 | "inherits": ["coverage-linux", "dev-mode", "conan"], 133 | "cacheVariables": { 134 | "COVERAGE_HTML_COMMAND": "" 135 | } 136 | }, 137 | { 138 | "name": "ci-sanitize", 139 | "binaryDir": "${sourceDir}/build/sanitize", 140 | "inherits": ["ci-linux", "dev-mode", "conan"], 141 | "cacheVariables": { 142 | "CMAKE_BUILD_TYPE": "Sanitize", 143 | "CMAKE_CXX_FLAGS_SANITIZE": "-U_FORTIFY_SOURCE -O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common", 144 | "CMAKE_MAP_IMPORTED_CONFIG_SANITIZE": "Sanitize;RelWithDebInfo;Release;Debug;" 145 | } 146 | }, 147 | { 148 | "name": "ci-build", 149 | "binaryDir": "${sourceDir}/build", 150 | "hidden": true 151 | }, 152 | { 153 | "name": "ci-multi-config", 154 | "description": "Speed up multi-config generators by generating only one configuration instead of the defaults", 155 | "hidden": true, 156 | "cacheVariables": { 157 | "CMAKE_CONFIGURATION_TYPES": "Release" 158 | } 159 | }, 160 | { 161 | "name": "ci-macos", 162 | "inherits": ["ci-build", "ci-darwin", "dev-mode", "ci-multi-config", "conan"] 163 | }, 164 | { 165 | "name": "ci-ubuntu", 166 | "inherits": ["ci-build", "ci-linux", "clang-tidy", "conan", "cppcheck", "dev-mode"] 167 | }, 168 | { 169 | "name": "ci-windows", 170 | "inherits": ["ci-build", "ci-win64", "dev-mode", "ci-multi-config", "conan"] 171 | } 172 | ] 173 | } 174 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | --- 2 | # Enable ALL the things! Except not really 3 | # misc-non-private-member-variables-in-classes: the options don't do anything 4 | # modernize-use-nodiscard: too aggressive, attribute is situationally useful 5 | Checks: "*,\ 6 | -google-readability-todo,\ 7 | -altera-*,\ 8 | -fuchsia-*,\ 9 | fuchsia-multiple-inheritance,\ 10 | -llvm-header-guard,\ 11 | -llvm-include-order,\ 12 | -llvmlibc-*,\ 13 | -modernize-use-nodiscard,\ 14 | -misc-non-private-member-variables-in-classes" 15 | WarningsAsErrors: '' 16 | CheckOptions: 17 | - key: 'bugprone-argument-comment.StrictMode' 18 | value: 'true' 19 | # Prefer using enum classes with 2 values for parameters instead of bools 20 | - key: 'bugprone-argument-comment.CommentBoolLiterals' 21 | value: 'true' 22 | - key: 'bugprone-misplaced-widening-cast.CheckImplicitCasts' 23 | value: 'true' 24 | - key: 'bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression' 25 | value: 'true' 26 | - key: 'bugprone-suspicious-string-compare.WarnOnLogicalNotComparison' 27 | value: 'true' 28 | - key: 'readability-simplify-boolean-expr.ChainedConditionalReturn' 29 | value: 'true' 30 | - key: 'readability-simplify-boolean-expr.ChainedConditionalAssignment' 31 | value: 'true' 32 | - key: 'readability-uniqueptr-delete-release.PreferResetCall' 33 | value: 'true' 34 | - key: 'cppcoreguidelines-init-variables.MathHeader' 35 | value: '' 36 | - key: 'cppcoreguidelines-narrowing-conversions.PedanticMode' 37 | value: 'true' 38 | - key: 'readability-else-after-return.WarnOnUnfixable' 39 | value: 'true' 40 | - key: 'readability-else-after-return.WarnOnConditionVariables' 41 | value: 'true' 42 | - key: 'readability-inconsistent-declaration-parameter-name.Strict' 43 | value: 'true' 44 | - key: 'readability-qualified-auto.AddConstToQualified' 45 | value: 'true' 46 | - key: 'readability-redundant-access-specifiers.CheckFirstDeclaration' 47 | value: 'true' 48 | # These seem to be the most common identifier styles 49 | - key: 'readability-identifier-naming.AbstractClassCase' 50 | value: 'lower_case' 51 | - key: 'readability-identifier-naming.ClassCase' 52 | value: 'lower_case' 53 | - key: 'readability-identifier-naming.ClassConstantCase' 54 | value: 'lower_case' 55 | - key: 'readability-identifier-naming.ClassMemberCase' 56 | value: 'lower_case' 57 | - key: 'readability-identifier-naming.ClassMethodCase' 58 | value: 'lower_case' 59 | - key: 'readability-identifier-naming.ConstantCase' 60 | value: 'lower_case' 61 | - key: 'readability-identifier-naming.ConstantMemberCase' 62 | value: 'lower_case' 63 | - key: 'readability-identifier-naming.ConstantParameterCase' 64 | value: 'lower_case' 65 | - key: 'readability-identifier-naming.ConstantPointerParameterCase' 66 | value: 'lower_case' 67 | - key: 'readability-identifier-naming.ConstexprFunctionCase' 68 | value: 'lower_case' 69 | - key: 'readability-identifier-naming.ConstexprMethodCase' 70 | value: 'lower_case' 71 | - key: 'readability-identifier-naming.ConstexprVariableCase' 72 | value: 'lower_case' 73 | - key: 'readability-identifier-naming.EnumCase' 74 | value: 'lower_case' 75 | - key: 'readability-identifier-naming.EnumConstantCase' 76 | value: 'lower_case' 77 | - key: 'readability-identifier-naming.FunctionCase' 78 | value: 'lower_case' 79 | - key: 'readability-identifier-naming.GlobalConstantCase' 80 | value: 'lower_case' 81 | - key: 'readability-identifier-naming.GlobalConstantPointerCase' 82 | value: 'lower_case' 83 | - key: 'readability-identifier-naming.GlobalFunctionCase' 84 | value: 'lower_case' 85 | - key: 'readability-identifier-naming.GlobalPointerCase' 86 | value: 'lower_case' 87 | - key: 'readability-identifier-naming.GlobalVariableCase' 88 | value: 'lower_case' 89 | - key: 'readability-identifier-naming.InlineNamespaceCase' 90 | value: 'lower_case' 91 | - key: 'readability-identifier-naming.LocalConstantCase' 92 | value: 'lower_case' 93 | - key: 'readability-identifier-naming.LocalConstantPointerCase' 94 | value: 'lower_case' 95 | - key: 'readability-identifier-naming.LocalPointerCase' 96 | value: 'lower_case' 97 | - key: 'readability-identifier-naming.LocalVariableCase' 98 | value: 'lower_case' 99 | - key: 'readability-identifier-naming.MacroDefinitionCase' 100 | value: 'UPPER_CASE' 101 | - key: 'readability-identifier-naming.MemberCase' 102 | value: 'lower_case' 103 | - key: 'readability-identifier-naming.MethodCase' 104 | value: 'lower_case' 105 | - key: 'readability-identifier-naming.NamespaceCase' 106 | value: 'lower_case' 107 | - key: 'readability-identifier-naming.ParameterCase' 108 | value: 'lower_case' 109 | - key: 'readability-identifier-naming.ParameterPackCase' 110 | value: 'lower_case' 111 | - key: 'readability-identifier-naming.PointerParameterCase' 112 | value: 'lower_case' 113 | - key: 'readability-identifier-naming.PrivateMemberCase' 114 | value: 'lower_case' 115 | - key: 'readability-identifier-naming.PrivateMemberPrefix' 116 | value: 'm_' 117 | - key: 'readability-identifier-naming.PrivateMethodCase' 118 | value: 'lower_case' 119 | - key: 'readability-identifier-naming.ProtectedMemberCase' 120 | value: 'lower_case' 121 | - key: 'readability-identifier-naming.ProtectedMemberPrefix' 122 | value: 'm_' 123 | - key: 'readability-identifier-naming.ProtectedMethodCase' 124 | value: 'lower_case' 125 | - key: 'readability-identifier-naming.PublicMemberCase' 126 | value: 'lower_case' 127 | - key: 'readability-identifier-naming.PublicMethodCase' 128 | value: 'lower_case' 129 | - key: 'readability-identifier-naming.ScopedEnumConstantCase' 130 | value: 'lower_case' 131 | - key: 'readability-identifier-naming.StaticConstantCase' 132 | value: 'lower_case' 133 | - key: 'readability-identifier-naming.StaticVariableCase' 134 | value: 'lower_case' 135 | - key: 'readability-identifier-naming.StructCase' 136 | value: 'lower_case' 137 | - key: 'readability-identifier-naming.TemplateParameterCase' 138 | value: 'CamelCase' 139 | - key: 'readability-identifier-naming.TemplateTemplateParameterCase' 140 | value: 'CamelCase' 141 | - key: 'readability-identifier-naming.TypeAliasCase' 142 | value: 'lower_case' 143 | - key: 'readability-identifier-naming.TypedefCase' 144 | value: 'lower_case' 145 | - key: 'readability-identifier-naming.TypeTemplateParameterCase' 146 | value: 'CamelCase' 147 | - key: 'readability-identifier-naming.UnionCase' 148 | value: 'lower_case' 149 | - key: 'readability-identifier-naming.ValueTemplateParameterCase' 150 | value: 'CamelCase' 151 | - key: 'readability-identifier-naming.VariableCase' 152 | value: 'lower_case' 153 | - key: 'readability-identifier-naming.VirtualMethodCase' 154 | value: 'lower_case' 155 | ... 156 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: Google 4 | AccessModifierOffset: -1 5 | AlignAfterOpenBracket: Align 6 | AlignArrayOfStructures: None 7 | AlignConsecutiveAssignments: 8 | Enabled: false 9 | AcrossEmptyLines: false 10 | AcrossComments: false 11 | AlignCompound: false 12 | AlignFunctionPointers: false 13 | PadOperators: true 14 | AlignConsecutiveBitFields: 15 | Enabled: false 16 | AcrossEmptyLines: false 17 | AcrossComments: false 18 | AlignCompound: false 19 | AlignFunctionPointers: false 20 | PadOperators: false 21 | AlignConsecutiveDeclarations: 22 | Enabled: false 23 | AcrossEmptyLines: false 24 | AcrossComments: false 25 | AlignCompound: false 26 | AlignFunctionPointers: false 27 | PadOperators: false 28 | AlignConsecutiveMacros: 29 | Enabled: false 30 | AcrossEmptyLines: false 31 | AcrossComments: false 32 | AlignCompound: false 33 | AlignFunctionPointers: false 34 | PadOperators: false 35 | AlignConsecutiveShortCaseStatements: 36 | Enabled: false 37 | AcrossEmptyLines: false 38 | AcrossComments: false 39 | AlignCaseColons: false 40 | AlignEscapedNewlines: Left 41 | AlignOperands: Align 42 | AlignTrailingComments: 43 | Kind: Always 44 | OverEmptyLines: 0 45 | AllowAllArgumentsOnNextLine: true 46 | AllowAllParametersOfDeclarationOnNextLine: true 47 | AllowBreakBeforeNoexceptSpecifier: Never 48 | AllowShortBlocksOnASingleLine: Never 49 | AllowShortCaseLabelsOnASingleLine: false 50 | AllowShortCompoundRequirementOnASingleLine: true 51 | AllowShortEnumsOnASingleLine: true 52 | AllowShortFunctionsOnASingleLine: All 53 | AllowShortIfStatementsOnASingleLine: WithoutElse 54 | AllowShortLambdasOnASingleLine: All 55 | AllowShortLoopsOnASingleLine: true 56 | AlwaysBreakAfterDefinitionReturnType: None 57 | AlwaysBreakAfterReturnType: None 58 | AlwaysBreakBeforeMultilineStrings: true 59 | AlwaysBreakTemplateDeclarations: Yes 60 | AttributeMacros: 61 | - __capability 62 | BinPackArguments: true 63 | BinPackParameters: true 64 | BitFieldColonSpacing: Both 65 | BraceWrapping: 66 | AfterCaseLabel: true 67 | AfterClass: true 68 | AfterControlStatement: Never 69 | AfterEnum: true 70 | AfterExternBlock: true 71 | AfterFunction: true 72 | AfterNamespace: true 73 | AfterObjCDeclaration: false 74 | AfterStruct: true 75 | AfterUnion: true 76 | BeforeCatch: true 77 | BeforeElse: true 78 | BeforeLambdaBody: true 79 | BeforeWhile: true 80 | IndentBraces: true 81 | SplitEmptyFunction: true 82 | SplitEmptyRecord: true 83 | SplitEmptyNamespace: true 84 | BreakAdjacentStringLiterals: true 85 | BreakAfterAttributes: Leave 86 | BreakAfterJavaFieldAnnotations: false 87 | BreakArrays: true 88 | BreakBeforeBinaryOperators: None 89 | BreakBeforeConceptDeclarations: Always 90 | BreakBeforeBraces: Attach 91 | BreakBeforeInlineASMColon: OnlyMultiline 92 | BreakBeforeTernaryOperators: true 93 | BreakConstructorInitializers: BeforeColon 94 | BreakInheritanceList: BeforeColon 95 | BreakStringLiterals: true 96 | ColumnLimit: 100 97 | CommentPragmas: '^ IWYU pragma:' 98 | CompactNamespaces: false 99 | ConstructorInitializerIndentWidth: 4 100 | ContinuationIndentWidth: 4 101 | Cpp11BracedListStyle: false 102 | DerivePointerAlignment: true 103 | DisableFormat: false 104 | EmptyLineAfterAccessModifier: Never 105 | EmptyLineBeforeAccessModifier: LogicalBlock 106 | ExperimentalAutoDetectBinPacking: false 107 | FixNamespaceComments: true 108 | ForEachMacros: 109 | - foreach 110 | - Q_FOREACH 111 | - BOOST_FOREACH 112 | IfMacros: 113 | - KJ_IF_MAYBE 114 | IncludeBlocks: Regroup 115 | IncludeCategories: 116 | - Regex: '^' 117 | Priority: 2 118 | SortPriority: 0 119 | CaseSensitive: false 120 | - Regex: '^<.*\.h>' 121 | Priority: 1 122 | SortPriority: 0 123 | CaseSensitive: false 124 | - Regex: '^<.*' 125 | Priority: 2 126 | SortPriority: 0 127 | CaseSensitive: false 128 | - Regex: '.*' 129 | Priority: 3 130 | SortPriority: 0 131 | CaseSensitive: false 132 | IncludeIsMainRegex: '([-_](test|unittest))?$' 133 | IncludeIsMainSourceRegex: '' 134 | IndentAccessModifiers: false 135 | IndentCaseBlocks: true 136 | IndentCaseLabels: true 137 | IndentExternBlock: AfterExternBlock 138 | IndentGotoLabels: true 139 | IndentPPDirectives: None 140 | IndentRequiresClause: true 141 | IndentWidth: 4 142 | IndentWrappedFunctionNames: false 143 | InsertBraces: false 144 | InsertNewlineAtEOF: false 145 | InsertTrailingCommas: None 146 | IntegerLiteralSeparator: 147 | Binary: 0 148 | BinaryMinDigits: 0 149 | Decimal: 0 150 | DecimalMinDigits: 0 151 | Hex: 0 152 | HexMinDigits: 0 153 | JavaScriptQuotes: Leave 154 | JavaScriptWrapImports: true 155 | KeepEmptyLinesAtTheStartOfBlocks: false 156 | KeepEmptyLinesAtEOF: false 157 | LambdaBodyIndentation: Signature 158 | LineEnding: DeriveLF 159 | MacroBlockBegin: '' 160 | MacroBlockEnd: '' 161 | MaxEmptyLinesToKeep: 1 162 | NamespaceIndentation: All 163 | ObjCBinPackProtocolList: Never 164 | ObjCBlockIndentWidth: 4 165 | ObjCBreakBeforeNestedBlockParam: true 166 | ObjCSpaceAfterProperty: false 167 | ObjCSpaceBeforeProtocolList: true 168 | PackConstructorInitializers: NextLine 169 | PenaltyBreakAssignment: 2 170 | PenaltyBreakBeforeFirstCallParameter: 1 171 | PenaltyBreakComment: 300 172 | PenaltyBreakFirstLessLess: 120 173 | PenaltyBreakOpenParenthesis: 0 174 | PenaltyBreakScopeResolution: 500 175 | PenaltyBreakString: 1000 176 | PenaltyBreakTemplateDeclaration: 10 177 | PenaltyExcessCharacter: 1000000 178 | PenaltyIndentedWhitespace: 0 179 | PenaltyReturnTypeOnItsOwnLine: 200 180 | PointerAlignment: Left 181 | PPIndentWidth: -1 182 | QualifierAlignment: Leave 183 | RawStringFormats: 184 | - Language: Cpp 185 | Delimiters: 186 | - cc 187 | - CC 188 | - cpp 189 | - Cpp 190 | - CPP 191 | - 'c++' 192 | - 'C++' 193 | CanonicalDelimiter: '' 194 | BasedOnStyle: google 195 | - Language: TextProto 196 | Delimiters: 197 | - pb 198 | - PB 199 | - proto 200 | - PROTO 201 | EnclosingFunctions: 202 | - EqualsProto 203 | - EquivToProto 204 | - PARSE_PARTIAL_TEXT_PROTO 205 | - PARSE_TEST_PROTO 206 | - PARSE_TEXT_PROTO 207 | - ParseTextOrDie 208 | - ParseTextProtoOrDie 209 | - ParseTestProto 210 | - ParsePartialTestProto 211 | CanonicalDelimiter: pb 212 | BasedOnStyle: google 213 | ReferenceAlignment: Pointer 214 | ReflowComments: true 215 | RemoveBracesLLVM: false 216 | RemoveParentheses: Leave 217 | RemoveSemicolon: false 218 | RequiresClausePosition: OwnLine 219 | RequiresExpressionIndentation: OuterScope 220 | SeparateDefinitionBlocks: Leave 221 | ShortNamespaceLines: 1 222 | SkipMacroDefinitionBody: false 223 | SortIncludes: CaseSensitive 224 | SortJavaStaticImport: Before 225 | SortUsingDeclarations: LexicographicNumeric 226 | SpaceAfterCStyleCast: false 227 | SpaceAfterLogicalNot: false 228 | SpaceAfterTemplateKeyword: true 229 | SpaceAroundPointerQualifiers: Default 230 | SpaceBeforeAssignmentOperators: true 231 | SpaceBeforeCaseColon: false 232 | SpaceBeforeCpp11BracedList: false 233 | SpaceBeforeCtorInitializerColon: true 234 | SpaceBeforeInheritanceColon: true 235 | SpaceBeforeJsonColon: false 236 | SpaceBeforeParens: ControlStatements 237 | SpaceBeforeParensOptions: 238 | AfterControlStatements: true 239 | AfterForeachMacros: true 240 | AfterFunctionDefinitionName: false 241 | AfterFunctionDeclarationName: false 242 | AfterIfMacros: true 243 | AfterOverloadedOperator: false 244 | AfterPlacementOperator: true 245 | AfterRequiresInClause: false 246 | AfterRequiresInExpression: false 247 | BeforeNonEmptyParentheses: false 248 | SpaceBeforeRangeBasedForLoopColon: true 249 | SpaceBeforeSquareBrackets: false 250 | SpaceInEmptyBlock: false 251 | SpacesBeforeTrailingComments: 2 252 | SpacesInAngles: Never 253 | SpacesInContainerLiterals: true 254 | SpacesInLineCommentPrefix: 255 | Minimum: 1 256 | Maximum: -1 257 | SpacesInParens: Never 258 | SpacesInParensOptions: 259 | InCStyleCasts: false 260 | InConditionalStatements: false 261 | InEmptyParentheses: false 262 | Other: false 263 | SpacesInSquareBrackets: false 264 | Standard: Auto 265 | StatementAttributeLikeMacros: 266 | - Q_EMIT 267 | StatementMacros: 268 | - Q_UNUSED 269 | - QT_REQUIRE_VERSION 270 | TabWidth: 8 271 | UseTab: Never 272 | VerilogBreakBetweenInstancePorts: true 273 | WhitespaceSensitiveMacros: 274 | - BOOST_PP_STRINGIZE 275 | - CF_SWIFT_NAME 276 | - NS_SWIFT_NAME 277 | - PP_STRINGIZE 278 | - STRINGIZE 279 | ... 280 | 281 | -------------------------------------------------------------------------------- /docs/man/man3/mathematics.3: -------------------------------------------------------------------------------- 1 | .TH "mathematics" 3 "Version 0.1.0" "libnumerixpp" \" -*- nroff -*- 2 | .ad l 3 | .nh 4 | .SH NAME 5 | mathematics \- Basic mathematics utils\&. 6 | 7 | .SH SYNOPSIS 8 | .br 9 | .PP 10 | .SS "Namespaces" 11 | 12 | .in +1c 13 | .ti -1c 14 | .RI "namespace \fBquadratic\fP" 15 | .br 16 | .ti -1c 17 | .RI "namespace \fBstatistics\fP" 18 | .br 19 | .RI "Statistics namespace\&. " 20 | .in -1c 21 | .SS "Functions" 22 | 23 | .in +1c 24 | .ti -1c 25 | .RI "double \fBoldApproximatePower\fP (double base, double exponent)" 26 | .br 27 | .RI "Algorithm for fast exponentiation ''Old' approximation'\&. " 28 | .ti -1c 29 | .RI "double \fBbinaryPower\fP (double b, unsigned long long e)" 30 | .br 31 | .RI "Algorithm: Binary exponentiation\&. " 32 | .ti -1c 33 | .RI "double \fBfastPowerDividing\fP (double base, double exponent)" 34 | .br 35 | .RI "Algorithm: 'Dividing fast power'\&. " 36 | .ti -1c 37 | .RI "double \fBanotherApproximatePower\fP (double base, double exponent)" 38 | .br 39 | .RI "Algorithm for fast exponentiation ''Another' approximation'\&. " 40 | .ti -1c 41 | .RI "double \fBfastPowerFractional\fP (double base, double exponent)" 42 | .br 43 | .RI "Algorithm: 'Fractional fast power'\&. " 44 | .ti -1c 45 | .RI "double \fBadd_percent_to_number\fP (double number, double percentage)" 46 | .br 47 | .RI "Adds a percent to number\&. " 48 | .ti -1c 49 | .RI "double \fBsquare_it_up\fP (double num)" 50 | .br 51 | .RI "Gets the number square (N^2)\&. " 52 | .ti -1c 53 | .RI "double \fBget_square_root\fP (double num)" 54 | .br 55 | .RI "Gets the square root\&. " 56 | .ti -1c 57 | .RI "int \fBintabs\fP (int x)" 58 | .br 59 | .RI "Getting the modulus of a number without a comparison operation\&. " 60 | .in -1c 61 | .SH "Detailed Description" 62 | .PP 63 | Basic mathematics utils\&. 64 | 65 | 66 | .PP 67 | .nf 68 | #include 69 | #include 70 | #include "libnumerixpp/libnumerixpp\&.hpp" 71 | #include "libnumerixpp/core/common\&.hpp" 72 | #include "libnumerixpp/mathematics/core\&.hpp" 73 | #include "libnumerixpp/mathematics/quadratic_equations\&.hpp" 74 | 75 | int main() { 76 | credits(); 77 | println("LIBNUMERIXPP"); 78 | 79 | // SQUARE AND SQR // 80 | 81 | double num = 100\&.0; 82 | double num_sq = mathematics::square_it_up(num); 83 | double num_sqr = mathematics::get_square_root(num); 84 | std::cout << "Square " << num << ": " << num_sq << std::endl; 85 | std::cout << "Square root " << num << ": " << num_sqr << std::endl; 86 | 87 | std::cout << std::endl; 88 | 89 | // CALCULATE QUADRATIC EQUATION BY DISCRIMINANT // 90 | 91 | double a = \-2; 92 | double b = 5; 93 | double c = 5; 94 | 95 | double d = mathematics::quadratic::calculateDiscriminant(a, b, c); 96 | std::vector roots = mathematics::quadratic::calculateRootsByDiscriminant(d, a, b); 97 | 98 | std::cout << "Quadratic Equation: a=" << a << "; b=" << b << "; c=" << c << std::endl; 99 | std::cout << "D=" << d << std::endl; 100 | std::cout << "Roots:" << std::endl; 101 | 102 | for (double root : roots) { 103 | std::cout << root << std::endl; 104 | } 105 | 106 | std::cout << std::endl; 107 | 108 | // PERCENTAGE // 109 | 110 | double nump = mathematics::add_percent_to_number(100\&.0, 10\&.0); 111 | std::cout << "100+10%: " << nump << std::endl; 112 | 113 | std::cout << std::endl; 114 | 115 | // POWER / Algorithms for fast exponentiation // 116 | 117 | double bestPowVal = 100; 118 | double pow_results[5] = { 119 | mathematics::oldApproximatePower(10\&.0, 2\&.0), 120 | mathematics::anotherApproximatePower(10\&.0, 2\&.0), 121 | mathematics::binaryPower(10\&.0, 2), 122 | mathematics::fastPowerDividing(10\&.0, 2\&.0), 123 | mathematics::fastPowerFractional(10\&.0, 2\&.0) 124 | }; 125 | 126 | std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << std::endl; 127 | std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << std::endl; 128 | std::cout << "2 binaryPower : base 10 exponent 2: " << pow_results[2] << std::endl; 129 | std::cout << "3 fastPowerDividing : base 10 exponent 2: " << pow_results[3] << std::endl; 130 | std::cout << "4 fastPowerFractional : base 10 exponent 2: " << pow_results[4] << std::endl; 131 | 132 | for (int i = 0; i < sizeof(pow_results) / sizeof(pow_results[0]); i++) { 133 | double error = bestPowVal \- pow_results[i]; 134 | 135 | std::cout << "POW Algorithm #" << i << ": error=" << error << std::endl; 136 | } 137 | 138 | std::cout << std::endl; 139 | 140 | // Other // 141 | 142 | std::cout << "\-10 number module: " << mathematics::intabs(\-10) << std::endl; 143 | 144 | return 0; 145 | } 146 | 147 | .fi 148 | .PP 149 | 150 | .SH "Function Documentation" 151 | .PP 152 | .SS "double mathematics::add_percent_to_number (double number, double percentage)" 153 | 154 | .PP 155 | Adds a percent to number\&. 156 | .PP 157 | \fBParameters\fP 158 | .RS 4 159 | \fInumber\fP The number 160 | .br 161 | \fIpercentage\fP The percentage 162 | .RE 163 | .PP 164 | \fBReturns\fP 165 | .RS 4 166 | number 167 | .RE 168 | .PP 169 | 170 | .SS "double mathematics::anotherApproximatePower (double base, double exponent)" 171 | 172 | .PP 173 | Algorithm for fast exponentiation ''Another' approximation'\&. Speed increase: ~9 times\&. Accuracy: <1\&.5%\&. Limitations: accuracy drops rapidly as the absolute value of the degree increases and remains acceptable in the range [-10, 10] (see also 'old' approximation: \fBoldApproximatePower()\fP)\&. 174 | 175 | .PP 176 | \fBParameters\fP 177 | .RS 4 178 | \fIbase\fP The base 179 | .br 180 | \fIexponent\fP The exponent 181 | .RE 182 | .PP 183 | \fBReturns\fP 184 | .RS 4 185 | raised value 186 | .RE 187 | .PP 188 | 189 | .SS "double mathematics::binaryPower (double b, unsigned long long e)" 190 | 191 | .PP 192 | Algorithm: Binary exponentiation\&. Speed increase: ~7\&.5 times on average, the advantage remains until numbers are raised to a power of 134217728, Speed increase: ~7\&.5 times on average, the advantage remains until the numbers are raised to the power of 134217728\&. Error: none, but it is worth noting that the multiplication operation is not associative for floating point numbers, i\&.e\&. 1\&.21 * 1\&.21 is not the same as 1\&.1 * 1\&.1 * 1\&.1 * 1\&.1, however, when compared with standard functions, errors do not arise, as mentioned earlier\&. Restrictions: the degree must be an integer not less than 0 193 | 194 | .PP 195 | \fBParameters\fP 196 | .RS 4 197 | \fIbase\fP base 198 | .br 199 | \fIexponent\fP exponent 200 | .RE 201 | .PP 202 | \fBReturns\fP 203 | .RS 4 204 | raised value 205 | .RE 206 | .PP 207 | 208 | .SS "double mathematics::fastPowerDividing (double base, double exponent)" 209 | 210 | .PP 211 | Algorithm: 'Dividing fast power'\&. Speed increase: ~3\&.5 times\&. Accuracy: ~13%\&. The code below contains checks for special input data\&. Without them, the code runs only 10% faster, but the error increases tenfold (especially when using negative powers)\&. 212 | 213 | .PP 214 | \fBParameters\fP 215 | .RS 4 216 | \fIbase\fP The base 217 | .br 218 | \fIexponent\fP The exponent 219 | .RE 220 | .PP 221 | \fBReturns\fP 222 | .RS 4 223 | raised value 224 | .RE 225 | .PP 226 | 227 | .SS "double mathematics::fastPowerFractional (double base, double exponent)" 228 | 229 | .PP 230 | Algorithm: 'Fractional fast power'\&. Speed increase: ~4\&.4 times\&. Accuracy: ~0\&.7% 231 | 232 | .PP 233 | \fBParameters\fP 234 | .RS 4 235 | \fIbase\fP The base 236 | .br 237 | \fIexponent\fP The exponent 238 | .RE 239 | .PP 240 | \fBReturns\fP 241 | .RS 4 242 | raised value 243 | .RE 244 | .PP 245 | 246 | .SS "double mathematics::get_square_root (double num)" 247 | 248 | .PP 249 | Gets the square root\&. 250 | .PP 251 | \fBParameters\fP 252 | .RS 4 253 | \fInum\fP The number 254 | .RE 255 | .PP 256 | \fBReturns\fP 257 | .RS 4 258 | The square root\&. 259 | .RE 260 | .PP 261 | 262 | .SS "int mathematics::intabs (int x)" 263 | 264 | .PP 265 | Getting the modulus of a number without a comparison operation\&. 266 | .PP 267 | \fBParameters\fP 268 | .RS 4 269 | \fIx\fP number 270 | .RE 271 | .PP 272 | \fBReturns\fP 273 | .RS 4 274 | modulus of number 275 | .RE 276 | .PP 277 | 278 | .SS "double mathematics::oldApproximatePower (double base, double exponent)" 279 | 280 | .PP 281 | Algorithm for fast exponentiation ''Old' approximation'\&. If accuracy is not important to you and the degrees are in the range from -1 to 1, you can use this method (see also 'another' approximation: \fBanotherApproximatePower()\fP)\&. This method is based on the algorithm used in the 2005 game Quake III Arena\&. He raised the number x to the power -0\&.5, i\&.e\&. found the value: $\frac{1}{\sqrt{x}}$ 282 | 283 | .PP 284 | \fBParameters\fP 285 | .RS 4 286 | \fIbase\fP The base 287 | .br 288 | \fIexponent\fP The exponent 289 | .RE 290 | .PP 291 | \fBReturns\fP 292 | .RS 4 293 | raised value 294 | .RE 295 | .PP 296 | 297 | .SS "double mathematics::square_it_up (double num)" 298 | 299 | .PP 300 | Gets the number square (N^2)\&. 301 | .PP 302 | \fBParameters\fP 303 | .RS 4 304 | \fInum\fP The number 305 | .RE 306 | .PP 307 | \fBReturns\fP 308 | .RS 4 309 | The number square\&. 310 | .RE 311 | .PP 312 | 313 | .SH "Author" 314 | .PP 315 | Generated automatically by Doxygen for libnumerixpp from the source code\&. 316 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libnumerixpp 2 | 3 |

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

4 |
5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 |

13 | 14 | > [!CAUTION] 15 | > 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).< 16 | 17 | > Powerful, Modular, and Extensible C++ Library for Numerical Computations in Mathematics, Physics, and Computer Science 18 | 19 | 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. 20 | 21 | 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. 22 | 23 | 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. 24 | 25 | 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. 26 | 27 | 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. 28 | 29 | --- 30 | 31 | You can join to our [small russian telegram blog](https://t.me/hex_warehouse). 32 | 33 | > You can view docs for libnumerixpp [here](https://alexeev-prog.github.io/libnumerixpp). 34 | 35 | > Current version: 0.1.3 36 | 37 | ## Comparison to Alternatives 🤔 38 | To help you decide whether libnumerixpp is the right choice for your project, here's a comparison table with some popular numerical computation libraries: 39 | 40 | | Feature | libnumerixpp | Eigen | Boost.Numeric | LAPACK | 41 | | --- | --- | --- | --- | --- | 42 | | Multi-disciplinary Approach | ✅ | ❌ | ❌ | ❌ | 43 | | Equation Solving | ✅ | ❌ | ✅ | ❌ | 44 | | Statistical Functions | ❌ | ❌ | ✅ | ❌ | 45 | | Kinematics Calculations | ✅ | ❌ | ❌ | ❌ | 46 | | Number System Conversion | ✅ | ❌ | ❌ | ❌ | 47 | | Doxygen Documentation | ✅ | ✅ | ✅ | ❌ | 48 | | Unit Tests | ✅ | ✅ | ✅ | ✅ | 49 | | Cross-platform Support | ✅ | ✅ | ✅ | ✅ | 50 | 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. 51 | 52 | ## Key Features 🔑 53 | The libnumerixpp library boasts an impressive array of features that set it apart from its competitors: 54 | 55 | Mathematics: 56 | - 🧮 Robust equation solving (including linear, quadratic, and higher-order equations) 57 | - 📊 Comprehensive statistical and probability functions 58 | - 🔬 Powerful trigonometric, exponential, and logarithmic functions 59 | - Unparalleled accuracy and performance 🏆 compared to standard math libraries 60 | 61 | Physics: 62 | - 🔍 Detailed kinematics calculations (displacement, velocity, acceleration, and more) 63 | - Intuitive and user-friendly API 🤗 that simplifies complex physical computations 64 | - Seamless integration with the mathematics module 🔗 for interdisciplinary projects 65 | 66 | Computer Science: 67 | - 🔢 Efficient number system conversion (decimal, binary, hexadecimal, and more) 68 | - Versatile and extensible design 🧠 that allows for easy integration with other libraries and frameworks 69 | - Extensive documentation and examples 📖 to help users get started quickly 70 | 71 | Robust Infrastructure: 72 | - Doxygen-generated documentation 📚 for easy navigation and understanding 73 | - Catch2 unit tests ✅ for ensuring code quality and reliability 74 | - CMake build system 🛠️ for cross-platform compatibility and easy installation 75 | - clang-format code formatting 💅 for consistent and readable code 76 | 77 | ## Getting Started 🚀 78 | 79 | To get started with libnumerixpp, follow these simple steps: 80 | 81 | 1. Clone the repository: 82 | 83 | ```bash 84 | git clone https://github.com/libnumerixpp/libnumerixpp.git 85 | ``` 86 | 87 | 2. Build the library using the provided script: 88 | 89 | ```bash 90 | cd libnumerixpp 91 | ./build.sh 92 | ``` 93 | 94 | 3. Include the nessary modules in your code using [`#include`](https://github.com/alexeev-prog/libnumerixpp/tree/main/include) directives: 95 | 96 | ```cpp 97 | #include "libnumerixpp/core/common.hpp" // example 98 | ``` 99 | 100 | 4. Start using the library functions in your applications! You can view [examples of usage here](https://github.com/alexeev-prog/libnumerixpp/tree/main/examples). 101 | 102 | ## Examples 💻 103 | 104 |
105 | Mathematics 106 | 107 | ```cpp 108 | #include 109 | #include 110 | 111 | #include "libnumerixpp/core/common.hpp" 112 | #include "libnumerixpp/libnumerixpp.hpp" 113 | #include "libnumerixpp/mathematics/core.hpp" 114 | #include "libnumerixpp/mathematics/quadratic_equations.hpp" 115 | 116 | auto main() -> int { 117 | credits(); 118 | println("LIBNUMERIXPP"); 119 | 120 | // SQUARE AND SQR // 121 | 122 | double const num = 100.0; 123 | double const num_sq = mathematics::square_it_up(num); 124 | double const num_sqr = mathematics::get_square_root(num); 125 | std::cout << "Square " << num << ": " << num_sq << '\n'; 126 | std::cout << "Square root " << num << ": " << num_sqr << '\n'; 127 | 128 | std::cout << '\n'; 129 | 130 | // CALCULATE QUADRATIC EQUATION BY DISCRIMINANT // 131 | 132 | double const a = -2; 133 | double const b = 5; 134 | double const c = 5; 135 | 136 | double const d = mathematics::quadratic::calculate_discriminant(a, b, c); 137 | std::vector const roots = mathematics::quadratic::calculate_roots_by_discriminant(d, a, b); 138 | 139 | std::cout << "Quadratic Equation: a=" << a << "; b=" << b << "; c=" << c << '\n'; 140 | std::cout << "D=" << d << '\n'; 141 | std::cout << "Roots:" << '\n'; 142 | 143 | for (double const root : roots) { 144 | std::cout << root << '\n'; 145 | } 146 | 147 | std::cout << '\n'; 148 | 149 | // PERCENTAGE // 150 | 151 | double const nump = mathematics::add_percent_to_number(100.0, 10.0); 152 | std::cout << "100+10%: " << nump << '\n'; 153 | 154 | std::cout << '\n'; 155 | 156 | // POWER / Algorithms for fast exponentiation // 157 | 158 | double const best_pow_val = 100; 159 | double const pow_results[5] = { mathematics::old_approximate_power(10.0, 2.0), 160 | mathematics::another_approximate_power(10.0, 2.0), 161 | mathematics::binary_power(10.0, 2), 162 | mathematics::fast_power_dividing(10.0, 2.0), 163 | mathematics::fast_power_fractional(10.0, 2.0) }; 164 | 165 | std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << '\n'; 166 | std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << '\n'; 167 | std::cout << "2 binaryPower : base 10 exponent 2: " << pow_results[2] 168 | << '\n'; 169 | std::cout << "3 fastPowerDividing : base 10 exponent 2: " << pow_results[3] << '\n'; 170 | std::cout << "4 fastPowerFractional : base 10 exponent 2: " << pow_results[4] << '\n'; 171 | 172 | for (int i = 0; i < sizeof(pow_results) / sizeof(pow_results[0]); i++) { 173 | double const error = best_pow_val - pow_results[i]; 174 | 175 | std::cout << "POW Algorithm #" << i << ": error=" << error << '\n'; 176 | } 177 | 178 | std::cout << '\n'; 179 | 180 | // Other // 181 | 182 | std::cout << "-10 number module: " << mathematics::intabs(-10) << '\n'; 183 | 184 | return 0; 185 | } 186 | ``` 187 | 188 | ```cpp 189 | #include 190 | #include 191 | #include 192 | 193 | #include "libnumerixpp/core/common.hpp" 194 | #include "libnumerixpp/libnumerixpp.hpp" 195 | #include "libnumerixpp/mathematics/equations.hpp" 196 | 197 | void test_eq_sa(double (*f_eq)(double), double x0, const std::string &eq) { 198 | int const iterations = 100; 199 | 200 | double z = NAN; 201 | 202 | std::cout << "Equation solution " << eq << ":\t"; 203 | 204 | z = mathematics::equations::successive_approximations_finding_root(f_eq, x0, iterations); 205 | 206 | std::cout << z << '\n'; 207 | 208 | std::cout << "Check finding solution:\t"; 209 | 210 | std::cout << z << " = " << f_eq(z) << '\n'; 211 | 212 | for (int i = 0; i <= 50; i++) { 213 | std::cout << "-"; 214 | } 215 | 216 | std::cout << '\n'; 217 | } 218 | 219 | auto main() -> int { 220 | credits(); 221 | println("LIBNUMERIXPP"); 222 | 223 | test_eq_sa(mathematics::equations::f_eq, 0, "x=0.5cos(x)"); 224 | test_eq_sa(mathematics::equations::g_eq, 0, "x=exp(-x)"); 225 | test_eq_sa(mathematics::equations::h_eq, 1, "x=(x*x+6)/5"); 226 | 227 | return 0; 228 | } 229 | ``` 230 | 231 |
232 | 233 |
234 | Physics 235 | 236 | ```cpp 237 | 238 | #include 239 | 240 | #include "libnumerixpp/core/common.hpp" 241 | #include "libnumerixpp/libnumerixpp.hpp" 242 | #include "libnumerixpp/physics/kinematics.hpp" 243 | 244 | auto main() -> int { 245 | credits(); 246 | println("LIBNUMERIXPP"); 247 | 248 | double speed = 10.0; 249 | double time = 5.0; 250 | 251 | double const path = physics::kinematics::calculate_path(speed, time); 252 | speed = physics::kinematics::calculate_speed(path, time); 253 | time = physics::kinematics::calculate_time(path, speed); 254 | 255 | std::cout << "Calculate: speed=" << speed << "m/s" << "; time=" << time << "s" 256 | << "; path=" << path << "m" << '\n'; 257 | 258 | double const final_velocity = physics::kinematics::calculate_final_velocity(10.0, 10.0, 10.0); 259 | std::cout << "final velocity (10.0, 10.0, 10.0) = " << final_velocity << '\n'; 260 | 261 | double const final_position = 262 | physics::kinematics::calculate_final_position(10.0, 10.0, 10.0, 10.0); 263 | std::cout << "final position (10.0, 10.0, 10.0, 10.0) = " << final_velocity << '\n'; 264 | 265 | return 0; 266 | } 267 | ``` 268 | 269 |
270 | 271 |
272 | Computer Science 273 | 274 | ```cpp 275 | #include 276 | #include 277 | 278 | #include "libnumerixpp/computerscience/core.hpp" 279 | #include "libnumerixpp/core/common.hpp" 280 | #include "libnumerixpp/libnumerixpp.hpp" 281 | 282 | auto main() -> int { 283 | credits(); 284 | println("LIBNUMERIXPP"); 285 | 286 | int const decimal_number = 777; 287 | std::string binary_number = computerscience::convert_decimal_to_binary(decimal_number); 288 | int const decimal_number2 = computerscience::convert_binary_to_decimal(binary_number); 289 | std::string hexadecimal_number = 290 | computerscience::convert_decimal_to_hexadecimal(decimal_number); 291 | int const decimal_number3 = computerscience::convert_hexadecimal_to_decimal(hexadecimal_number); 292 | std::string const hexadecimal_number2 = 293 | computerscience::convert_binary_to_hexadecimal(binary_number); 294 | std::string const binary_number2 = 295 | computerscience::convert_hexadecimal_to_binary(hexadecimal_number); 296 | long long const bytes = 1024 * 1024; 297 | 298 | std::cout << "Convert decimal " << decimal_number << " to binary: " << binary_number << '\n'; 299 | std::cout << "Convert binary " << binary_number << " to decimal: " << decimal_number2 << '\n'; 300 | std::cout << "Convert decimal " << decimal_number << " to hexadecimal: " << hexadecimal_number 301 | << '\n'; 302 | std::cout << "Convert hexadecimal " << hexadecimal_number << " to decimal: " << decimal_number3 303 | << '\n'; 304 | std::cout << "Convert binary " << binary_number << " to hexadecimal: " << hexadecimal_number2 305 | << '\n'; 306 | std::cout << "Convert hexadecimal " << hexadecimal_number << " to binary: " << binary_number2 307 | << '\n'; 308 | std::cout << "Convert " << bytes << ": " << computerscience::humanize_bytes_size(bytes) << '\n'; 309 | 310 | return 0; 311 | } 312 | ``` 313 | 314 |
315 | 316 | ## Architecture 317 | libnumerixpp has a modular architecture consisting of the following core components: 318 | 319 | - core: Provides essential data types, error handling functions, and utility tools. 320 | - mathematics: Implements algorithms for linear algebra, calculus, and geometry. 321 | - physics: Offers functions for solving problems in the areas of kinematics, mechanics, thermodynamics and electronics. 322 | - computerscience: Offers functions for converting data and other CS utils 323 | 324 | 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. 325 | 326 | ``` 327 | . 328 | ├── build.sh 329 | ├── CHANGELOG.md 330 | ├── cmake 331 | │ ├── coverage.cmake 332 | │ ├── dev-mode.cmake 333 | │ ├── docs-ci.cmake 334 | │ ├── docs.cmake 335 | │ ├── folders.cmake 336 | │ ├── install-config.cmake 337 | │ ├── install-rules.cmake 338 | │ ├── lint.cmake 339 | │ ├── lint-targets.cmake 340 | │ ├── prelude.cmake 341 | │ ├── project-is-top-level.cmake 342 | │ ├── spell.cmake 343 | │ ├── spell-targets.cmake 344 | │ └── variables.cmake 345 | ├── CMakeLists.txt 346 | ├── CMakePresets.json 347 | ├── CMakeUserPresets.json 348 | ├── conanfile.py 349 | ├── docs 350 | │ ├── doxygen-styles.css 351 | │ ├── en 352 | │ │ └── index.md 353 | │ ├── man 354 | │ │ └── man3 355 | │ │ ├── common.cpp.3 356 | │ │ ├── computerscience.3 357 | │ │ ├── core.cpp.3 358 | │ │ ├── core.hpp.3 359 | │ │ ├── equations.cpp.3 360 | │ │ ├── equations.hpp.3 361 | │ │ ├── kinematics.cpp.3 362 | │ │ ├── kinematics.hpp.3 363 | │ │ ├── libnumerixpp.cpp.3 364 | │ │ ├── mathematics.3 365 | │ │ ├── mathematics_quadratic.3 366 | │ │ ├── mathematics_statistics.3 367 | │ │ ├── physics.3 368 | │ │ ├── physics_kinematics.3 369 | │ │ ├── quadratic_equations.cpp.3 370 | │ │ ├── quadratic_equations.hpp.3 371 | │ │ ├── statistics.cpp.3 372 | │ │ ├── statistics.hpp.3 373 | │ │ └── todo.3 374 | │ ├── README.md 375 | │ └── ru 376 | │ ├── article2.md 377 | │ ├── article.md 378 | │ └── index.md 379 | ├── Doxyfile 380 | ├── Doxygen.cmake 381 | ├── examples 382 | │ ├── example-1.cpp 383 | │ ├── example-2.cpp 384 | │ ├── example-3.cpp 385 | │ └── example-4.cpp 386 | ├── format-code.py 387 | ├── include 388 | │ └── libnumerixpp 389 | │ ├── computerscience 390 | │ │ └── core.hpp 391 | │ ├── core 392 | │ │ └── common.hpp 393 | │ ├── export.h 394 | │ ├── libnumerixpp.hpp 395 | │ ├── mathematics 396 | │ │ ├── core.hpp 397 | │ │ ├── equations.hpp 398 | │ │ ├── quadratic_equations.hpp 399 | │ │ └── statistics.hpp 400 | │ └── physics 401 | │ ├── core.hpp 402 | │ └── kinematics.hpp 403 | ├── LICENSE 404 | ├── README.md 405 | ├── spacetabs.sh 406 | ├── src 407 | │ ├── computerscience 408 | │ │ └── core.cpp 409 | │ ├── core 410 | │ │ └── common.cpp 411 | │ ├── libnumerixpp.cpp 412 | │ ├── mathematics 413 | │ │ ├── core.cpp 414 | │ │ ├── equations.cpp 415 | │ │ ├── quadratic_equations.cpp 416 | │ │ └── statistics.cpp 417 | │ └── physics 418 | │ ├── core.cpp 419 | │ └── kinematics.cpp 420 | └── test 421 | ├── CMakeLists.txt 422 | └── source 423 | └── libnumerixpp_test.cpp 424 | ``` 425 | 426 | ## Tools and Dependencies 427 | linumerixpp utilizes the following tools and libraries: 428 | 429 | - **CMake**: Cross-platform build system 430 | - **Doxygen**: Documentation generation 431 | 432 | ## Documentation 📚 433 | Detailed documentation, including user guides, API reference, and code examples, is available in the [docs](https://alexeev-prog.github.io/libnumerixpp/). Or you can see articles or additional info in [en docs dir](https://github.com/alexeev-prog/libnumerixpp/blob/main/docs/en/index.md) or [ru docs dir](https://github.com/alexeev-prog/libnumerixpp/blob/main/docs/ru/index.md). 434 | 435 | If you have any questions, suggestions, or encounter issues, please create a new [issue](https://github.com/alexeev-prog/libnumerixpp/issues/new) in the repository. We'll be happy to assist you and improve the library. 436 | 437 | You can also write to me on Telegram: [@alexeev_dev](https://t.me/alexeev_dev) 438 | 439 | libnumerixpp is an Open Source project, and it only survives due to your feedback and support! 440 | 441 | Project releases are available at [this link](https://github.com/alexeev-prog/libnumerixpp/releases). 442 | 443 | ## Requirements 📋 444 | To use libnumerixpp, you will need the following: 445 | 446 | - A C++17 compatible compiler (e.g., GCC 8+, Clang 8+, or MSVC 2019+) 447 | - CMake 3.14 or newer 448 | - Catch2 testing framework (included as a submodule) 449 | 450 | ## Our Projects 🔧 451 | Check other our projects: 452 | 453 | + [Shegang - functional shell in C for linux](https://github.com/alexeev-prog/shegang). 454 | + [Hex64 - software for benchmarking](https://github.com/alexeev-prog/hex64) 455 | + [Pentest 154 - software for simple OSINT and search info about target](https://github.com/alexeev-prog/pentest154) 456 | 457 | ## Contributing 🤝 458 | 459 | We welcome contributions from the community! If you would like to contribute to the libnumerixpp project, please read our [contribution guidelines](CONTRIBUTING.md) and submit a pull request. 460 | 461 | ## Get Help 🆘 462 | If you encounter any issues or have questions about using libnumerixpp, you can: 463 | 464 | - 🐞 Open an issue on the [GitHub repository](https://github.com/alexeev-prog/libnumerixpp/issues) 465 | - 📧 Contact the project maintainers at dev.alexeev@main.ru 466 | 467 | ## Future Plans 🔮 468 | 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: 469 | 470 | - 🧠 Implementing more advanced mathematical and physical computations, such as differential equations, linear algebra, and fluid dynamics 471 | - ⚡ Adding support for parallel processing and GPU acceleration to boost performance on large-scale computations 472 | - 🎨 Integrating with popular data visualization and scientific computing frameworks, making it easier to use libnumerixpp in complex project workflows 473 | 474 | Stay tuned for more updates! 🚀 475 | 476 | ## Testing 🧪 477 | 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. 478 | 479 | To run the tests, you can execute the following command from the project's root directory: 480 | 481 | ```bash 482 | ./build/test/libnumerixpp_test 483 | ``` 484 | 485 | This will run all the available tests and report the results. 486 | 487 | ## Copyright 📄 488 | libnumerixpp is released under the [Apache License 2.0](https://github.com/alexeev-prog/libnumerixpp/blob/main/LICENSE). 489 | 490 | Copyright © 2024 Alexeev Bronislav. All rights reversed. 491 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | @mainpage 2 | # libnumerixpp 3 | 4 |

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

5 |
6 |

7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 | > [!CAUTION] 16 | > 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).< 17 | 18 | > Powerful, Modular, and Extensible C++ Library for Numerical Computations in Mathematics, Physics, and Computer Science 19 | 20 | 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. 21 | 22 | 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. 23 | 24 | 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. 25 | 26 | 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. 27 | 28 | 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. 29 | 30 | --- 31 | 32 | You can join to our [small russian telegram blog](https://t.me/hex_warehouse). 33 | 34 | > You can view docs for libnumerixpp [here](https://alexeev-prog.github.io/libnumerixpp). 35 | 36 | > Current version: 0.1.2 37 | 38 | ## Key Features 🔑 39 | The libnumerixpp library boasts an impressive array of features that set it apart from its competitors: 40 | 41 | Mathematics: 42 | - 🧮 Robust equation solving (including linear, quadratic, and higher-order equations) 43 | - 📊 Comprehensive statistical and probability functions 44 | - 🔬 Powerful trigonometric, exponential, and logarithmic functions 45 | - Unparalleled accuracy and performance 🏆 compared to standard math libraries 46 | 47 | Physics: 48 | - 🔍 Detailed kinematics calculations (displacement, velocity, acceleration, and more) 49 | - Intuitive and user-friendly API 🤗 that simplifies complex physical computations 50 | - Seamless integration with the mathematics module 🔗 for interdisciplinary projects 51 | 52 | Computer Science: 53 | - 🔢 Efficient number system conversion (decimal, binary, hexadecimal, and more) 54 | - Versatile and extensible design 🧠 that allows for easy integration with other libraries and frameworks 55 | - Extensive documentation and examples 📖 to help users get started quickly 56 | 57 | Robust Infrastructure: 58 | - Doxygen-generated documentation 📚 for easy navigation and understanding 59 | - Catch2 unit tests ✅ for ensuring code quality and reliability 60 | - CMake build system 🛠️ for cross-platform compatibility and easy installation 61 | - clang-format code formatting 💅 for consistent and readable code 62 | 63 | ## Comparison to Alternatives 🤔 64 | To help you decide whether libnumerixpp is the right choice for your project, here's a comparison table with some popular numerical computation libraries: 65 | 66 | | Feature | libnumerixpp | Eigen | Boost.Numeric | LAPACK | 67 | | --- | --- | --- | --- | --- | 68 | | Multi-disciplinary Approach | ✅ | ❌ | ❌ | ❌ | 69 | | Equation Solving | ✅ | ❌ | ✅ | ❌ | 70 | | Statistical Functions | ❌ | ❌ | ✅ | ❌ | 71 | | Kinematics Calculations | ✅ | ❌ | ❌ | ❌ | 72 | | Number System Conversion | ✅ | ❌ | ❌ | ❌ | 73 | | Doxygen Documentation | ✅ | ✅ | ✅ | ❌ | 74 | | Unit Tests | ✅ | ✅ | ✅ | ✅ | 75 | | Cross-platform Support | ✅ | ✅ | ✅ | ✅ | 76 | 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. 77 | 78 | ## Getting Started 🚀 79 | 80 | To get started with libnumerixpp, follow these simple steps: 81 | 82 | 1. Clone the repository: 83 | 84 | ```bash 85 | git clone https://github.com/libnumerixpp/libnumerixpp.git 86 | ``` 87 | 88 | 2. Build the library using the provided script: 89 | 90 | ```bash 91 | cd libnumerixpp 92 | ./build.sh 93 | ``` 94 | 95 | 3. Include the nessary modules in your code using [`#include`](https://github.com/alexeev-prog/libnumerixpp/tree/main/include) directives: 96 | 97 | ```cpp 98 | #include "libnumerixpp/core/common.hpp" // example 99 | ``` 100 | 101 | 4. Start using the library functions in your applications! You can view [examples of usage here](https://github.com/alexeev-prog/libnumerixpp/tree/main/examples). 102 | 103 | ## Examples 💻 104 | 105 |
106 | Mathematics 107 | 108 | ```cpp 109 | #include 110 | #include 111 | 112 | #include "libnumerixpp/core/common.hpp" 113 | #include "libnumerixpp/libnumerixpp.hpp" 114 | #include "libnumerixpp/mathematics/core.hpp" 115 | #include "libnumerixpp/mathematics/quadratic_equations.hpp" 116 | 117 | auto main() -> int { 118 | credits(); 119 | println("LIBNUMERIXPP"); 120 | 121 | // SQUARE AND SQR // 122 | 123 | double const num = 100.0; 124 | double const num_sq = mathematics::square_it_up(num); 125 | double const num_sqr = mathematics::get_square_root(num); 126 | std::cout << "Square " << num << ": " << num_sq << '\n'; 127 | std::cout << "Square root " << num << ": " << num_sqr << '\n'; 128 | 129 | std::cout << '\n'; 130 | 131 | // CALCULATE QUADRATIC EQUATION BY DISCRIMINANT // 132 | 133 | double const a = -2; 134 | double const b = 5; 135 | double const c = 5; 136 | 137 | double const d = mathematics::quadratic::calculateDiscriminant(a, b, c); 138 | std::vector const roots = mathematics::quadratic::calculateRootsByDiscriminant(d, a, b); 139 | 140 | std::cout << "Quadratic Equation: a=" << a << "; b=" << b << "; c=" << c << '\n'; 141 | std::cout << "D=" << d << '\n'; 142 | std::cout << "Roots:" << '\n'; 143 | 144 | for (double const root : roots) { 145 | std::cout << root << '\n'; 146 | } 147 | 148 | std::cout << '\n'; 149 | 150 | // PERCENTAGE // 151 | 152 | double const nump = mathematics::add_percent_to_number(100.0, 10.0); 153 | std::cout << "100+10%: " << nump << '\n'; 154 | 155 | std::cout << '\n'; 156 | 157 | // POWER / Algorithms for fast exponentiation // 158 | 159 | double const best_pow_val = 100; 160 | double const pow_results[5] = { mathematics::oldApproximatePower(10.0, 2.0), 161 | mathematics::anotherApproximatePower(10.0, 2.0), 162 | mathematics::binaryPower(10.0, 2), 163 | mathematics::fastPowerDividing(10.0, 2.0), 164 | mathematics::fastPowerFractional(10.0, 2.0) }; 165 | 166 | std::cout << "0 oldApproximatePower : base 10 exponent 2: " << pow_results[0] << '\n'; 167 | std::cout << "1 anotherApproximatePower: base 10 exponent 2: " << pow_results[1] << '\n'; 168 | std::cout << "2 binaryPower : base 10 exponent 2: " << pow_results[2] 169 | << '\n'; 170 | std::cout << "3 fastPowerDividing : base 10 exponent 2: " << pow_results[3] << '\n'; 171 | std::cout << "4 fastPowerFractional : base 10 exponent 2: " << pow_results[4] << '\n'; 172 | 173 | for (int i = 0; i < sizeof(pow_results) / sizeof(pow_results[0]); i++) { 174 | double const error = best_pow_val - pow_results[i]; 175 | 176 | std::cout << "POW Algorithm #" << i << ": error=" << error << '\n'; 177 | } 178 | 179 | std::cout << '\n'; 180 | 181 | // Other // 182 | 183 | std::cout << "-10 number module: " << mathematics::intabs(-10) << '\n'; 184 | 185 | return 0; 186 | } 187 | ``` 188 | 189 | ```cpp 190 | #include 191 | #include 192 | #include 193 | 194 | #include "libnumerixpp/core/common.hpp" 195 | #include "libnumerixpp/libnumerixpp.hpp" 196 | #include "libnumerixpp/mathematics/equations.hpp" 197 | 198 | void test_eq_sa(double (*f_eq)(double), double x0, const std::string &eq) { 199 | int const iterations = 100; 200 | 201 | double z = NAN; 202 | 203 | std::cout << "Equation solution " << eq << ":\t"; 204 | 205 | z = mathematics::equations::successiveApproximationsFindingRoot(f_eq, x0, iterations); 206 | 207 | std::cout << z << '\n'; 208 | 209 | std::cout << "Check finding solution:\t"; 210 | 211 | std::cout << z << " = " << f_eq(z) << '\n'; 212 | 213 | for (int i = 0; i <= 50; i++) { 214 | std::cout << "-"; 215 | } 216 | 217 | std::cout << '\n'; 218 | } 219 | 220 | auto main() -> int { 221 | credits(); 222 | println("LIBNUMERIXPP"); 223 | 224 | test_eq_sa(mathematics::equations::f_eq, 0, "x=0.5cos(x)"); 225 | test_eq_sa(mathematics::equations::g_eq, 0, "x=exp(-x)"); 226 | test_eq_sa(mathematics::equations::h_eq, 1, "x=(x*x+6)/5"); 227 | 228 | return 0; 229 | } 230 | ``` 231 | 232 |
233 | 234 |
235 | Physics 236 | 237 | ```cpp 238 | #include 239 | 240 | #include "libnumerixpp/core/common.hpp" 241 | #include "libnumerixpp/libnumerixpp.hpp" 242 | #include "libnumerixpp/physics/kinematics.hpp" 243 | 244 | auto main() -> int { 245 | credits(); 246 | println("LIBNUMERIXPP"); 247 | 248 | double speed = 10.0; 249 | double time = 5.0; 250 | 251 | double const path = physics::kinematics::calculate_path(speed, time); 252 | speed = physics::kinematics::calculate_speed(path, time); 253 | time = physics::kinematics::calculate_time(path, speed); 254 | 255 | std::cout << "Calculate: speed=" << speed << "m/s" << "; time=" << time << "s" 256 | << "; path=" << path << "m" << '\n'; 257 | 258 | double const final_velocity = physics::kinematics::calculate_final_velocity(10.0, 10.0, 10.0); 259 | std::cout << "final velocity (10.0, 10.0, 10.0) = " << final_velocity << '\n'; 260 | 261 | double const final_position = 262 | physics::kinematics::calculate_final_position(10.0, 10.0, 10.0, 10.0); 263 | std::cout << "final position (10.0, 10.0, 10.0, 10.0) = " << final_velocity << '\n'; 264 | 265 | return 0; 266 | } 267 | ``` 268 | 269 |
270 | 271 |
272 | Computer Science 273 | 274 | ```cpp 275 | #include 276 | #include 277 | 278 | #include "libnumerixpp/computerscience/core.hpp" 279 | #include "libnumerixpp/core/common.hpp" 280 | #include "libnumerixpp/libnumerixpp.hpp" 281 | 282 | auto main() -> int { 283 | credits(); 284 | println("LIBNUMERIXPP"); 285 | 286 | int const decimal_number = 777; 287 | std::string binary_number = computerscience::convertDecimalToBinary(decimal_number); 288 | int const decimal_number2 = computerscience::convertBinaryToDecimal(binary_number); 289 | std::string hexadecimal_number = computerscience::convertDecimalToHexadecimal(decimal_number); 290 | int const decimal_number3 = computerscience::convertHexadecimalToDecimal(hexadecimal_number); 291 | std::string const hexadecimal_number2 = 292 | computerscience::convertBinaryToHexadecimal(binary_number); 293 | std::string const binary_number2 = 294 | computerscience::convertHexadecimalToBinary(hexadecimal_number); 295 | long long const bytes = 1024 * 1024; 296 | 297 | std::cout << "Convert decimal " << decimal_number << " to binary: " << binary_number << '\n'; 298 | std::cout << "Convert binary " << binary_number << " to decimal: " << decimal_number2 << '\n'; 299 | std::cout << "Convert decimal " << decimal_number << " to hexadecimal: " << hexadecimal_number 300 | << '\n'; 301 | std::cout << "Convert hexadecimal " << hexadecimal_number << " to decimal: " << decimal_number3 302 | << '\n'; 303 | std::cout << "Convert binary " << binary_number << " to hexadecimal: " << hexadecimal_number2 304 | << '\n'; 305 | std::cout << "Convert hexadecimal " << hexadecimal_number << " to binary: " << binary_number2 306 | << '\n'; 307 | std::cout << "Convert " << bytes << ": " << computerscience::humanizeBytesSize(bytes) << '\n'; 308 | 309 | return 0; 310 | } 311 | ``` 312 | 313 |
314 | 315 | ## Architecture 316 | libnumerixpp has a modular architecture consisting of the following core components: 317 | 318 | - core: Provides essential data types, error handling functions, and utility tools. 319 | - mathematics: Implements algorithms for linear algebra, calculus, and geometry. 320 | - physics: Offers functions for solving problems in the areas of kinematics, mechanics, thermodynamics and electronics. 321 | - computerscience: Offers functions for converting data and other CS utils 322 | 323 | 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. 324 | 325 | ``` 326 | . 327 | ├── build.sh 328 | ├── CHANGELOG.md 329 | ├── cmake 330 | │ ├── coverage.cmake 331 | │ ├── dev-mode.cmake 332 | │ ├── docs-ci.cmake 333 | │ ├── docs.cmake 334 | │ ├── folders.cmake 335 | │ ├── install-config.cmake 336 | │ ├── install-rules.cmake 337 | │ ├── lint.cmake 338 | │ ├── lint-targets.cmake 339 | │ ├── prelude.cmake 340 | │ ├── project-is-top-level.cmake 341 | │ ├── spell.cmake 342 | │ ├── spell-targets.cmake 343 | │ └── variables.cmake 344 | ├── CMakeLists.txt 345 | ├── CMakePresets.json 346 | ├── CMakeUserPresets.json 347 | ├── conanfile.py 348 | ├── docs 349 | │ ├── doxygen-styles.css 350 | │ ├── en 351 | │ │ └── index.md 352 | │ ├── man 353 | │ │ └── man3 354 | │ │ ├── common.cpp.3 355 | │ │ ├── computerscience.3 356 | │ │ ├── core.cpp.3 357 | │ │ ├── core.hpp.3 358 | │ │ ├── equations.cpp.3 359 | │ │ ├── equations.hpp.3 360 | │ │ ├── kinematics.cpp.3 361 | │ │ ├── kinematics.hpp.3 362 | │ │ ├── libnumerixpp.cpp.3 363 | │ │ ├── mathematics.3 364 | │ │ ├── mathematics_quadratic.3 365 | │ │ ├── mathematics_statistics.3 366 | │ │ ├── physics.3 367 | │ │ ├── physics_kinematics.3 368 | │ │ ├── quadratic_equations.cpp.3 369 | │ │ ├── quadratic_equations.hpp.3 370 | │ │ ├── statistics.cpp.3 371 | │ │ ├── statistics.hpp.3 372 | │ │ └── todo.3 373 | │ ├── README.md 374 | │ └── ru 375 | │ ├── article2.md 376 | │ ├── article.md 377 | │ └── index.md 378 | ├── Doxyfile 379 | ├── Doxygen.cmake 380 | ├── examples 381 | │ ├── example-1.cpp 382 | │ ├── example-2.cpp 383 | │ ├── example-3.cpp 384 | │ └── example-4.cpp 385 | ├── format-code.py 386 | ├── include 387 | │ └── libnumerixpp 388 | │ ├── computerscience 389 | │ │ └── core.hpp 390 | │ ├── core 391 | │ │ └── common.hpp 392 | │ ├── export.h 393 | │ ├── libnumerixpp.hpp 394 | │ ├── mathematics 395 | │ │ ├── core.hpp 396 | │ │ ├── equations.hpp 397 | │ │ ├── quadratic_equations.hpp 398 | │ │ └── statistics.hpp 399 | │ └── physics 400 | │ ├── core.hpp 401 | │ └── kinematics.hpp 402 | ├── LICENSE 403 | ├── README.md 404 | ├── spacetabs.sh 405 | ├── src 406 | │ ├── computerscience 407 | │ │ └── core.cpp 408 | │ ├── core 409 | │ │ └── common.cpp 410 | │ ├── libnumerixpp.cpp 411 | │ ├── mathematics 412 | │ │ ├── core.cpp 413 | │ │ ├── equations.cpp 414 | │ │ ├── quadratic_equations.cpp 415 | │ │ └── statistics.cpp 416 | │ └── physics 417 | │ ├── core.cpp 418 | │ └── kinematics.cpp 419 | └── test 420 | ├── CMakeLists.txt 421 | └── source 422 | └── libnumerixpp_test.cpp 423 | ``` 424 | 425 | ## Tools and Dependencies 426 | linumerixpp utilizes the following tools and libraries: 427 | 428 | - **CMake**: Cross-platform build system 429 | - **Doxygen**: Documentation generation 430 | 431 | ## Documentation 📚 432 | Detailed documentation, including user guides, API reference, and code examples, is available in the [docs](https://alexeev-prog.github.io/libnumerixpp/). Or you can see articles or additional info in [en docs dir](https://github.com/alexeev-prog/libnumerixpp/blob/main/docs/en/index.md) or [ru docs dir](https://github.com/alexeev-prog/libnumerixpp/blob/main/docs/ru/index.md). 433 | 434 | If you have any questions, suggestions, or encounter issues, please create a new [issue](https://github.com/alexeev-prog/libnumerixpp/issues/new) in the repository. We'll be happy to assist you and improve the library. 435 | 436 | You can also write to me on Telegram: [@alexeev_dev](https://t.me/alexeev_dev) 437 | 438 | libnumerixpp is an Open Source project, and it only survives due to your feedback and support! 439 | 440 | Project releases are available at [this link](https://github.com/alexeev-prog/libnumerixpp/releases). 441 | 442 | ## Requirements 📋 443 | 444 | To use libnumerixpp, you will need the following: 445 | 446 | - A C++17 compatible compiler (e.g., GCC 8+, Clang 8+, or MSVC 2019+) 447 | - CMake 3.14 or newer 448 | - Catch2 testing framework (included as a submodule) 449 | 450 | ## Our Projects 🔧 451 | Check other our projects: 452 | 453 | + [Shegang - functional shell in C for linux](https://github.com/alexeev-prog/shegang). 454 | + [Hex64 - software for benchmarking](https://github.com/alexeev-prog/hex64) 455 | + [Pentest 154 - software for simple OSINT and search info about target](https://github.com/alexeev-prog/pentest154) 456 | 457 | ## Contributing 🤝 458 | 459 | We welcome contributions from the community! If you would like to contribute to the libnumerixpp project, please read our [contribution guidelines](CONTRIBUTING.md) and submit a pull request. 460 | 461 | ## Get Help 🆘 462 | 463 | If you encounter any issues or have questions about using libnumerixpp, you can: 464 | 465 | - 🐞 Open an issue on the [GitHub repository](https://github.com/alexeev-prog/libnumerixpp/issues) 466 | - 📧 Contact the project maintainers at dev.alexeev@main.ru 467 | 468 | ## Future Plans 🔮 469 | 470 | 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: 471 | 472 | - 🧠 Implementing more advanced mathematical and physical computations, such as differential equations, linear algebra, and fluid dynamics 473 | - ⚡ Adding support for parallel processing and GPU acceleration to boost performance on large-scale computations 474 | - 🎨 Integrating with popular data visualization and scientific computing frameworks, making it easier to use libnumerixpp in complex project workflows 475 | 476 | Stay tuned for more updates! 🚀 477 | 478 | ## Testing 🧪 479 | 480 | 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. 481 | 482 | To run the tests, you can execute the following command from the project's root directory: 483 | 484 | ```bash 485 | ./build/test/libnumerixpp_test 486 | ``` 487 | 488 | This will run all the available tests and report the results. 489 | 490 | ## Copyright 📄 491 | libnumerixpp is released under the [Apache License 2.0](https://github.com/alexeev-prog/libnumerixpp/blob/main/LICENSE). 492 | 493 | Copyright © 2024 Alexeev Bronislav. All rights reversed. 494 | --------------------------------------------------------------------------------