Skip to content

Commit

Permalink
Add procedures first-kind-bessel and second-kind-bessel
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 7fe4bf0 commit dd78f5b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 9 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.295.so` and executable `meevax`.
| `all` | Build shared-library `libmeevax.0.5.296.so` and executable `meevax`.
| `install` | Copy files into `/usr/local` directly.
| `package` | Generate debian package `meevax_0.5.295_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.295_amd64.deb`.
| `package` | Generate debian package `meevax_0.5.296_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.296_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.295
0.5.296
10 changes: 8 additions & 2 deletions basis/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
cosh
e
euler
first-kind-bessel
gamma
load-exponent
log-gamma
next-after
phi
pi
second-kind-bessel
sinh
tanh
)
Expand Down Expand Up @@ -122,8 +124,8 @@

flquotient flremainder flremquo

flgamma flloggamma
; flfirst-bessel flsecond-bessel flerf flerfc
flgamma flloggamma flfirst-bessel flsecond-bessel
; flerf flerfc
)

(begin (define fl-e e)
Expand Down Expand Up @@ -389,5 +391,9 @@
(values (log-gamma x)
(if (positive? (gamma x)) 1.0 -1.0)))

(define flfirst-bessel first-kind-bessel)

(define flsecond-bessel second-kind-bessel)

)
)
4 changes: 4 additions & 0 deletions include/meevax/kernel/number.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ inline namespace number
auto copy_sign(object const&, object const&) -> object;

auto next_after(object const&, object const&) -> object;

auto first_kind_bessel(object const&, object const&) -> object;

auto second_kind_bessel(object const&, object const&) -> object;
} // namespace number
} // namespace kernel
} // namespace meevax
Expand Down
10 changes: 10 additions & 0 deletions src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,16 @@ namespace meevax::inline kernel
return load_exponent(car(xs), cadr(xs));
});

library.define<procedure>("first-kind-bessel", [](let const& xs)
{
return first_kind_bessel(car(xs), cadr(xs));
});

library.define<procedure>("second-kind-bessel", [](let const& xs)
{
return second_kind_bessel(car(xs), cadr(xs));
});

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

library.define<double>("pi", std::numbers::pi);
Expand Down
8 changes: 5 additions & 3 deletions src/kernel/number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,10 @@ inline namespace number
return apply_to<real_numbers>(f, x, y); \
}

DEFINE_REAL2(atan, std::atan2)
DEFINE_REAL2(copy_sign, std::copysign)
DEFINE_REAL2(next_after, std::nextafter)
DEFINE_REAL2(atan, std::atan2)
DEFINE_REAL2(copy_sign, std::copysign)
DEFINE_REAL2(first_kind_bessel, std::cyl_bessel_j)
DEFINE_REAL2(next_after, std::nextafter)
DEFINE_REAL2(second_kind_bessel, std::cyl_neumann)
} // namespace number
} // namespace meevax::kernel
22 changes: 21 additions & 1 deletion test/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,26 @@
(call-with-values (lambda () (flloggamma 1.0)) (lambda (value sign) (check value => 0.0) (check sign => 1.0)))
(call-with-values (lambda () (flloggamma +inf.0)) (lambda (value sign) (check value => +inf.0) (check sign => 1.0)))

(check (flfirst-bessel 0.0 (* 0/3 fl-pi)) => 1.0)
(check (flfirst-bessel 0.0 (* 1/3 fl-pi)) => 0.74407197075292975)
(check (flfirst-bessel 0.0 (* 2/3 fl-pi)) => 0.16979382182100766)
(check (flfirst-bessel 0.5 (* 0/3 fl-pi)) => 0.0)
(check (flfirst-bessel 0.5 (* 1/3 fl-pi)) => 0.67523723711782946)
(check (flfirst-bessel 0.5 (* 2/3 fl-pi)) => 0.47746482927568606)
(check (flfirst-bessel 1.0 (* 0/3 fl-pi)) => 0.0)
(check (flfirst-bessel 1.0 (* 1/3 fl-pi)) => 0.45503061147236740)
(check (flfirst-bessel 1.0 (* 2/3 fl-pi)) => 0.56886896392288921)

(check (flsecond-bessel 0.0 (* 0/3 fl-pi)) => -inf.0)
(check (flsecond-bessel 0.0 (* 1/3 fl-pi)) => 0.12417445819941761)
(check (flsecond-bessel 0.0 (* 2/3 fl-pi)) => 0.51799555016845289)
(check (flsecond-bessel 0.5 (* 0/3 fl-pi)) => -inf.0)
(check (flsecond-bessel 0.5 (* 1/3 fl-pi)) => -0.38984840061683823)
(check (flsecond-bessel 0.5 (* 2/3 fl-pi)) => 0.27566444771089593)
(check (flsecond-bessel 1.0 (* 0/3 fl-pi)) => -inf.0)
(check (flsecond-bessel 1.0 (* 1/3 fl-pi)) => -0.74108949656080647)
(check (flsecond-bessel 1.0 (* 2/3 fl-pi)) => -0.05472495339562021)

(check-report)

(exit (check-passed? 232))
(exit (check-passed? 250))

0 comments on commit dd78f5b

Please sign in to comment.