simon-git: spigot (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Tue Aug 27 21:28:44 BST 2019


TL;DR:
  3d22779 Factor out new function match_dyadic_rationals().
  1ac8b1c Factor out new function intersect_intervals().
  27355fa lambertw, erfinv: move setup code into classlets.
  78bd2e3 bi_internal: fix semantics of right-shift of negative numbers.
  ecaafd0 New inverse-function system, NewtonInverter.
  189fa0e Migrate Lambert W function to use NewtonInverter.
  ac2565d Migrate inverse erf and phi to use NewtonInverter.
  9658af8 Lengthen test cases for the reworked inverse functions.

Repository:     https://git.tartarus.org/simon/spigot.git
On the web:     https://git.tartarus.org/?p=simon/spigot.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2019-08-27 21:28:44

commit 3d22779ae67d9a67b9715f45b57b51ff84c25f6a
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=3d22779ae67d9a67b9715f45b57b51ff84c25f6a;hp=7d049000e69c16f0fcff91ecf2c4af8de39c0569
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Aug 26 13:42:33 2019 +0100

    Factor out new function match_dyadic_rationals().
    
    There are several places in the code where I have rational numbers in
    the form of a bigint numerator and an unsigned denominator denoting a
    power of 2, and need to put them over a common denominator. There will
    soon be more still of those. So here's a new function which factors
    that common operation out into somewhere that it can be reused
    conveniently, applying to any number of values.

 holefiller.cpp | 10 ++-----
 hypergeom.cpp  |  4 +--
 monotone.cpp   | 13 ++------
 spigot.cpp     | 14 +++------
 spigot.h       | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 102 insertions(+), 32 deletions(-)

commit 1ac8b1cbe04ed5f3ef05212e6283a2d6f13b6814
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=1ac8b1cbe04ed5f3ef05212e6283a2d6f13b6814;hp=3d22779ae67d9a67b9715f45b57b51ff84c25f6a
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Aug 26 13:42:46 2019 +0100

    Factor out new function intersect_intervals().
    
    This is only used in one place at the moment - the centralised
    monotonicity-checker in BinaryIntervalSource - but I'm going to want
    to use it again elsewhere, so let's factor it out too.

 spigot.cpp |  5 +----
 spigot.h   | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

commit 27355fac5c288ba90676b25bed4936f910b0a3f5
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=27355fac5c288ba90676b25bed4936f910b0a3f5;hp=1ac8b1cbe04ed5f3ef05212e6283a2d6f13b6814
Author: Simon Tatham <anakin at pobox.com>
Date:   Mon Aug 26 16:00:38 2019 +0100

    lambertw, erfinv: move setup code into classlets.
    
    The entire point of this is that the classlets get to inherit from
    Debuggable, like AlgebraicPrep does, so that their diagnostic
    statements don't have to be commented out any more but can be enabled
    selectively at run time just like all the other dprints in this code.
    No functional change other than that enhanced debuggability.

 erf.cpp      | 33 ++++++++++++++++++++++++-------
 lambertw.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 76 insertions(+), 20 deletions(-)

commit 78bd2e3bebe20e9c2786ce7db896a4da4be10a68
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=78bd2e3bebe20e9c2786ce7db896a4da4be10a68;hp=27355fac5c288ba90676b25bed4936f910b0a3f5
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Aug 27 21:06:21 2019 +0100

    bi_internal: fix semantics of right-shift of negative numbers.
    
    In spigot's bigints, right-shifting a negative number is supposed to
    round towards -inf, as it would in the bounded integers implemented by
    a typical CPU's right-shift operation.
    
    In bi_gmp, that was already true, because we were doing it by calling
    mpz_fdiv_q_2exp, where the 'f' in fdiv stands for 'floor'. But in
    bi_internal, we were truncating the magnitude integer towards zero,
    regardless of sign. Now we're doing it the same way in both systems.

 bi_internal.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

commit ecaafd090107e24b50ff58e57e3b7eaa2bf34385
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=ecaafd090107e24b50ff58e57e3b7eaa2bf34385;hp=78bd2e3bebe20e9c2786ce7db896a4da4be10a68
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Aug 27 20:59:13 2019 +0100

    New inverse-function system, NewtonInverter.
    
    This is much faster than the existing MonotoneInverter, because
    instead of doing tedious binary-chop style searching one bit at a
    time, it uses the derivative of the function being inverted, so it
    should have the same property as Newton-Raphson of accelerating its
    convergence further every time it goes round the main loop (at least
    assuming f' is continuous).
    
    The actual technique is a modified form of N-R which returns a
    guaranteed bounding interval at each step, instead of just a single
    convergent sequence of real numbers. Full comments are in the header
    in inverter.cpp.
    
    This commit only introduces the new inverter facility, and doesn't
    actually start using it. When I've switched over the current clients
    of MonotoneInverter, I plan to leave it in the code in case it's
    needed again: some day I may want to invert a function that _isn't_
    continuously or even boundedly differentiable, and then it may still
    be the best choice.

 funcs.h      |  28 ++++++
 inverter.cpp | 321 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sources.mk   |   2 +-
 3 files changed, 350 insertions(+), 1 deletion(-)

commit 189fa0eb5eca4bd0f68df2d9b2bce5921d5efbb0
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=189fa0eb5eca4bd0f68df2d9b2bce5921d5efbb0;hp=ecaafd090107e24b50ff58e57e3b7eaa2bf34385
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Aug 27 21:02:49 2019 +0100

    Migrate Lambert W function to use NewtonInverter.
    
    This greatly speeds up computation of W. However, one point where it's
    still a bit slow is the stationary point at (-1,-1/e); if you ask for
    W(-1/e) itself, then convergence is slow, and W(-1/e+epsilon) is slow
    until the bounding interval manages to stop containing -1, at which
    point it speeds up again. But it's already a big improvement on the
    previous W implementation.

 lambertw.cpp | 275 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 228 insertions(+), 47 deletions(-)

commit ac2565d04e9799124d282f765364844288846cfb
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=ac2565d04e9799124d282f765364844288846cfb;hp=189fa0eb5eca4bd0f68df2d9b2bce5921d5efbb0
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Aug 27 21:05:02 2019 +0100

    Migrate inverse erf and phi to use NewtonInverter.
    
    Unlike W, this function has no inconvenient stationary point, so it's
    much improved across the board.
    
    I've taken the opportunity to rework the central inversion function so
    that it's inverting ErfBase (that is, the plain integral of exp(-x^2)
    with no scaling factors), and scaled that appropriately for the
    various user-facing functions.

 erf.cpp | 273 +++++++++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 184 insertions(+), 89 deletions(-)

commit 9658af8a95844a2873ec37b2add908b5d4414e33
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=9658af8a95844a2873ec37b2add908b5d4414e33;hp=ac2565d04e9799124d282f765364844288846cfb
Author: Simon Tatham <anakin at pobox.com>
Date:   Tue Aug 27 21:07:55 2019 +0100

    Lengthen test cases for the reworked inverse functions.
    
    There's no need to compute 10 digits instead of 70 in the test suite
    any more, because 70 can actually be managed in a sensible length of
    time!

 test.sh | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)



More information about the tartarus-commits mailing list