simon-git: spigot (master): spigot.git

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Wed Nov 2 22:51:13 GMT 2016


TL;DR:
  9270e53 Implement a two-operand variant of log().

Repository:     https://git.tartarus.org/simon/spigot.git
On the web:     https://git.tartarus.org/?p=simon/spigot.git
Branch updated: master
Committer:      spigot.git
Date:           2016-11-02 22:51:13

commit 9270e537516ed36d794a39e785fbf652cb71fa6d
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=9270e537516ed36d794a39e785fbf652cb71fa6d;hp=2793ace18dca363201040a20dc07247752af17da
Author: Simon Tatham <anakin at pobox.com>
Date:   Wed Nov 2 22:47:12 2016 +0000

    Implement a two-operand variant of log().
    
    As I mentioned in the previous commit message, this is a user-facing
    function generalising the improvement I just made to log2 and log10:
    log(a,b) gives you log of a to the base b, i.e. log(a)/log(b), except
    that in any case where a,b are rational and a is a rational power of
    b, it should detect that and return the exact rational in question.
    
    An algorithm for finding that rational if it exists, even in the
    trickiest cases such as log of 25/9 to the base 27/125 being -2/3,
    turns out to be surprisingly simple - I was expecting it to be
    intractable, but actually it's a quite straightforward modification of
    Euclid. (And has to be called 'Euclid's Logarithm', surely!) So I've
    completely removed the old method of detecting exact powers of 2 or 10
    by actually constructing a spigot to take log of them, and instead
    log2 and log10 are just special cases of the new function.

 exp.cpp     | 243 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 expr.cpp    |   2 +-
 funcs.h     |   2 +
 manpage.but |   3 +-
 manual.but  |   5 ++
 test.sh     |  14 ++++
 6 files changed, 231 insertions(+), 38 deletions(-)



More information about the tartarus-commits mailing list