Skip to content

Commit

Permalink
Merge pull request #999 from boostorg/develop
Browse files Browse the repository at this point in the history
Merge develop for 1.83
  • Loading branch information
mborland authored Jun 28, 2023
2 parents c56f334 + 8bb0d16 commit 1a7be5d
Show file tree
Hide file tree
Showing 200 changed files with 5,924 additions and 1,993 deletions.
5 changes: 5 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):

things_to_test = [ "special_fun", "distribution_tests", "mp", "misc", "interpolators", "quadrature", "autodiff", "long-running-tests", "float128_tests" ]
gcc13_things_to_test = [ "special_fun", "distribution_tests", "mp", "misc", "interpolators", "quadrature", "autodiff", "long-running-tests", "float128_tests", "new_floats" ]
sanitizer_test = [ "special_fun", "distribution_tests", "misc", "interpolators", "quadrature", "float128_tests" ]
gnu_5_stds = [ "gnu++14", "c++14" ]
gnu_6_stds = [ "gnu++14", "c++14", "gnu++17", "c++17" ]
clang_6_stds = [ "c++14", "c++17" ]
gnu_9_stds = [ "gnu++14", "c++14", "gnu++17", "c++17", "gnu++2a", "c++2a" ]
clang_10_stds = [ "c++14", "c++17", "c++2a" ]
gnu_non_native = [ "gnu++17" ]
gcc13_stds = [ "c++23" ]

result = []

Expand Down Expand Up @@ -59,6 +61,9 @@ def main(ctx):
result.append(linux_cxx("Ubuntu g++ ARM64" + cxx + " " + suite, "g++", packages="g++", buildtype="boost", image="cppalliance/droneubuntu2204:multiarch", arch="arm64", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++', 'CXXSTD': cxx, 'TEST_SUITE': suite, }, globalenv=globalenv))
for cxx in gnu_non_native:
result.append(osx_cxx("M1 Clang " + cxx + " " + suite, "clang++", buildscript="drone", buildtype="boost", xcode_version="14.1", environment={'TOOLSET': 'clang', 'CXXSTD': cxx, 'TEST_SUITE': suite, 'DEFINE': 'BOOST_MATH_NO_REAL_CONCEPT_TESTS,BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS,BOOST_MATH_MULTI_ARCH_CI_RUN', }, globalenv=globalenv))
for suite in gcc13_things_to_test:
for cxx in gcc13_stds:
result.append(linux_cxx("Ubuntu g++-13 " + cxx + " " + suite, "g++-13", packages="g++-13", buildtype="boost", image="cppalliance/droneubuntu2304:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-13', 'CXXSTD': cxx, 'TEST_SUITE': suite, }, globalenv=globalenv))

return result

Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
branches:
- master
- develop
- feature/**
pull_request:
release:
types: [published, created, edited]
Expand Down Expand Up @@ -47,7 +48,7 @@ jobs:
if: steps.retry1.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-12 clang-14 libgmp-dev libmpfr-dev libfftw3-dev
run: sudo apt-get install -y g++-12 clang-14 libgmp-dev libmpfr-dev libfftw3-dev
- name: Checkout main boost
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
- name: Update tools/boostdep
Expand Down Expand Up @@ -75,7 +76,7 @@ jobs:
run: ./config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ../../../b2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER
run: ../../../b2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER define=BOOST_MATH_RUN_MP_TESTS
working-directory: ../boost-root/libs/math/test
ubuntu-focal-no-eh:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -105,7 +106,7 @@ jobs:
if: steps.retry1.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-9 g++-11 clang-9 clang-10 libgmp-dev libmpfr-dev libfftw3-dev
run: sudo apt-get install -y g++-9 g++-11 clang-9 clang-10 libgmp-dev libmpfr-dev libfftw3-dev
- name: Checkout main boost
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
- name: Update tools/boostdep
Expand Down Expand Up @@ -214,7 +215,7 @@ jobs:
run: config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ..\..\..\b2 --hash %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES debug-symbols=off ${{ matrix.suite }}
run: ..\..\..\b2 --hash %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES debug-symbols=off ${{ matrix.suite }} pch=off
working-directory: ../boost-root/libs/math/test
windows_gcc:
runs-on: windows-2019
Expand Down Expand Up @@ -299,7 +300,7 @@ jobs:
run: config_info_travis
working-directory: ../boost-root/libs/config/test
- name: Test
run: ..\..\..\b2 --hash %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES ${{ matrix.suite }}
run: ..\..\..\b2 --hash %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES ${{ matrix.suite }} pch=off
working-directory: ../boost-root/libs/math/test
cygwin:
runs-on: windows-latest
Expand Down Expand Up @@ -364,7 +365,7 @@ jobs:
if: steps.retry1.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-10 libgmp-dev libmpfr-dev libfftw3-dev
run: sudo apt-get install -y g++-10 libgmp-dev libmpfr-dev libfftw3-dev
- name: Checkout main boost
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
- name: Update tools/boostdep
Expand Down Expand Up @@ -404,7 +405,7 @@ jobs:
if: steps.retry1.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install clang-10 libgmp-dev libmpfr-dev libfftw3-dev
run: sudo apt-get install -y clang-10 libgmp-dev libmpfr-dev libfftw3-dev libtbb-dev
- name: Checkout main boost
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
- name: Update tools/boostdep
Expand Down Expand Up @@ -448,7 +449,7 @@ jobs:
if: steps.retry1.outcome=='failure'
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- name: Install packages
run: sudo apt install g++-10 libgmp-dev libmpfr-dev libfftw3-dev
run: sudo apt-get install -y g++-10 libgmp-dev libmpfr-dev libfftw3-dev
- name: Checkout main boost
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
- name: Update tools/boostdep
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ Boost Math Library
[![Build Status](https://drone.cpp.al/api/badges/boostorg/math/status.svg)](https://drone.cpp.al/boostorg/math)[![Build Status](https://github.com/boostorg/math/workflows/CI/badge.svg?branch=develop)](https://github.com/boostorg/math/actions)
==================

>ANNOUNCEMENT: Support for C++11 will be deprecated in this library starting in July 2023 (Boost 1.82).
>New features will require *at least* C++14, as will existing features starting with the deprecation release.
>ANNOUNCEMENT: This library now requires a compliant C++14 compiler.
This library is divided into several interconnected parts:

Expand Down
2 changes: 1 addition & 1 deletion doc/background/references.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The Wolfram Research Documentation Center is a collection of online reference ma
Statistical Distributions (Wiley Series in Probability & Statistics) (Paperback)
by N.A.J. Hastings, Brian Peacock, Merran Evans, ISBN: 0471371246, Wiley 2000.

[@http://www.worldscibooks.com/mathematics/p191.html Extreme Value Distributions, Theory and Applications]
[@https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0 Extreme Value Distributions, Theory and Applications]
Samuel Kotz & Saralees Nadarajah, ISBN 978-1-86094-224-2 & 1-86094-224-5 Oct 2000,
Chapter 1.2 discusses the various extreme value distributions.

Expand Down
2 changes: 1 addition & 1 deletion doc/distributions/exponential.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ In the following table [lambda] is the parameter lambda of the distribution,
(See also the reference documentation for the related __extreme_distrib.)

*
[@http://www.worldscibooks.com/mathematics/p191.html Extreme Value Distributions, Theory and Applications
[@https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0 Extreme Value Distributions, Theory and Applications
Samuel Kotz & Saralees Nadarajah]
discuss the relationship of the types of extreme value distributions.

Expand Down
2 changes: 1 addition & 1 deletion doc/distributions/extreme_value.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ websites.

The relationship of the types of extreme value distributions, of which this is but one, is
discussed by
[@http://www.worldscibooks.com/mathematics/p191.html Extreme Value Distributions, Theory and Applications
[@https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0 Extreme Value Distributions, Theory and Applications
Samuel Kotz & Saralees Nadarajah].

The distribution has a PDF given by:
Expand Down
18 changes: 9 additions & 9 deletions doc/distributions/hypergeometric.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
typedef RealType value_type;
typedef Policy policy_type;
// Construct:
hypergeometric_distribution(unsigned r, unsigned n, unsigned N); // r=defective/failures/success, n=trials/draws, N=total population.
hypergeometric_distribution(uint64_t r, uint64_t n, uint64_t N); // r=defective/failures/success, n=trials/draws, N=total population.
// Accessors:
unsigned total()const;
unsigned defective()const;
unsigned sample_count()const;
uint64_t total()const;
uint64_t defective()const;
uint64_t sample_count()const;
};

typedef hypergeometric_distribution<> hypergeometric;
Expand Down Expand Up @@ -56,20 +56,20 @@ then we obtain basically the same graphs:

[h4 Member Functions]

hypergeometric_distribution(unsigned r, unsigned n, unsigned N);
hypergeometric_distribution(uint64_t r, uint64_t n, uint64_t N);

Constructs a hypergeometric distribution with a population of /N/ objects,
of which /r/ are defective, and from which /n/ are sampled.

unsigned total()const;
uint64_t total()const;

Returns the total number of objects /N/.

unsigned defective()const;
uint64_t defective()const;

Returns the number of objects /r/ in population /N/ which are defective.

unsigned sample_count()const;
uint64_t sample_count()const;

Returns the number of objects /n/ which are sampled from the population /N/.

Expand All @@ -87,7 +87,7 @@ and Python
All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
that are generic to all distributions are supported: __usual_accessors.

The domain of the random variable is the unsigned integers in the range
The domain of the random variable are the 64-bit unsigned integers in the range
\[max(0, n + r - N), min(n, r)\]. A __domain_error is raised if the
random variable is outside this range, or is not an integral value.

Expand Down
2 changes: 1 addition & 1 deletion doc/distributions/triangular.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The triangular distribution is often used where the distribution is only vaguely
but, like the [@http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29 uniform distribution],
upper and limits are 'known', but a 'best guess', the mode or center point, is also added.
It has been recommended as a
[@http://www.worldscibooks.com/mathematics/etextbook/5720/5720_chap1.pdf proxy for the beta distribution.]
[@https://www.jstor.org/stable/2988573 proxy for the beta distribution.]
The distribution is used in business decision making and project planning.

The [@http://en.wikipedia.org/wiki/Triangular_distribution triangular distribution]
Expand Down
2 changes: 1 addition & 1 deletion doc/distributions/weibull.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ When ['[alpha]] = 1, the Weibull distribution reduces to the
[@http://en.wikipedia.org/wiki/Exponential_distribution exponential distribution].
The relationship of the types of extreme value distributions, of which the Weibull is but one, is
discussed by
[@http://www.worldscibooks.com/mathematics/p191.html Extreme Value Distributions, Theory and Applications
[@https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0 Extreme Value Distributions, Theory and Applications
Samuel Kotz & Saralees Nadarajah].


Expand Down
Binary file added doc/graphs/fourier_transform_daubechies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion doc/html/math_toolkit/dist_ref/dists/exp_dist.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ <h5>
Distributions</a>.)
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
<a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme
<a href="https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0" target="_top">Extreme
Value Distributions, Theory and Applications Samuel Kotz &amp; Saralees
Nadarajah</a> discuss the relationship of the types of extreme
value distributions.
Expand Down
2 changes: 1 addition & 1 deletion doc/html/math_toolkit/dist_ref/dists/extreme_dist.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</p>
<p>
The relationship of the types of extreme value distributions, of which
this is but one, is discussed by <a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme
this is but one, is discussed by <a href="https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0" target="_top">Extreme
Value Distributions, Theory and Applications Samuel Kotz &amp; Saralees
Nadarajah</a>.
</p>
Expand Down
2 changes: 1 addition & 1 deletion doc/html/math_toolkit/dist_ref/dists/triangular_dist.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
vaguely known, but, like the <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
distribution</a>, upper and limits are 'known', but a 'best guess',
the mode or center point, is also added. It has been recommended as a
<a href="http://www.worldscibooks.com/mathematics/etextbook/5720/5720_chap1.pdf" target="_top">proxy
<a href="https://www.jstor.org/stable/2988573" target="_top">proxy
for the beta distribution.</a> The distribution is used in business
decision making and project planning.
</p>
Expand Down
2 changes: 1 addition & 1 deletion doc/html/math_toolkit/dist_ref/dists/weibull_dist.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ <h5>
distribution</a>. When <span class="emphasis"><em>α</em></span> = 1, the Weibull distribution
reduces to the <a href="http://en.wikipedia.org/wiki/Exponential_distribution" target="_top">exponential
distribution</a>. The relationship of the types of extreme value distributions,
of which the Weibull is but one, is discussed by <a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme
of which the Weibull is but one, is discussed by <a href="https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0" target="_top">Extreme
Value Distributions, Theory and Applications Samuel Kotz &amp; Saralees
Nadarajah</a>.
</p>
Expand Down
2 changes: 1 addition & 1 deletion doc/html/math_toolkit/refs.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h5>
by N.A.J. Hastings, Brian Peacock, Merran Evans, ISBN: 0471371246, Wiley 2000.
</p>
<p>
<a href="http://www.worldscibooks.com/mathematics/p191.html" target="_top">Extreme Value
<a href="https://www.google.com/books/edition/Extreme_Value_Distributions/GwBqDQAAQBAJ?hl=en&gbpv=0" target="_top">Extreme Value
Distributions, Theory and Applications</a> Samuel Kotz &amp; Saralees Nadarajah,
ISBN 978-1-86094-224-2 &amp; 1-86094-224-5 Oct 2000, Chapter 1.2 discusses
the various extreme value distributions.
Expand Down
1 change: 1 addition & 0 deletions doc/math.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ and as a CD ISBN 0-9504833-2-X 978-0-9504833-2-0, Classification 519.2-dc22.
[include statistics/runs_test.qbk]
[include statistics/ljung_box.qbk]
[include statistics/linear_regression.qbk]
[include statistics/chatterjee_correlation.qbk]
[endmathpart] [/section:statistics Statistics]

[mathpart vector_functionals Vector Functionals - Norms]
Expand Down
42 changes: 42 additions & 0 deletions doc/sf/daubechies.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,48 @@ The 2 vanishing moment scaling function.
[$../graphs/daubechies_8_scaling.svg]
The 8 vanishing moment scaling function.

Boost.Math also provides numerical evaluation of the Fourier transform of these functions.
This is useful in sparse recovery problems where the measurements are taken in the Fourier basis.
The usage is exhibited below:

#include <boost/math/special_functions/fourier_transform_daubechies_scaling.hpp>
using boost::math::fourier_transform_daubechies_scaling;
// Evaluate the Fourier transform of the 4-vanishing moment Daubechies scaling function at ω=1.8:
std::complex<float> hat_phi = fourier_transform_daubechies_scaling<float, 4>(1.8f);

The Fourier transform convention is unitary with the sign of the imaginary unit being given in Daubechies Ten Lectures.
In particular, this means that `fourier_transform_daubechies_scaling<float, p>(0.0)` returns 1/sqrt(2π).

The implementation computes an infinite product of trigonometric polynomials as can be found from recursive application of the identity 𝓕[φ](ω) = m(ω/2)𝓕[φ](ω/2).
This is neither particularly fast nor accurate, but there appears to be no literature on this extremely useful topic, and hence the naive method must suffice.

[$../graphs/fourier_transform_daubechies.png]

A benchmark can be found in `reporting/performance/fourier_transform_daubechies_performance.cpp`; the results on a ~2021 M1 Macbook pro are presented below:


Run on (10 X 24.1212 MHz CPU s)
CPU Caches:
L1 Data 64 KiB (x10)
L1 Instruction 128 KiB (x10)
L2 Unified 4096 KiB (x5)
Load Average: 1.33, 1.52, 1.62
-----------------------------------------------------------
Benchmark Time
-----------------------------------------------------------
FourierTransformDaubechiesScaling<double, 1> 70.3 ns
FourierTransformDaubechiesScaling<double, 2> 330 ns
FourierTransformDaubechiesScaling<double, 3> 335 ns
FourierTransformDaubechiesScaling<double, 4> 364 ns
FourierTransformDaubechiesScaling<double, 5> 386 ns
FourierTransformDaubechiesScaling<double, 6> 436 ns
FourierTransformDaubechiesScaling<double, 7> 447 ns
FourierTransformDaubechiesScaling<double, 8> 473 ns
FourierTransformDaubechiesScaling<double, 9> 503 ns
FourierTransformDaubechiesScaling<double, 10> 554 ns

Due to the low accuracy of this method, `float` precision is arg-promoted to `double`, and hence takes just as long as `double` precision to execute.

[heading References]

* Daubechies, Ingrid. ['Ten Lectures on Wavelets.] Vol. 61. Siam, 1992.
Expand Down
43 changes: 43 additions & 0 deletions example/calculate_fourier_transform_daubechies_constants.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// (C) Copyright Nick Thompson 2023.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <utility>
#include <boost/math/filters/daubechies.hpp>
#include <boost/math/tools/polynomial.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/math/constants/constants.hpp>

using std::pow;
using boost::multiprecision::cpp_bin_float_100;
using boost::math::filters::daubechies_scaling_filter;
using boost::math::tools::polynomial;
using boost::math::constants::half;
using boost::math::constants::root_two;

template<typename Real, size_t N>
std::vector<Real> get_constants() {
auto h = daubechies_scaling_filter<cpp_bin_float_100, N>();
auto p = polynomial<cpp_bin_float_100>(h.begin(), h.end());

auto q = polynomial({half<cpp_bin_float_100>(), half<cpp_bin_float_100>()});
q = pow(q, N);
auto l = p/q;
return l.data();
}

template<typename Real>
void print_constants(std::vector<Real> const & l) {
std::cout << std::setprecision(std::numeric_limits<Real>::digits10 -10);
std::cout << "return std::array<Real, " << l.size() << ">{";
for (size_t i = 0; i < l.size() - 1; ++i) {
std::cout << "BOOST_MATH_BIG_CONSTANT(Real, std::numeric_limits<Real>::digits, " << l[i]/root_two<Real>() << "), ";
}
std::cout << "BOOST_MATH_BIG_CONSTANT(Real, std::numeric_limits<Real>::digits, " << l.back()/root_two<Real>() << ")};\n";
}

int main() {
auto constants = get_constants<cpp_bin_float_100, 1>();
print_constants(constants);
}
Loading

0 comments on commit 1a7be5d

Please sign in to comment.