Skip to content

Commit

Permalink
Merge pull request #5 from Cactus-proj/dev
Browse files Browse the repository at this point in the history
doc, test: init elliptic,error,hyper,misc
inkydragon authored Dec 9, 2024
2 parents 877341b + b392efd commit b7b7754
Showing 24 changed files with 309 additions and 170 deletions.
5 changes: 0 additions & 5 deletions doc/markdown/bessel.md
Original file line number Diff line number Diff line change
@@ -37,8 +37,3 @@
* **k1**, [Modified Bessel function, third kind, order one](doubldoc.md#k1)
* **k1e**, [Modified Bessel function, third kind, order one, exponentially scaled](doubldoc.md#k1e)
* **kn**, [Modified Bessel function, third kind, integer order](doubldoc.md#kn)

## Others

* **psi**, [Psi (digamma) function](doubldoc.md#psi)
* **struve**, [Struve function](doubldoc.md#struve)
7 changes: 7 additions & 0 deletions doc/markdown/elliptic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Elliptic Functions

* **ellpk**, [Complete elliptic integral of the first kind](doubldoc.md#ellpk)
* **ellik**, [Incomplete elliptic integral of the first kind](doubldoc.md#ellik)
* **ellpe**, [Complete elliptic integral of the second kind](doubldoc.md#ellpe)
* **ellie**, [Incomplete elliptic integral of the second kind](doubldoc.md#ellie)
* **ellpj**, [Jacobian elliptic functions](doubldoc.md#ellpj)
7 changes: 7 additions & 0 deletions doc/markdown/error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Error Functions

* **erf**, [Error function](doubldoc.md#erf)
* **erfc**, [Complementary error function](doubldoc.md#erfc)
* **ndtri**, [Inverse of normal distribution function](doubldoc.md#ndtri)
* **dawsn**, [Dawson's Integral](doubldoc.md#dawsn)
* **fresnl**, [Fresnel integral](doubldoc.md#fresnl)
6 changes: 6 additions & 0 deletions doc/markdown/hyper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# cephes/hyper

## Hypergeometric Functions

* **hyp2f1**, [Gauss hypergeometric function](doubldoc.md#hyp2f1)
* **hyperg**, [Confluent hypergeometric function](doubldoc.md#hyperg)
6 changes: 6 additions & 0 deletions doc/markdown/misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# cephes/misc

* **spence**, [Dilogarithm](doubldoc.md#spence)
* **zeta**, [Zeta function of two arguments](doubldoc.md#zeta)
* **zetac**, [Riemann zeta function of two arguments](doubldoc.md#zetac)
* **struve**, [Struve function](doubldoc.md#struve)
8 changes: 0 additions & 8 deletions include/cephes/bessel.h
Original file line number Diff line number Diff line change
@@ -13,10 +13,6 @@ extern "C" {
/** Airy Functions */
int airy(double x, double *ai, double *aip, double *bi, double *bip);

/** Hypergeometric Functions */
double hyp2f1(double a, double b, double c, double x);
double hyperg(double a, double b, double x);

/** Bessel functions */
double j0(double x);
double j1(double x);
@@ -42,10 +38,6 @@ double k1(double x);
double k1e(double x);
double kn(int nn, double x);

/** Others */
double psi(double x);
double struve(double v, double x);

#if defined(__cplusplus)
} // extern "C"
#endif
31 changes: 31 additions & 0 deletions include/cephes/elliptic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef CEPHES_ELLIPTIC_H
/** Cephes double precision special functions suite
*
* cephes/bessel
*/
#define CEPHES_ELLIPTIC_H

namespace cephes {
#if defined(__cplusplus)
extern "C" {
#endif

/** Elliptic Functions */
/* ellf/ellpk.c */
double ellpk(double x);
/* ellf/ellik.c */
double ellik(double phi, double m);
/* ellf/ellpe.c */
double ellpe(double x);
/* ellf/ellie.c */
double ellie(double phi, double m);

/* ellf/ellpj.c */
int ellpj(double u, double m, double *sn, double *cn, double *dn, double *ph);

#if defined(__cplusplus)
} // extern "C"
#endif
}; // ::cephes

#endif // CEPHES_ELLIPTIC_H
29 changes: 29 additions & 0 deletions include/cephes/error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef CEPHES_ERROR_H
/** Cephes double precision special functions suite
*
* cephes/bessel
*/
#define CEPHES_ERROR_H

namespace cephes {
#if defined(__cplusplus)
extern "C" {
#endif

/** Error Functions */
/* cephes/ndtr.c */
double erf(double x);
double erfc(double a);
double ndtr(double a);

/* cephes/dawsn.c */
double dawsn(double xx);
/* cephes/fresnl.c */
int fresnl(double xxa, double *ssa, double *cca);

#if defined(__cplusplus)
} // extern "C"
#endif
}; // ::cephes

#endif // CEPHES_ERROR_H
22 changes: 22 additions & 0 deletions include/cephes/hyper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef CEPHES_HYPER_H
/** Cephes double precision special functions suite
*
* cephes/bessel
*/
#define CEPHES_HYPER_H

namespace cephes {
#if defined(__cplusplus)
extern "C" {
#endif

/** Hypergeometric Functions */
double hyp2f1(double a, double b, double c, double x);
double hyperg(double a, double b, double x);

#if defined(__cplusplus)
} // extern "C"
#endif
}; // ::cephes

#endif // CEPHES_HYPER_H
28 changes: 28 additions & 0 deletions include/cephes/misc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef CEPHES_MISC_H
/** Cephes double precision special functions suite
*
* cephes/misc
*/
#define CEPHES_MISC_H

namespace cephes {
#if defined(__cplusplus)
extern "C" {
#endif

/* misc/spence.c */
double spence(double x);

/* misc/zeta.c */
double zeta(double x, double q);
/* misc/zetac.c */
double zetac(double x);

double struve(double v, double x);

#if defined(__cplusplus)
} // extern "C"
#endif
}; // ::cephes

#endif // CEPHES_MISC_H
6 changes: 5 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -22,6 +22,10 @@ function(add_gtest test_name)
gtest_discover_tests(${test_name})
endfunction()

add_gtest(exp_int)
add_subdirectory(exp_int)
add_subdirectory(gamma)
# add_subdirectory(error)
add_subdirectory(bessel)
add_subdirectory(hyper)
# add_subdirectory(elliptic)
add_subdirectory(misc)
3 changes: 0 additions & 3 deletions tests/bessel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -21,6 +21,3 @@ add_gtest(k0e)
add_gtest(k1)
add_gtest(k1e)
add_gtest(kn)

add_gtest(psi)
add_gtest(struve)
14 changes: 0 additions & 14 deletions tests/bessel/airy.cpp
Original file line number Diff line number Diff line change
@@ -75,17 +75,3 @@ TEST(Airy, Branches) {
XTEST_ISAPPROX_F64(bi);
XTEST_ISAPPROX_F64(bip);
}

TEST(Hyp2f1, Errors) {
double a, b, c, x, y, y_ref;

// c is a negative integer
// hypdiv:
EXPECT_GT(cephes::hyp2f1(2.0, 3.0, -4.0, 5.0), 1e308);
// ax > 1.0
EXPECT_GT(cephes::hyp2f1(2.0, 3.0, 4.0, 2.0), 1e308);
}

TEST(Hyp2f1, Branches) {
double a, b, c, x, y, y_ref;
}
136 changes: 0 additions & 136 deletions tests/exp_int.cpp

This file was deleted.

4 changes: 4 additions & 0 deletions tests/exp_int/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

add_gtest(expn)
add_gtest(sici)
add_gtest(shichi)
32 changes: 32 additions & 0 deletions tests/exp_int/expn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <xtest.hpp>
#include <cephes/exp_int.h>


TEST(ExpN, Errors) {
// n < 0
EXPECT_TRUE(cephes::expn(-1, 10.0) > 1e308);
// x < 0
EXPECT_TRUE(cephes::expn(1, -1.0) > 1e308);
// x > MAXLOG ≈ 709.78
EXPECT_EQ(cephes::expn(1, 800), 0.0);
// x==0 && n < 2
EXPECT_TRUE(cephes::expn(1, 0.0) > 1e308);
EXPECT_TRUE(cephes::expn(0, 0.0) > 1e308);
}
TEST(ExpN, CodecovTodo) {
const double nan64 = std::numeric_limits<double>::quiet_NaN();

// x==0.0 && n >= 2
EXPECT_NE(cephes::expn(2, 0.0), nan64);
EXPECT_NE(cephes::expn(10, 0.0), nan64);
// n==0
EXPECT_NE(cephes::expn(0, 10.0), nan64);
// n > 5000
EXPECT_NE(cephes::expn(5500, 10.0), nan64);
// n <= 5000 && x > 1.0
// cfrac: continued fraction
EXPECT_NE(cephes::expn(10, 10.0), nan64);
// Power series expansion
EXPECT_NE(cephes::expn(1, 0.5), nan64);
EXPECT_NE(cephes::expn(10, 0.5), nan64);
}
Loading

0 comments on commit b7b7754

Please sign in to comment.