Skip to content

Commit

Permalink
Add procedure binary64-log1p
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Dec 15, 2024
1 parent 9aad201 commit 13c3ca1
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.292
0.5.293
25 changes: 22 additions & 3 deletions basis/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
binary64-integral-part
binary64-least
binary64-log-binary
binary64-log1p
binary64-max
binary64-min
binary64-normalized-fraction
Expand Down Expand Up @@ -56,6 +57,7 @@
or
positive?
round
square
truncate
values
zero?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
)
5 changes: 5 additions & 0 deletions src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,11 @@ namespace meevax::inline kernel
{
return make(std::expm1(car(xs).as<double>()));
});

library.define<procedure>("binary64-log1p", [](let const& xs)
{
return make(std::log1p(car(xs).as<double>()));
});
});

define<library>("(meevax list)", [](library & library)
Expand Down
81 changes: 80 additions & 1 deletion test/srfi-144.ss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(import (scheme base)
(scheme inexact)
(scheme process-context)
(srfi 78)
(srfi 144))
Expand Down Expand Up @@ -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))

0 comments on commit 13c3ca1

Please sign in to comment.