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) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 16447e7..038b115 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,8 +24,8 @@ endfunction() add_subdirectory(exp_int) add_subdirectory(gamma) -# add_subdirectory(error) +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); +} 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); +} 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); +} 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); +} 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); +}