diff --git a/README.md b/README.md index febdf0941..f35c4a43e 100644 --- a/README.md +++ b/README.md @@ -97,9 +97,9 @@ Then, select one of the following targets and `make` it according to your purpos | Target | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.292.so` and executable `meevax`. +| `all` | Build shared-library `libmeevax.0.5.293.so` and executable `meevax`. | `install` | Copy files into `/usr/local` directly. -| `package` | Generate debian package `meevax_0.5.292_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.292_amd64.deb`. +| `package` | Generate debian package `meevax_0.5.293_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.293_amd64.deb`. | `test` | Test executable `meevax`. This target requires Valgrind to be installed. | `uninstall` | Remove files copied to `/usr/local` directly by target `install`. diff --git a/VERSION b/VERSION index d9d175dac..46f9dddd7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.292 +0.5.293 diff --git a/basis/srfi-144.ss b/basis/srfi-144.ss index 283145981..480a6ea93 100644 --- a/basis/srfi-144.ss +++ b/basis/srfi-144.ss @@ -13,6 +13,7 @@ binary64-integral-part binary64-least binary64-log-binary + binary64-log1p binary64-max binary64-min binary64-normalized-fraction @@ -56,6 +57,7 @@ or positive? round + square truncate values zero? @@ -94,9 +96,9 @@ flmax flmin fl+ fl* fl+* fl- fl/ flabs flabsdiff flposdiff flsgn flnumerator fldenominator flfloor flceiling flround fltruncate - flexp flexp2 flexp-1 - ; flsquare flsqrt flcbrt flhypot flexpt fllog - ; fllog1+ fllog2 fllog10 make-fllog-base + flexp flexp2 flexp-1 flsquare flsqrt flcbrt flhypot flexpt fllog + fllog1+ + ; fllog2 fllog10 make-fllog-base ; ; flsin flcos fltan flasin flacos flatan ; flsinh flcosh fltanh flasinh flacosh flatanh @@ -303,5 +305,22 @@ (expt 2 x)) (define flexp-1 binary64-expm1) + + (define flsquare square) + + (define flsqrt sqrt) + + (define (flcbrt x) + (expt x (/ 1 3))) + + (define (flhypot x y) + (sqrt (+ (square x) + (square y)))) + + (define flexpt expt) + + (define fllog log) + + (define fllog1+ binary64-log1p) ) ) diff --git a/src/kernel/boot.cpp b/src/kernel/boot.cpp index 22f0c4940..b12a018e1 100644 --- a/src/kernel/boot.cpp +++ b/src/kernel/boot.cpp @@ -685,6 +685,11 @@ namespace meevax::inline kernel { return make(std::expm1(car(xs).as())); }); + + library.define("binary64-log1p", [](let const& xs) + { + return make(std::log1p(car(xs).as())); + }); }); define("(meevax list)", [](library & library) diff --git a/test/srfi-144.ss b/test/srfi-144.ss index 71d3014c8..338271194 100644 --- a/test/srfi-144.ss +++ b/test/srfi-144.ss @@ -1,4 +1,5 @@ (import (scheme base) + (scheme inexact) (scheme process-context) (srfi 78) (srfi 144)) @@ -261,6 +262,84 @@ (check (fl+ 1.0 (flexp-1 fl-least)) => 1.0) +(check (flsquare -0.0) => 0.0) + +(check (flsquare 0.0) => 0.0) + +(check (flsquare 1.0) => 1.0) + +(check (flsquare 2.0) => 4.0) + +(check (flsqrt -0.0) => -0.0) + +(check (flsqrt 0.0) => 0.0) + +(check (flsqrt 1.0) => 1.0) + +(check (flsqrt 2.0) => fl-sqrt-2) + +(check (flsqrt 3.0) => fl-sqrt-3) + +(check (flsqrt 5.0) => fl-sqrt-5) + +(check (flsqrt 10.0) => fl-sqrt-10) + +(check (flcbrt 0.0) => 0.0) + +(check (flcbrt 1.0) => 1.0) + +(check (flcbrt 1.0) => 1.0) + +(check (flcbrt 2.0) => fl-cbrt-2) + +(check (flcbrt 3.0) => fl-cbrt-3) + +(check (flhypot 0.0 0.0) => 0.0) + +(check (flhypot 0.0 1.0) => 1.0) + +(check (flhypot 0.0 -1.0) => 1.0) + +(check (flhypot 1.0 1.0) => fl-sqrt-2) + +(check (flhypot 1.0 2.0) => fl-sqrt-5) + +(check (flhypot 1.0 3.0) => fl-sqrt-10) + +(check (flexpt 0.0 0.0) => 1.0) + +(check (flexpt 1.0 0.0) => 1.0) + +(check (flexpt 2.0 1.0) => 2.0) + +(check (flexpt 2.0 2.0) => 4.0) + +(check (flexpt 2.0 3.0) => 8.0) + +(check (fllog 0.0) => -inf.0) + +(check (fllog 1.0) => 0.0) + +(check (fllog fl-phi) => fl-log-phi) + +(check (fllog 2.0) => fl-log-2) + +(check (fllog 3.0) => fl-log-3) + +(check (fllog fl-pi) => fl-log-pi) + +(check (fllog 10.0) => fl-log-10) + +(check (fllog1+ 0.0) => 0.0) + +(check (fllog1+ fl-least) (=> =) 0.0) + +(check (fllog1+ 1.0) => fl-log-2) + +(check (fllog1+ 2.0) (=> =) fl-log-3) + +(check (fllog1+ 9.0) => fl-log-10) + (check-report) -(exit (check-passed? 127)) +(exit (check-passed? 166))