2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-11 11:52:21 +00:00
Commit Graph

5490 Commits

Author SHA1 Message Date
jzmaddock
44ae862ce9 Experimental prime_sieve. 2020-09-27 10:57:45 +01:00
John Maddock
58a1c7a4ea Merge branch 'prime_functions' of https://github.com/mborland/math into primes 2020-09-27 10:30:38 +01:00
Matt Borland
c361cdea65 Linear output iterator and refactoring [CI SKIP] 2020-09-26 21:02:28 -05:00
Matt Borland
0d9d31b374 Merge branch 'prime_functions' into mborland/prime_functions 2020-09-26 20:55:53 -05:00
Matt Borland
1d2f03c108 Linear sieve with output iterator and refactoring [CI SKIP][WIP] 2020-09-26 20:51:20 -05:00
Matt Borland
f2277e3c52 Merge branch 'prime_iterator' into mborland/prime_iterator 2020-09-26 20:46:24 -05:00
Matt Borland
f5d789adbc Improved Linear Algo and testing 2020-09-26 20:36:44 -05:00
Suyash Patil
c2843663dc fixed CSS property in doc/math.css (#437) 2020-09-26 17:38:15 -04:00
Matt Borland
eee2c8627b Added container method 2020-09-26 12:46:15 -05:00
Suyash Patil
2dec5f6af5 fix typo in README.md (#436) 2020-09-17 08:52:54 -04:00
Matt Borland
0dbe69cb72 Sanitize linear prime sieve and add wheel
[WIP][CI SKIP]
2020-09-09 18:30:13 -05:00
Matt Borland
5dc35236d0 Implemented linear sieve with iterators
[WIP][CI SKIP]
2020-09-09 17:59:47 -05:00
Matt Borland
84a69f0304 diffs from @jzmaddock [CI SKIP] 2020-09-08 18:02:10 -05:00
Matt Borland
9792a23b4e Minor change to policy handling [CI SKIP] 2020-09-06 18:33:55 -05:00
Matt Borland
302fb5fcdb Merge branch 'develop' into prime_functions 2020-09-05 14:33:46 -05:00
Evan Miller
18ed616376 Kolmogorov-Smirnov distribution (#422)
* Kolmogorov-Smirnov distribution #421

Add a new distribution, kolmogorov_smirnov_distribution, which takes a
parameter that represents the number of observations used in a
Kolmogorov-Smirnov test. (The K-S test is a popular test for comparing
two CDFs, but the test statistic is not implemented here.)

This implementation includes Kolmogorov's original 1st order Taylor
expansion. There is a literature on the distribution's other
mathematical properties (higher order terms and exact version); this
literature is summarized in the main header file for anyone who may
want to expand the implementation later.

The CDF is implemented using a Jacobi theta function, and the PDF is a
hand-rolled derivative of that function. Quantiles plug the CDF and PDF
into a Newton-Raphson iteration. The mean and variance have nice
closed-form expressions, and the mode uses a dumb run-time maximizer.

This commit includes graphs, a ULP plotter for the PDF, and the usual
compilation and numerical tests. The test file is on the small side, but
it integrates the distribution from zero to infinity, and covers the
quantiles pretty well. As of now the numerical tests only verify
self-consistency (e.g. distribution moments and CDF-quantile relations),
so there's room to add some external checks.

* Implement skewness for K-S distribution [CI SKIP]

The third moment integrates nicely with the help of Apery's constant
(zeta_three). Verify the result via quadrature.

* Implement kurtosis for the K-S distribution

Verify the result via quadrature.
2020-09-04 08:48:51 -04:00
jzmaddock
eb668a01bd Merge pull request #432 from boostorg/improve_float_next
Update float_next/float_prior to handle types with exponents larger t…
2020-09-04 11:49:16 +01:00
jzmaddock
e39eca4f54 Update float_next/float_prior to handle types with exponents larger than type int. 2020-09-03 18:35:14 +01:00
Märt Laak
a9f096815d Make interpolators C++14 compatible (#429) 2020-09-02 18:55:37 -04:00
Matt Borland
3d9b77c784 Minor changes and doc updates 2020-09-02 16:41:41 -05:00
Matt Borland
7c0cbbfe29 Merge branch 'develop' into prime_functions 2020-08-31 23:32:26 -05:00
Matt Borland
8e240f7eb7 Better prime_range implementation [WIP][CI SKIP] 2020-08-30 23:51:19 -05:00
Matt Borland
5ba0a1d1f8 Replace magic number w variable template [CI SKIP] 2020-08-30 23:15:46 -05:00
Matt Borland
0b8f1d51ed Documentation edits [CI SKIP] 2020-08-30 18:02:17 -05:00
pabristow
39d0c1c4a1 Added missing #include <vector>. 2020-08-28 17:49:32 +01:00
jzmaddock
526fc6eef4 Update test_jacobi_theta compiler requirements in Jamfile.v2. 2020-08-27 18:36:18 +01:00
Matt Borland
81e4a6ca60 mpz_int passes unit tests [CI SKIP] 2020-08-26 22:29:27 -05:00
Matt Borland
6d6b19fb9e cpp_int now passes all tests [CI SKIP] 2020-08-26 19:23:54 -05:00
Matt Borland
91836f62f3 Fixes for multiprecision and policies [CI SKIP] 2020-08-25 18:44:07 -05:00
Matt Borland
c4a89c86ff Seq policy actually sequential [CI SKIP] 2020-08-24 23:12:01 -05:00
Matt Borland
fa04133513 Significant refactoring [WIP][CI SKIP] 2020-08-24 22:00:05 -05:00
Matt Borland
97244be0a0 Performance improvements and bug fixes [CI SKIP] 2020-08-23 22:57:46 -05:00
Matt Borland
1b40403801 Implemented interval sieve [CI SKIP] 2020-08-23 18:50:07 -05:00
Matt Borland
6759ede1b3 Added unit tests [WIP][CI SKIP] 2020-08-23 17:06:51 -05:00
Matt Borland
2e46b81a33 Added interval sieve to performance test [CI SKIP] 2020-08-23 13:59:24 -05:00
Matt Borland
fbc38c8bf6 New segmented sieve algorithm [WIP][CI SKIP] 2020-08-23 11:42:20 -05:00
Matt Borland
b7d42564f5 Added fixed mod 210 wheel [WIP][CI SKIP] 2020-08-23 10:59:18 -05:00
jzmaddock
d72149388e Merge branch 'develop' of https://github.com/boostorg/math into develop 2020-08-21 11:13:30 +01:00
jzmaddock
d7ab3a9873 tanh_sinh: trivial correction of if..else logic.
Without this we can take 2 of the branches when z < -0.5 and not make correct use of zc triggering the assertion later.
[CI SKIP]
2020-08-21 11:13:13 +01:00
jzmaddock
09c0d37178 Merge pull request #418 from boostorg/mp_erf
Update multiprecision erf to improve precision and performance.
2020-08-20 18:21:44 +01:00
jzmaddock
b1c03c841a Jamfile.v2: Tidy up mpfr/gmp use so tests pass on mingw64 2020-08-18 11:19:48 +01:00
jzmaddock
8633d74278 jacobi_theta.hpp: Fix a few concept errors. 2020-08-18 11:19:18 +01:00
Matt Pulver
d739449f61 Fix to logic error in c8117fc. 2020-08-16 15:08:52 -04:00
Matt Pulver
c8117fc4bb [#420] Protect unused branches with size_t overflow when compiled pre-C++17.
Replace 'if BOOST_AUTODIFF_IF_CONSTEXPR' with 'BOOST_IF_CONSTEXPR'.
2020-08-16 10:30:50 -04:00
Evan Miller
d7141cd353 Jacobi Theta functions (#394)
* Jacobi Theta functions

Implementations, tests, and ULP plotting programs are provided for the
four Jacobi Theta functions per #373. Twenty-four public C++ functions
are provided in all, covering various precision-preserving scenarios.

Documentation for collaborators is provided in the code comments. Proper
documentation for end users will be provided when the implementation and
APIs are finalized.

Some tests are failing; this implementation is meant to start a
conversation. The core dilemma faced by the author was that large values
of |q| resulted in slow convergence, and sometimes wildly inaccurate
results. Following the implementation note in DLMF 20.14, I added code
to switch over to the imaginary versions of the theta functions when |q|
> 0.85.  This restored accuracy such that all of the identity tests
passed for a loose-enough epsilon, but then lost precision to the point
that the Wolfram Alpha spot checks failed. It is the author's hope that
someone with floating-point experience can tame the exponential dragons
and squeeze the ULPs back down to a reasonable range when |q| is large.

When #392 is merged I will add more thorough value tests, although I
fully expect them to fail until the underlying precision issues are
resolved.

As a final note, the precision issues do not affect the z=0 case - the
ULP plots indicate these return values within 2 ULP across all valid
|q|. So that's a start.

* [CI SKIP] Jacobi theta: Add special-value tests and more

* Add tests covering z=0 special values from MathWorld

* Add missing real_concept header

* Replace M_PI and friends with constants::pi etc

* Use BOOST_MATH_STD_USING in more places

* Jacobi theta: Test two more of Watson's identities [CI SKIP]

See https://mathworld.wolfram.com/JacobiThetaFunctions.html

(Equations 48 and 49)

* Improve precision of Jacobi theta functions [CI SKIP]

Rewrite the private imaginary versions to use double-sided summations
following DLMF 20.13.4 and 20.13.5. This cuts down the worst of the
precision issues by a factor of 10, and gets more of the tests to pass.

I am confident enough in the code path to eliminate the compile-time
__JACOBI_THETA_USE_IMAGINARY flag. In fact the imaginary-z code paths
are now enabled for all |q| > 0.04, i.e. most legal values of q.

More extensive tests will be needed to illuminate any remaining
precision issues.

* Jacobi theta: Make changes suggested in #394 [CI SKIP]

* Add LICENSE notice to main file

* Document convergence criteria

* Eliminate eps*eps = 0 logic. This causes some disagreement with the
zero returned by Wolfram Alpha for z=0, q > 0.99 in the fourth function.
Mathematically, the fourth function is never exactly zero, so I don't
trust Wolfram here.

* Per code-review comments, remove multiplications by floating-point 2.

* Tweak the plotting programs to display their titles, and to uniformly
use `float` as their CoarseType and `long double` as their
`PreciseType`.

* Add quadrature tests to Jacobi theta functions [CI SKIP]

The quadrature tests revealed a problem in the m1 functions: they too
should switch to the _IMAGINARY logic for q > exp(-pi), or will suffer
from slow convergence. Fix them.

Also tighten tolerances for many tests from sqrt(eps) to 100 * eps.

* Test Jacobi thetas against elliptic functions and elliptic integrals [CI SKIP]

See:

* https://dlmf.nist.gov/22.2
* https://dlmf.nist.gov/20.9#i

* Test Jacobi Thetas against their Laplace transforms [CI SKIP]

See:

* https://dlmf.nist.gov/20.10#ii

I did find some disagreement, and dropped the negative sign from the
theta1 equation. DLMF's theta2 and theta3 Laplace transform equations do
not agree at all with the computed values - will need to investigate.

In the meantime, the two implemented equations agree to 4 EPS so I am
keeping them.

* Add a note on using log1p with Jacobi theta functions [CI SKIP]

See discussion:

* https://github.com/boostorg/math/pull/394#issuecomment-655871762

* Add random data tests to Jacobi Theta functions [CI SKIP]

Add a test data generator program for the Jacobi theta functions.
This program will produce data for the tau parameterization, so that
precision isn't lost during the log-transformation. This distinguishes
it from the Wolfram Alpha data, which is parameterized by q.

A few of these new random-data tests are failing, but not by obscene
margins (< 100 EPS). These failures will be addressed when the test
tolerances are finalized.

* Add small-tau tests and simplify Jacobi Theta code [CI SKIP]

Add tests for small tau (i.e. large q). The tests are failing with mean
~ 200 EPS and max ~ 800 EPS. These look like worst-case input, and
should be the focus of future accuracy improvements.

This commit also simplifies the _IMAGINARY code by abstracting all of
the loops into a single svelte function.

* Add user documentation for Jacobi Theta functions [CI SKIP]

* Add function graphs to Jacobi Theta docs [CI SKIP]

* Define Jacobi Theta test tolerances [CI SKIP]

* Add implementation note on Jacobi theta functions [CI SKIP]

* Consolidate Jacobi Theta ULPs plotting programs [CI SKIP]

* Fix q domain checking of jacobi_theta4 [CI SKIP]

* Add ULPs plots to Jacobi Theta docs [CI SKIP]

Also add the built HTML files for easy evaluation. A full rebuild is
needed for the new docs to appear in the indexes.

* Add missing Jacobi Theta ULPs plots [CI SKIP]

* Add LaTeX source for Jacobi Theta equations [CI SKIP]

* Remove unused Jacobi Theta PNG equations [CI SKIP]

* Add Jacobi Theta performance script [CI SKIP]

Provided by @NAThompson.

* Remove vestigial eps*eps check from jacobi_theta3 [CI SKIP]

* Update Jacobi Theta docs per code review comments [CI SKIP]

* Enable arg promotion for Jacobi Theta functions [CI SKIP]

Add Jacobi theta functions to the instantiation tests and fix up
everything needed to make them pass. This changes the function
signatures to use promote_args.

* Fix Jacobi Theta plotting script [CI SKIP]

This script broke when the promote_args API was added.

* Change Jacobi Theta convergence criterion [CI SKIP]

Compare the non-oscillating part of the delta to the previous one.
This avoids some headaches comparing the delta to the partial sum,
because the partial sum can be a small number due to the oscillating
component alternating signs.

Because successive terms involve either q^n^2 or exp(-(pi*n)^2),
convergence should still happen pretty quickly. Graphs have been updated
and tests still passs with no noticeable difference.
2020-08-15 18:51:47 -04:00
jzmaddock
df91e5a1c0 Add erf ulp plots to Jamfile.v2
[CI SKIP]
2020-08-15 15:36:02 +01:00
jzmaddock
2b428c94e5 Add new erf/erfc plots to docs.
[CI SKIP]
2020-08-15 12:41:30 +01:00
Matt Borland
c63f1f13bc Added wheel class [WIP][CI SKIP] 2020-08-14 23:06:08 -05:00
jzmaddock
9bcb6be085 Update multiprecision erf to improve precision and performance.
See https://github.com/boostorg/multiprecision/issues/264.
2020-08-13 18:12:51 +01:00
jzmaddock
6d1d46720f Improve ulps plot: (#417)
* Improve ulps plot:

- Use numeric_limits for precision comparison, plot out of bounds points at the clip boundary so we can still see that they're there.
-Add options for colored marks when clipping and NaN.
2020-08-11 11:44:32 -04:00