From f4182ff03eff77450fba7edf6a3da09576099cd2 Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 9 Dec 2024 11:59:24 +0800 Subject: [PATCH 1/6] test.misc: init misc tests --- tests/misc/CMakeLists.txt | 5 +++++ tests/misc/spence.cpp | 14 ++++++++++++++ tests/misc/zeta.cpp | 10 ++++++++++ tests/misc/zetac.cpp | 10 ++++++++++ 4 files changed, 39 insertions(+) create mode 100644 tests/misc/spence.cpp create mode 100644 tests/misc/zeta.cpp create mode 100644 tests/misc/zetac.cpp diff --git a/tests/misc/CMakeLists.txt b/tests/misc/CMakeLists.txt index b25b468..330bd0d 100644 --- a/tests/misc/CMakeLists.txt +++ b/tests/misc/CMakeLists.txt @@ -1,2 +1,7 @@ +add_gtest(spence) + +add_gtest(zeta) +add_gtest(zetac) + add_gtest(struve) diff --git a/tests/misc/spence.cpp b/tests/misc/spence.cpp new file mode 100644 index 0000000..7ce210e --- /dev/null +++ b/tests/misc/spence.cpp @@ -0,0 +1,14 @@ +#include +#include + +/* + +*/ +TEST(Spence, Branches) { + // x < 0 + EXPECT_REL_NEAR_F64(cephes::spence(-1.0), 0.0); + // x == 1.0 + EXPECT_REL_NEAR_F64(cephes::spence(1.0), 0.0); + // x == 0.0 + // EXPECT_REL_NEAR_F64(cephes::spence(0.0), pi*pi/6.0); +} diff --git a/tests/misc/zeta.cpp b/tests/misc/zeta.cpp new file mode 100644 index 0000000..e769a19 --- /dev/null +++ b/tests/misc/zeta.cpp @@ -0,0 +1,10 @@ +#include +#include + +/* + +*/ +TEST(Zeta, Branches) { + // x == 1.0 + EXPECT_GT(cephes::zeta(1.0, 1.0), 1e308); +} diff --git a/tests/misc/zetac.cpp b/tests/misc/zetac.cpp new file mode 100644 index 0000000..f6093cc --- /dev/null +++ b/tests/misc/zetac.cpp @@ -0,0 +1,10 @@ +#include +#include + +/* + +*/ +TEST(ZetaC, Branches) { + // x < -170.6243 + EXPECT_REL_NEAR_F64(cephes::zetac(-175.0), 0.0); +} From 409bb024238da3c1ec2117df82aac576ed6b6c68 Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 9 Dec 2024 12:03:50 +0800 Subject: [PATCH 2/6] test: init hyper\hyperg --- tests/hyper/CMakeLists.txt | 1 + tests/hyper/hyperg.cpp | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 tests/hyper/hyperg.cpp diff --git a/tests/hyper/CMakeLists.txt b/tests/hyper/CMakeLists.txt index d1736d0..778bb75 100644 --- a/tests/hyper/CMakeLists.txt +++ b/tests/hyper/CMakeLists.txt @@ -1,2 +1,3 @@ add_gtest(hyp2f1) +add_gtest(hyperg) diff --git a/tests/hyper/hyperg.cpp b/tests/hyper/hyperg.cpp new file mode 100644 index 0000000..e19a09c --- /dev/null +++ b/tests/hyper/hyperg.cpp @@ -0,0 +1,7 @@ +#include +#include + + +TEST(Hyp2f1, Branches) { + EXPECT_GT(cephes::hyperg(1.0, 2.0, 3.0), 0.0); +} From 70ab46b42d7bbe0c461fff9eb02a0b3aad3aaa4f Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 9 Dec 2024 12:10:53 +0800 Subject: [PATCH 3/6] test: init gamma: incbi,incbet --- tests/gamma/CMakeLists.txt | 4 ++-- tests/gamma/incbet.cpp | 12 ++++++++++++ tests/gamma/incbi.cpp | 11 +++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/gamma/incbet.cpp create mode 100644 tests/gamma/incbi.cpp diff --git a/tests/gamma/CMakeLists.txt b/tests/gamma/CMakeLists.txt index 42c6208..edae511 100644 --- a/tests/gamma/CMakeLists.txt +++ b/tests/gamma/CMakeLists.txt @@ -6,8 +6,8 @@ add_gtest(lgam) add_gtest(igam) add_gtest(igamc) add_gtest(igami) -# add_gtest(incbet) -# add_gtest(incbi) +add_gtest(incbet) +add_gtest(incbi) add_gtest(psi) add_gtest(rgamma) diff --git a/tests/gamma/incbet.cpp b/tests/gamma/incbet.cpp new file mode 100644 index 0000000..f1ff242 --- /dev/null +++ b/tests/gamma/incbet.cpp @@ -0,0 +1,12 @@ +#include +#include + + +TEST(BetaInc, BasicAssertions) { + +} +TEST(BetaInc, Branches) { + // aa <= 0.0 || bb <= 0.0 + EXPECT_REL_NEAR_F64(cephes::incbet(0.0, 1.0, 1.0), 0.0); + EXPECT_REL_NEAR_F64(cephes::incbet(1.0, 0.0, 1.0), 0.0); +} diff --git a/tests/gamma/incbi.cpp b/tests/gamma/incbi.cpp new file mode 100644 index 0000000..5f28aa3 --- /dev/null +++ b/tests/gamma/incbi.cpp @@ -0,0 +1,11 @@ +#include +#include + + +TEST(BetaIncInv, BasicAssertions) { + +} +TEST(BetaIncInv, Branches) { + // yy0 <= 0 + EXPECT_REL_NEAR_F64(cephes::incbi(1.0, 1.0, -1.0), 0.0); +} From e225b28408f765df8258ea1ad60e96951fd7a4a5 Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 9 Dec 2024 12:21:55 +0800 Subject: [PATCH 4/6] test: init error: erf,erfc,ndtr,fresnl,dawsn --- tests/CMakeLists.txt | 2 +- tests/error/CMakeLists.txt | 7 +++++++ tests/error/dawsn.cpp | 7 +++++++ tests/error/erf.cpp | 8 ++++++++ tests/error/erfc.cpp | 8 ++++++++ tests/error/fresnl.cpp | 9 +++++++++ tests/error/ndtr.cpp | 7 +++++++ 7 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/error/CMakeLists.txt create mode 100644 tests/error/dawsn.cpp create mode 100644 tests/error/erf.cpp create mode 100644 tests/error/erfc.cpp create mode 100644 tests/error/fresnl.cpp create mode 100644 tests/error/ndtr.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 16447e7..1bf6a27 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,7 +24,7 @@ endfunction() add_subdirectory(exp_int) add_subdirectory(gamma) -# add_subdirectory(error) +add_subdirectory(error) add_subdirectory(bessel) add_subdirectory(hyper) # add_subdirectory(elliptic) diff --git a/tests/error/CMakeLists.txt b/tests/error/CMakeLists.txt new file mode 100644 index 0000000..4a5bc86 --- /dev/null +++ b/tests/error/CMakeLists.txt @@ -0,0 +1,7 @@ + +add_gtest(erf) +add_gtest(erfc) +add_gtest(ndtr) + +add_gtest(dawsn) +add_gtest(fresnl) diff --git a/tests/error/dawsn.cpp b/tests/error/dawsn.cpp new file mode 100644 index 0000000..ce14dc5 --- /dev/null +++ b/tests/error/dawsn.cpp @@ -0,0 +1,7 @@ +#include +#include + + +TEST(Dawson, Branches) { + EXPECT_GT(cephes::dawsn(1.0), 0.0); +} diff --git a/tests/error/erf.cpp b/tests/error/erf.cpp new file mode 100644 index 0000000..1982b3f --- /dev/null +++ b/tests/error/erf.cpp @@ -0,0 +1,8 @@ +#include +#include + + +TEST(Erf, Branches) { + // fabs(x) > 1.0 + EXPECT_REL_NEAR_F64(cephes::erf(20.0), 1.0); +} diff --git a/tests/error/erfc.cpp b/tests/error/erfc.cpp new file mode 100644 index 0000000..ff50e35 --- /dev/null +++ b/tests/error/erfc.cpp @@ -0,0 +1,8 @@ +#include +#include + + +TEST(ErfC, Branches) { + // z < -MAXLOG && a < 0 + EXPECT_REL_NEAR_F64(cephes::erfc(-20.0), 2.0); +} diff --git a/tests/error/fresnl.cpp b/tests/error/fresnl.cpp new file mode 100644 index 0000000..4193b96 --- /dev/null +++ b/tests/error/fresnl.cpp @@ -0,0 +1,9 @@ +#include +#include + + +TEST(Fresnel, Branches) { + double x, s, c; + + EXPECT_REL_NEAR_F64(cephes::fresnl(1.0, &s, &c), 0.0); +} diff --git a/tests/error/ndtr.cpp b/tests/error/ndtr.cpp new file mode 100644 index 0000000..d8be250 --- /dev/null +++ b/tests/error/ndtr.cpp @@ -0,0 +1,7 @@ +#include +#include + + +TEST(ndtr, Branches) { + EXPECT_GT(cephes::ndtr(0.1), 0.0); +} From 8086404bfedfe5c7e8633580085850695f13d440 Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 9 Dec 2024 12:49:16 +0800 Subject: [PATCH 5/6] test.elliptic: init tests --- tests/CMakeLists.txt | 2 +- tests/elliptic/CMakeLists.txt | 7 +++++++ tests/elliptic/ellie.cpp | 8 ++++++++ tests/elliptic/ellik.cpp | 8 ++++++++ tests/elliptic/ellpe.cpp | 8 ++++++++ tests/elliptic/ellpj.cpp | 11 +++++++++++ tests/elliptic/ellpk.cpp | 9 +++++++++ 7 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/elliptic/CMakeLists.txt create mode 100644 tests/elliptic/ellie.cpp create mode 100644 tests/elliptic/ellik.cpp create mode 100644 tests/elliptic/ellpe.cpp create mode 100644 tests/elliptic/ellpj.cpp create mode 100644 tests/elliptic/ellpk.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1bf6a27..038b115 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,5 +27,5 @@ add_subdirectory(gamma) add_subdirectory(error) add_subdirectory(bessel) add_subdirectory(hyper) -# add_subdirectory(elliptic) +add_subdirectory(elliptic) add_subdirectory(misc) diff --git a/tests/elliptic/CMakeLists.txt b/tests/elliptic/CMakeLists.txt new file mode 100644 index 0000000..eed4848 --- /dev/null +++ b/tests/elliptic/CMakeLists.txt @@ -0,0 +1,7 @@ + +add_gtest(ellpk) +add_gtest(ellik) +add_gtest(ellpe) +add_gtest(ellie) + +add_gtest(ellpj) diff --git a/tests/elliptic/ellie.cpp b/tests/elliptic/ellie.cpp new file mode 100644 index 0000000..82dc202 --- /dev/null +++ b/tests/elliptic/ellie.cpp @@ -0,0 +1,8 @@ +#include +#include + + +TEST(EllipticEInc, Branches) { + // m == 0.0 + EXPECT_REL_NEAR_F64(cephes::ellie(3.0, 0.0), 3.0); +} diff --git a/tests/elliptic/ellik.cpp b/tests/elliptic/ellik.cpp new file mode 100644 index 0000000..0deedca --- /dev/null +++ b/tests/elliptic/ellik.cpp @@ -0,0 +1,8 @@ +#include +#include + + +TEST(EllipticKInc, Branches) { + // m == 0.0 + EXPECT_REL_NEAR_F64(cephes::ellik(3.0, 0.0), 3.0); +} diff --git a/tests/elliptic/ellpe.cpp b/tests/elliptic/ellpe.cpp new file mode 100644 index 0000000..d2157bb --- /dev/null +++ b/tests/elliptic/ellpe.cpp @@ -0,0 +1,8 @@ +#include +#include + + +TEST(EllipticE, Branches) { + // x == 0.0 + EXPECT_REL_NEAR_F64(cephes::ellpe(0.0), 1.0); +} diff --git a/tests/elliptic/ellpj.cpp b/tests/elliptic/ellpj.cpp new file mode 100644 index 0000000..497c23d --- /dev/null +++ b/tests/elliptic/ellpj.cpp @@ -0,0 +1,11 @@ +#include +#include + + +TEST(EllipticJaco, Branches) { + double u, m, sn, cn, dn, ph; + // m < 0.0 || m > 1.0 + u = 1.0; + EXPECT_REL_NEAR_F64(cephes::ellpj(u, -1.0, &sn, &cn, &dn, &ph), -1); + EXPECT_REL_NEAR_F64(cephes::ellpj(u, 2.0, &sn, &cn, &dn, &ph), -1); +} diff --git a/tests/elliptic/ellpk.cpp b/tests/elliptic/ellpk.cpp new file mode 100644 index 0000000..3a569b8 --- /dev/null +++ b/tests/elliptic/ellpk.cpp @@ -0,0 +1,9 @@ +#include +#include + + +TEST(EllipticK, Branches) { + // (x < 0.0) || (x > 1.0) + EXPECT_REL_NEAR_F64(cephes::ellpk(-1.0), 0.0); + EXPECT_REL_NEAR_F64(cephes::ellpk(2.0), 0.0); +} From 412cd82ddf1c6ec354a7b981a640815d05b41a7b Mon Sep 17 00:00:00 2001 From: Chengyu HAN Date: Mon, 9 Dec 2024 12:50:46 +0800 Subject: [PATCH 6/6] doc: update doc TOC --- README.md | 11 +++++++++-- doc/markdown/bessel.md | 2 +- doc/markdown/exp_int.md | 2 +- doc/markdown/hyper.md | 4 +--- doc/markdown/misc.md | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 945e5d6..bf43f40 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,18 @@ Therefore, contributions regarding precision and error-related contributions are > which is a header-only library containing a modernized (C++17) refactoring of > the classic `AMOS/SPECFUN/Cephes/...` special function implementations. + ## Docs [List of Cephes functions](doc/markdown/index.md) -- [bessel](doc/markdown/bessel.md) -- [exp_int](doc/markdown/exp_int.md) +- [Exponential integral](doc/markdown/exp_int.md) +- [Gamma functions](doc/markdown/gamma.md) +- [Error functions](doc/markdown/gamma.md) +- [Bessel functions](doc/markdown/bessel.md) +- [Hypergeometric functions](doc/markdown/hyper.md) +- [Elliptic functions](doc/markdown/elliptic.md) +- [Miscellaneous functions](doc/markdown/misc.md) ## Test @@ -31,6 +37,7 @@ cmake -DCMAKE_BUILD_TYPE=Coverage -S . -B build && cmake --build build cd build/ && ctest && make coverage_html ``` + ## License Using a `BSD-3-Clause` like [LICENSE](LICENSE.txt). diff --git a/doc/markdown/bessel.md b/doc/markdown/bessel.md index a59fb7b..671827e 100644 --- a/doc/markdown/bessel.md +++ b/doc/markdown/bessel.md @@ -1,4 +1,4 @@ -# cephes/bessel +# Bessel functions ## Airy Functions diff --git a/doc/markdown/exp_int.md b/doc/markdown/exp_int.md index b302a65..352f06e 100644 --- a/doc/markdown/exp_int.md +++ b/doc/markdown/exp_int.md @@ -1,4 +1,4 @@ -# cephes/Exponential integral +# Exponential integral * **expn**, [Exponential integral En](doubldoc.md#expn) diff --git a/doc/markdown/hyper.md b/doc/markdown/hyper.md index 4e9fb35..4a9edfe 100644 --- a/doc/markdown/hyper.md +++ b/doc/markdown/hyper.md @@ -1,6 +1,4 @@ -# cephes/hyper - -## Hypergeometric Functions +# Hypergeometric Functions * **hyp2f1**, [Gauss hypergeometric function](doubldoc.md#hyp2f1) * **hyperg**, [Confluent hypergeometric function](doubldoc.md#hyperg) diff --git a/doc/markdown/misc.md b/doc/markdown/misc.md index 040cada..931f11b 100644 --- a/doc/markdown/misc.md +++ b/doc/markdown/misc.md @@ -1,4 +1,4 @@ -# cephes/misc +# Miscellaneous functions * **spence**, [Dilogarithm](doubldoc.md#spence) * **zeta**, [Zeta function of two arguments](doubldoc.md#zeta)