Skip to content

Commit

Permalink
Move binary64- prefixed procedures into library (meevax binary64)
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 9, 2024
1 parent b02e966 commit c854f59
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 40 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.287.so` and executable `meevax`.
| `all` | Build shared-library `libmeevax.0.5.288.so` and executable `meevax`.
| `install` | Copy files into `/usr/local` directly.
| `package` | Generate debian package `meevax_0.5.287_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.287_amd64.deb`.
| `package` | Generate debian package `meevax_0.5.288_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.288_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.287
0.5.288
4 changes: 3 additions & 1 deletion basis/srfi-144.ss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(define-library (srfi 144)
(import (only (meevax inexact)
(import (only (meevax binary64)
FP_FAST_FMA
binary64-denormalized?
binary64-epsilon
Expand All @@ -14,6 +14,8 @@
binary64-normalized?
binary64-sign-bit
binary64?
)
(only (meevax inexact)
copy-sign
e
euler
Expand Down
66 changes: 36 additions & 30 deletions src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,6 @@ namespace meevax::inline kernel

define<library>("(meevax inexact)", [](library & library)
{
library.define<procedure>("binary32?", [](let const& xs)
{
return std::numeric_limits<float>::is_iec559 and car(xs).is<float>();
});

library.define<procedure>("binary64?", [](let const& xs)
{
return std::numeric_limits<double>::is_iec559 and car(xs).is<double>();
});

library.define<procedure>("finite?", [](let const& xs)
{
return is_finite(car(xs));
Expand Down Expand Up @@ -570,6 +560,42 @@ namespace meevax::inline kernel
return load_exponent(car(xs), cadr(xs));
});

library.define<double>("e", std::numbers::e);

library.define<double>("pi", std::numbers::pi);

library.define<double>("euler", std::numbers::egamma);

library.define<double>("phi", std::numbers::phi);
});

define<library>("(meevax binary32)", [](library & library)
{
library.define<procedure>("binary32?", [](let const& xs)
{
return std::numeric_limits<float>::is_iec559 and car(xs).is<float>();
});
});

define<library>("(meevax binary64)", [](library & library)
{
library.define<procedure>("binary64?", [](let const& xs)
{
return std::numeric_limits<double>::is_iec559 and car(xs).is<double>();
});

library.define<double>("binary64-min", std::numeric_limits<double>::min());

library.define<double>("binary64-max", std::numeric_limits<double>::max());

library.define<double>("binary64-epsilon", std::numeric_limits<double>::epsilon());

#ifdef FP_FAST_FMA
library.define<bool>("FP_FAST_FMA", true);
#else
library.define<bool>("FP_FAST_FMA", false);
#endif

library.define<procedure>("binary64-integral-part", [](let const& xs)
{
auto integral_part = 0.0;
Expand Down Expand Up @@ -620,26 +646,6 @@ namespace meevax::inline kernel
{
return std::fpclassify(car(xs).as<double>()) == FP_SUBNORMAL;
});

library.define<double>("e", std::numbers::e);

library.define<double>("pi", std::numbers::pi);

library.define<double>("euler", std::numbers::egamma);

library.define<double>("phi", std::numbers::phi);

library.define<double>("binary64-max", std::numeric_limits<double>::max());

library.define<double>("binary64-min", std::numeric_limits<double>::min());

library.define<double>("binary64-epsilon", std::numeric_limits<double>::epsilon());

#ifdef FP_FAST_FMA
library.define<bool>("FP_FAST_FMA", true);
#else
library.define<bool>("FP_FAST_FMA", false);
#endif
});

define<library>("(meevax list)", [](library & library)
Expand Down
3 changes: 2 additions & 1 deletion test/number.ss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(import (scheme base)
(scheme inexact)
(scheme process-context)
(only (meevax inexact) binary32? binary64?)
(only (meevax binary32) binary32?)
(only (meevax binary64) binary64?)
(srfi 78)
(srfi 144))

Expand Down
9 changes: 4 additions & 5 deletions test/srfi-144.ss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(import (only (meevax inexact) binary64?)
(scheme base)
(import (scheme base)
(scheme process-context)
(srfi 78)
(srfi 144))
Expand Down Expand Up @@ -82,15 +81,15 @@

(check fl-gamma-2/3 => 1.3541179394264004169452880281545137855193)

(check (binary64? fl-greatest) => #t)
(check (flonum? fl-greatest) => #t)

(check (binary64? fl-least) => #t)
(check (flonum? fl-least) => #t)

(check (< 0.0 0.0) => #f)

(check (< 0.0 fl-least) => #t)

(check (binary64? fl-epsilon) => #t)
(check (flonum? fl-epsilon) => #t)

(check (boolean? fl-fast-fl+*) => #t)

Expand Down

0 comments on commit c854f59

Please sign in to comment.