Skip to content

Commit

Permalink
Merge branch 'master' into leastsquares
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiaisgro authored Nov 28, 2023
2 parents 35b944a + b61d3dd commit 0136a49
Show file tree
Hide file tree
Showing 384 changed files with 13,628 additions and 8,738 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ name: Test on Linux

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]


jobs:
build:

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Test on MacOS

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ name: "Test on Windows"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '26 10 * * 3'

Expand Down
42 changes: 27 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
default_target: all
.PHONY: all example test_core test_algebra test_polynomial test_optimization test_autodiff test_calculus automatic_differentiation hamiltonian \
error_propagation statistics sampling_distributions multivariate_minimization benchmark \
clean attractor montecarlo_comparison histogram
.PHONY: all example test_core test_algebra test_polynomial test_optimization test_autodiff \
test_calculus test_statistics autodiff hamiltonian error_propagation \
statistics sampling gradient_descent benchmark \
clean attractor montecarlo_integral histogram random_walk

all: examples test

Expand Down Expand Up @@ -63,14 +64,21 @@ ifndef windows_build
@./test/test_pseudorandom
endif

test: test_core test_algebra test_autodiff test_calculus test_polynomial test_optimization test_pseudorandom
test_statistics:
ifndef windows_build
@echo Compiling statistics test cases...
@g++ test/test_statistics.cpp ${CXXFLAGS} -I./test/ -o test/test_statistics
@./test/test_statistics
endif

test: test_core test_algebra test_autodiff test_calculus test_polynomial test_optimization test_pseudorandom test_statistics


# Example programs

automatic_differentiation:
autodiff:
@echo Compiling \"Automatic differentiation\" example...
@g++ examples/automatic_differentiation.cpp ${CXXFLAGS} -o ./examples/automatic_differentiation
@g++ examples/autodiff.cpp ${CXXFLAGS} -o ./examples/autodiff

hamiltonian:
@echo Compiling \"Hamiltonian\" example...
Expand All @@ -84,17 +92,17 @@ statistics:
@echo Compiling \"Statistics\" example...
@g++ examples/statistics.cpp ${CXXFLAGS} -o ./examples/statistics

sampling_distributions:
sampling:
@echo Compiling \"Sampling distributions\" example...
@g++ examples/sampling_distributions.cpp ${CXXFLAGS} -o ./examples/sampling_distributions
@g++ examples/sampling.cpp ${CXXFLAGS} -o ./examples/sampling

montecarlo_comparison:
montecarlo_integral:
@echo Compiling \"Montecarlo comparison\" example...
@g++ examples/montecarlo_comparison.cpp ${CXXFLAGS} -o ./examples/montecarlo_comparison
@g++ examples/montecarlo_integral.cpp ${CXXFLAGS} -o ./examples/montecarlo_integral

multivariate_minimization:
gradient_descent:
@echo Compiling \"Multivariate minimization\" example...
@g++ examples/multivariate_minimization.cpp ${CXXFLAGS} -o ./examples/multivariate_minimization
@g++ examples/gradient_descent.cpp ${CXXFLAGS} -o ./examples/gradient_descent

logfit:
@echo Compiling \"Log fit\" example...
Expand All @@ -108,9 +116,13 @@ histogram:
@echo Compiling \"Histogram\" example...
@g++ examples/histogram.cpp ${CXXFLAGS} -o ./examples/histogram

examples: example automatic_differentiation hamiltonian error_propagation \
statistics sampling_distributions montecarlo_comparison multivariate_minimization \
logfit attractor histogram
random_walk:
@echo Compiling \"Random walk\" example...
@g++ examples/random_walk.cpp ${CXXFLAGS} -o ./examples/random_walk

examples: example autodiff hamiltonian error_propagation \
statistics sampling montecarlo_integral gradient_descent \
logfit attractor histogram random_walk


# Benchmarks
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Home -->
<!-- ======== -->

![GitHub last commit](https://img.shields.io/github/last-commit/chaotic-society/theoretica) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/chaotic-society/theoretica/test-windows.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/0f4ae5dc6e1140ad855a3d6325d44b35)](https://www.codacy.com/gh/chaotic-society/theoretica/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=chaotic-society/theoretica&amp;utm_campaign=Badge_Grade) ![License](https://img.shields.io/github/license/chaotic-society/theoretica)
![GitHub last commit](https://img.shields.io/github/last-commit/chaotic-society/theoretica) ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/chaotic-society/theoretica/test-windows.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/0f4ae5dc6e1140ad855a3d6325d44b35)](https://app.codacy.com/gh/chaotic-society/theoretica/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=chaotic-society/theoretica&amp;utm_campaign=Badge_Grade) ![License](https://img.shields.io/github/license/chaotic-society/theoretica)

> A numerical and automatic math library for scientific research and graphical applications
Expand All @@ -18,7 +18,7 @@ mat<N, N> J = mat<N, N>::symplectic();
real df_dt = gradient(f, eta) * J * gradient(H, eta);
```

The library includes basic functionalities like real and complex analysis functions enhanced for x86 architectures, vector and matrix operations (both row-major and column-major), quaternions and function roots and extrema search, as well as more advanced features like dual numbers for automatic differentiation, statistical functions including distribution sampling, pseudorandom and quasirandom number generation for Monte Carlo methods and simulations.
The library includes real and complex analysis functions optimized for the x86 architecture, linear algebra, quaternions, roots and extrema search, numerical approximation of derivatives, integrals and differential equations, as well as more advanced features like dual numbers for automatic differentiation, statistical functions including distribution sampling, pseudorandom and quasirandom number generation for Monte Carlo methods and simulations.

## Table of Contents
- [Key Features](#key-features)
Expand All @@ -40,7 +40,7 @@ This is an overview of the library's functionalities. For a more detailed list s
- Dual numbers, **Multivariable Automatic Differentiation** and Differential Operators
- Pseudorandom and Quasirandom number generation (LCG, Xoshiro256++, Splitmix64, Wyrand, Weyl)
- Statistical functions, including **Least Squares Linearization**
- Random distribution sampling
- Random distribution sampling and Monte Carlo
- Approximation of roots, extrema, derivatives and integrals of real functions
- Numerical integration of **Ordinary Differential Equations** (Euler, Heun, RK4, K38, multistep)
- Polynomial interpolation with Chebyshev nodes, Bezier curves and spline interpolation
Expand All @@ -51,11 +51,12 @@ The library has no dependencies. Only the C++ Standard Library with C++11 capabi
## Setup
You don't need anything other than your compiler to use the library. You can run `make all` in the root directory of the library to make sure it works.
Define **THEORETICA_INCLUDE_BASE** if you intend to use only basic functionalities (linear algebra, real functions, complex numbers), as by default `theoretica.h` includes all headers.
All library functions are implemented in the `theoretica` namespace (`th` is a shorter namespace alias).
All library functions and objects are implemented in the `theoretica` namespace (`th` is a shorter namespace alias).

## Documentation
The documentation for the library is available [here](https://chaotic-society.github.io/theoretica/).
Introductory examples can be found in [EXAMPLES.md](https://github.com/chaotic-society/theoretica/blob/master/docs/txt/EXAMPLES.md) and more advanced examples can be found inside the `examples/` folder.
The bibliography used for researching the algorithms used in the library is available [here](https://github.com/chaotic-society/theoretica/blob/master/docs/txt/BIBLIOGRAPHY.md).

### Quickstart
You can try to compile this simple code to check if you set up the library correctly:
Expand All @@ -74,11 +75,11 @@ int main() {
```

### Other examples
- [Chaotic Attractors](https://github.com/chaotic-society/theoretica/blob/master/examples/attractor.cpp)
- [Statistics](https://github.com/chaotic-society/theoretica/blob/master/examples/statistics.cpp)
- [Automatic differentiation](https://github.com/chaotic-society/theoretica/blob/master/examples/automatic_differentiation.cpp)
- [Sampling distributions](https://github.com/chaotic-society/theoretica/blob/master/examples/sampling_distributions.cpp)
- [Monte Carlo methods](https://github.com/chaotic-society/theoretica/blob/master/examples/montecarlo_comparison.cpp)
- [Chaotic Attractors](https://github.com/chaotic-society/theoretica/blob/master/examples/attractor.cpp)
- [Automatic differentiation](https://github.com/chaotic-society/theoretica/blob/master/examples/autodiff.cpp)
- [Sampling distributions](https://github.com/chaotic-society/theoretica/blob/master/examples/sampling.cpp)
- [Monte Carlo integration](https://github.com/chaotic-society/theoretica/blob/master/examples/montecarlo_integral.cpp)
- [Fitting data](https://github.com/chaotic-society/theoretica/blob/master/examples/logfit.cpp)
- [Automatic error propagation](https://github.com/chaotic-society/theoretica/blob/master/examples/error_propagation.cpp)
- [Histogram usage](https://github.com/chaotic-society/theoretica/blob/master/examples/histogram.cpp)
Expand All @@ -91,7 +92,7 @@ Contributions are welcome and very appreciated! Make sure to read the [Contribut

The library uses the custom built [Chebyshev testing framework](https://github.com/chaotic-society/chebyshev) to **estimate the precision** of functions and test their **performance**. Tests are automatically run on Windows, Linux and MacOS on every commit to ensure stability. Test units are placed inside the `test` folder while benchmarks are placed inside the `benchmark` folder.

## Other informations
## Other information

### License
This project is currently under the [GNU Lesser General Public License 3.0](https://github.com/chaotic-society/theoretica/blob/master/LICENSE).
Expand Down
10 changes: 5 additions & 5 deletions benchmark/benchmark_algebra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ using benchmark::benchmark_result;


template<unsigned int N, unsigned int M = N>
mat<N, M> rand_mat(real min, real max, PRNG& g) {
mat<real, N, M> rand_mat(real min, real max, PRNG& g) {

mat<N, M> A;
mat<real, N, M> A;

for (unsigned int i = 0; i < N; ++i)
for (unsigned int j = 0; j < M; ++j)
A.iat(i, j) = rand_uniform(min, max, g);
A.at(i, j) = rand_uniform(min, max, g);

return A;
}
Expand All @@ -24,7 +24,7 @@ mat<N, M> rand_mat(real min, real max, PRNG& g) {
template<unsigned int N>
benchmark_result benchmark_mat_det(unsigned int iter, unsigned int runs) {

std::vector<mat<N, N>> A(iter);
std::vector<mat<real, N, N>> A(iter);
volatile real c = 0;

const int MAX = 100000;
Expand Down Expand Up @@ -53,7 +53,7 @@ benchmark_result benchmark_mat_det(unsigned int iter, unsigned int runs) {
template<unsigned int N>
benchmark_result benchmark_mat_inverse(unsigned int iter, unsigned int runs) {

std::vector<mat<N, N>> A(iter);
std::vector<mat<real, N, N>> A(iter);
volatile real c = 0;

const int MAX = 100000;
Expand Down
2 changes: 2 additions & 0 deletions benchmark/benchmark_real_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,7 @@ int main(int argc, char const *argv[]) {
benchmark::request("th::binomial_coeff",
[](real x) { return binomial_coeff<uint32_t>(10, x); }, uniform_generator(0, 9));

BENCHMARK(th::special::gamma, 0.1, 20);

benchmark::terminate();
}
2 changes: 1 addition & 1 deletion docs/annotated.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Tue Jun 27 2023 15:20:19 for Theoretica by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
<li class="footer">Generated on Wed Sep 13 2023 16:25:44 for Theoretica by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
</ul>
</div>
</body>
Expand Down
11 changes: 1 addition & 10 deletions docs/attractor_8cpp.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@
<tr class="memitem:a9beca8606cc317769958c4658d98554c"><td class="memItemLeft" align="right" valign="top"><a id="a9beca8606cc317769958c4658d98554c" name="a9beca8606cc317769958c4658d98554c"></a>
const <a class="el" href="namespacetheoretica.html#a049966946220f1f7e5eae57293703066">real</a>&#160;</td><td class="memItemRight" valign="bottom"><b>c</b> = 8 / 3.0</td></tr>
<tr class="separator:a9beca8606cc317769958c4658d98554c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae0af7a6e62928a88cc7aacd7fa840c6a"><td class="memItemLeft" align="right" valign="top"><a id="ae0af7a6e62928a88cc7aacd7fa840c6a" name="ae0af7a6e62928a88cc7aacd7fa840c6a"></a>
const <a class="el" href="namespacetheoretica.html#a049966946220f1f7e5eae57293703066">real</a>&#160;</td><td class="memItemRight" valign="bottom"><b>d</b> = 0</td></tr>
<tr class="separator:ae0af7a6e62928a88cc7aacd7fa840c6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a239fc54a76293a87f4e239ce20cfe69e"><td class="memItemLeft" align="right" valign="top"><a id="a239fc54a76293a87f4e239ce20cfe69e" name="a239fc54a76293a87f4e239ce20cfe69e"></a>
const <a class="el" href="namespacetheoretica.html#a049966946220f1f7e5eae57293703066">real</a>&#160;</td><td class="memItemRight" valign="bottom"><b>e</b> = 0</td></tr>
<tr class="separator:a239fc54a76293a87f4e239ce20cfe69e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a99c80d79be5c2549f93a911da7724e69"><td class="memItemLeft" align="right" valign="top"><a id="a99c80d79be5c2549f93a911da7724e69" name="a99c80d79be5c2549f93a911da7724e69"></a>
const <a class="el" href="namespacetheoretica.html#a049966946220f1f7e5eae57293703066">real</a>&#160;</td><td class="memItemRight" valign="bottom"><b>g</b> = 0</td></tr>
<tr class="separator:a99c80d79be5c2549f93a911da7724e69"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p >Compute the orbit of a chaotic attractor. </p>
Expand All @@ -153,7 +144,7 @@
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_d28a4824dc47e487b107a5db32ef43c4.html">examples</a></li><li class="navelem"><a class="el" href="attractor_8cpp.html">attractor.cpp</a></li>
<li class="footer">Generated on Tue Jun 27 2023 15:20:17 for Theoretica by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
<li class="footer">Generated on Wed Sep 13 2023 16:25:42 for Theoretica by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
</ul>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/autodiff_8h.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_42425a70e384b694fde5273f8252c9aa.html">autodiff</a></li><li class="navelem"><a class="el" href="autodiff_8h.html">autodiff.h</a></li>
<li class="footer">Generated on Tue Jun 27 2023 15:20:17 for Theoretica by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
<li class="footer">Generated on Wed Sep 13 2023 16:25:42 for Theoretica by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.3 </li>
</ul>
</div>
</body>
Expand Down
Loading

0 comments on commit 0136a49

Please sign in to comment.