Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY: clang-format repo #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/xsf/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ BreakBeforeBraces: Attach
Cpp11BracedListStyle: true
NamespaceIndentation: Inner
AlwaysBreakTemplateDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterCStyleCast: false
ColumnLimit: 120
InsertNewlineAtEOF: true
AlignAfterOpenBracket: BlockIndent
IncludeBlocks: Preserve
AllowShortFunctionsOnASingleLine: None
2 changes: 1 addition & 1 deletion include/xsf/airy.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ inline void airyb(double x, double *ai, double *bi, double *ad, double *bd) {
*ad = c1 * df - c2 * dg;
*bd = sr3 * (c1 * df + c2 * dg);
} else {
km = (int) (24.5 - xa);
km = (int)(24.5 - xa);
if (xa < 6.0)
km = 14;
if (xa > 15.0)
Expand Down
8 changes: 6 additions & 2 deletions include/xsf/alg.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

namespace xsf {

XSF_HOST_DEVICE inline double cbrt(double x) { return cephes::detail::cbrt(x); }
XSF_HOST_DEVICE inline double cbrt(double x) {
return cephes::detail::cbrt(x);
}

XSF_HOST_DEVICE inline float cbrt(float x) { return cbrt(static_cast<double>(x)); }
XSF_HOST_DEVICE inline float cbrt(float x) {
return cbrt(static_cast<double>(x));
}

} // namespace xsf
11,946 changes: 6,146 additions & 5,800 deletions include/xsf/amos/amos.h

Large diffs are not rendered by default.

108 changes: 81 additions & 27 deletions include/xsf/bessel.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,13 +638,21 @@ T cyl_bessel_je(T v, T x) {
return std::real(cyl_bessel_je(v, std::complex(x)));
}

inline double cyl_bessel_y0(double x) { return cephes::y0(x); }
inline double cyl_bessel_y0(double x) {
return cephes::y0(x);
}

inline float cyl_bessel_y0(float x) { return cyl_bessel_y0(static_cast<double>(x)); }
inline float cyl_bessel_y0(float x) {
return cyl_bessel_y0(static_cast<double>(x));
}

inline double cyl_bessel_y1(double x) { return cephes::y1(x); }
inline double cyl_bessel_y1(double x) {
return cephes::y1(x);
}

inline float cyl_bessel_y1(float x) { return cyl_bessel_y1(static_cast<double>(x)); }
inline float cyl_bessel_y1(float x) {
return cyl_bessel_y1(static_cast<double>(x));
}

inline std::complex<double> cyl_bessel_ye(double v, std::complex<double> z) {
int n = 1;
Expand Down Expand Up @@ -857,13 +865,21 @@ inline std::complex<float> cyl_hankel_2e(float v, std::complex<float> z) {
);
}

inline double cyl_bessel_j0(double x) { return cephes::j0(x); }
inline double cyl_bessel_j0(double x) {
return cephes::j0(x);
}

inline float cyl_bessel_j0(float x) { return cyl_bessel_j0(static_cast<double>(x)); }
inline float cyl_bessel_j0(float x) {
return cyl_bessel_j0(static_cast<double>(x));
}

inline double cyl_bessel_j1(double x) { return cephes::j1(x); }
inline double cyl_bessel_j1(double x) {
return cephes::j1(x);
}

inline float cyl_bessel_j1(float x) { return cyl_bessel_j1(static_cast<double>(x)); }
inline float cyl_bessel_j1(float x) {
return cyl_bessel_j1(static_cast<double>(x));
}

inline std::complex<double> cyl_bessel_j(double v, std::complex<double> z) {
int n = 1;
Expand Down Expand Up @@ -990,25 +1006,45 @@ T cyl_bessel_y(T v, T x) {
return std::real(res);
}

inline double cyl_bessel_i(double v, double x) { return cephes::iv(v, x); }
inline double cyl_bessel_i(double v, double x) {
return cephes::iv(v, x);
}

inline float cyl_bessel_i(float v, float x) { return cyl_bessel_i(static_cast<double>(v), static_cast<double>(x)); }
inline float cyl_bessel_i(float v, float x) {
return cyl_bessel_i(static_cast<double>(v), static_cast<double>(x));
}

inline double cyl_bessel_i0(double x) { return cephes::i0(x); }
inline double cyl_bessel_i0(double x) {
return cephes::i0(x);
}

inline float cyl_bessel_i0(float x) { return cyl_bessel_i0(static_cast<double>(x)); }
inline float cyl_bessel_i0(float x) {
return cyl_bessel_i0(static_cast<double>(x));
}

inline double cyl_bessel_i0e(double x) { return cephes::i0e(x); }
inline double cyl_bessel_i0e(double x) {
return cephes::i0e(x);
}

inline float cyl_bessel_i0e(float x) { return cyl_bessel_i0e(static_cast<double>(x)); }
inline float cyl_bessel_i0e(float x) {
return cyl_bessel_i0e(static_cast<double>(x));
}

inline double cyl_bessel_i1(double x) { return cephes::i1(x); }
inline double cyl_bessel_i1(double x) {
return cephes::i1(x);
}

inline float cyl_bessel_i1(float x) { return cyl_bessel_i1(static_cast<double>(x)); }
inline float cyl_bessel_i1(float x) {
return cyl_bessel_i1(static_cast<double>(x));
}

inline double cyl_bessel_i1e(double x) { return cephes::i1e(x); }
inline double cyl_bessel_i1e(double x) {
return cephes::i1e(x);
}

inline float cyl_bessel_i1e(float x) { return cyl_bessel_i1e(static_cast<double>(x)); }
inline float cyl_bessel_i1e(float x) {
return cyl_bessel_i1e(static_cast<double>(x));
}

inline std::complex<double> cyl_bessel_i(double v, std::complex<double> z) {
int n = 1;
Expand Down Expand Up @@ -1112,21 +1148,37 @@ T cyl_bessel_k(T v, T z) {
return std::real(cyl_bessel_k(v, std::complex(z)));
}

inline double cyl_bessel_k0(double x) { return cephes::k0(x); }
inline double cyl_bessel_k0(double x) {
return cephes::k0(x);
}

inline float cyl_bessel_k0(float x) { return cyl_bessel_k0(static_cast<double>(x)); }
inline float cyl_bessel_k0(float x) {
return cyl_bessel_k0(static_cast<double>(x));
}

inline double cyl_bessel_k0e(double x) { return cephes::k0e(x); }
inline double cyl_bessel_k0e(double x) {
return cephes::k0e(x);
}

inline float cyl_bessel_k0e(float x) { return cyl_bessel_k0e(static_cast<double>(x)); }
inline float cyl_bessel_k0e(float x) {
return cyl_bessel_k0e(static_cast<double>(x));
}

inline double cyl_bessel_k1(double x) { return cephes::k1(x); }
inline double cyl_bessel_k1(double x) {
return cephes::k1(x);
}

inline float cyl_bessel_k1(float x) { return cyl_bessel_k1(static_cast<double>(x)); }
inline float cyl_bessel_k1(float x) {
return cyl_bessel_k1(static_cast<double>(x));
}

inline double cyl_bessel_k1e(double x) { return cephes::k1e(x); }
inline double cyl_bessel_k1e(double x) {
return cephes::k1e(x);
}

inline float cyl_bessel_k1e(float x) { return cyl_bessel_k1e(static_cast<double>(x)); }
inline float cyl_bessel_k1e(float x) {
return cyl_bessel_k1e(static_cast<double>(x));
}

inline std::complex<double> cyl_hankel_1(double v, std::complex<double> z) {
int n = 1;
Expand Down Expand Up @@ -1193,7 +1245,9 @@ inline std::complex<float> cyl_hankel_2(float v, std::complex<float> z) {
return static_cast<std::complex<float>>(cyl_hankel_2(static_cast<double>(v), static_cast<std::complex<double>>(z)));
}

inline double besselpoly(double a, double lambda, double nu) { return cephes::besselpoly(a, lambda, nu); }
inline double besselpoly(double a, double lambda, double nu) {
return cephes::besselpoly(a, lambda, nu);
}

inline float besselpoly(float a, float lambda, float nu) {
return besselpoly(static_cast<double>(a), static_cast<double>(lambda), static_cast<double>(nu));
Expand Down
16 changes: 12 additions & 4 deletions include/xsf/beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@

namespace xsf {

XSF_HOST_DEVICE inline double beta(double a, double b) { return cephes::beta(a, b); }
XSF_HOST_DEVICE inline double beta(double a, double b) {
return cephes::beta(a, b);
}

XSF_HOST_DEVICE inline float beta(float a, float b) { return beta(static_cast<double>(a), static_cast<double>(b)); }
XSF_HOST_DEVICE inline float beta(float a, float b) {
return beta(static_cast<double>(a), static_cast<double>(b));
}

XSF_HOST_DEVICE inline double betaln(double a, double b) { return cephes::lbeta(a, b); }
XSF_HOST_DEVICE inline double betaln(double a, double b) {
return cephes::lbeta(a, b);
}

XSF_HOST_DEVICE inline float betaln(float a, float b) { return betaln(static_cast<double>(a), static_cast<double>(b)); }
XSF_HOST_DEVICE inline float betaln(float a, float b) {
return betaln(static_cast<double>(a), static_cast<double>(b));
}

} // namespace xsf
18 changes: 8 additions & 10 deletions include/xsf/cdflib.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ XSF_HOST_DEVICE inline double gdtrib(double a, double p, double x) {
}
double q = 1.0 - p;
auto func = [a, p, q, x](double b) {
if (p <= q) {
return cephes::igam(b, a * x) - p;
}
return q - cephes::igamc(b, a * x);
if (p <= q) {
return cephes::igam(b, a * x) - p;
}
return q - cephes::igamc(b, a * x);
};
double lower_bound = std::numeric_limits<double>::min();
double upper_bound = std::numeric_limits<double>::max();
Expand All @@ -71,9 +71,8 @@ XSF_HOST_DEVICE inline double gdtrib(double a, double p, double x) {
* number of iterations needed in this bracket search to check all normalized
* floating point values.
*/
auto [xl, xr, f_xl, f_xr, bracket_status] = detail::bracket_root_for_cdf_inversion(
func, 1.0, lower_bound, upper_bound, -0.875, 7.0, 0.125, 8, false, 342
);
auto [xl, xr, f_xl, f_xr, bracket_status] =
detail::bracket_root_for_cdf_inversion(func, 1.0, lower_bound, upper_bound, -0.875, 7.0, 0.125, 8, false, 342);
if (bracket_status == 1) {
set_error("gdtrib", SF_ERROR_UNDERFLOW, NULL);
return 0.0;
Expand All @@ -86,9 +85,8 @@ XSF_HOST_DEVICE inline double gdtrib(double a, double p, double x) {
set_error("gdtrib", SF_ERROR_OTHER, "Computational Error");
return std::numeric_limits<double>::quiet_NaN();
}
auto [result, root_status] = detail::find_root_chandrupatla(
func, xl, xr, f_xl, f_xr, std::numeric_limits<double>::epsilon(), 1e-100, 100
);
auto [result, root_status] =
detail::find_root_chandrupatla(func, xl, xr, f_xl, f_xr, std::numeric_limits<double>::epsilon(), 1e-100, 100);
if (root_status) {
/* The root finding return should only fail if there's a bug in our code. */
set_error("gdtrib", SF_ERROR_OTHER, "Computational Error, (%.17g, %.17g, %.17g)", a, p, x);
Expand Down
6 changes: 3 additions & 3 deletions include/xsf/cephes/beta.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ namespace cephes {
b = Gamma(b);
if (std::isinf(y)) {
goto overflow;
}
}

if (std::abs(std::abs(a*y) - 1.0) > std::abs(std::abs(b*y) - 1.0)) {
if (std::abs(std::abs(a * y) - 1.0) > std::abs(std::abs(b * y) - 1.0)) {
y = b * y;
y *= a;
} else {
Expand Down Expand Up @@ -239,7 +239,7 @@ namespace cephes {
return (sign * std::numeric_limits<double>::infinity());
}

if (std::abs(std::abs(a*y) - 1.0) > std::abs(std::abs(b*y) - 1.0)) {
if (std::abs(std::abs(a * y) - 1.0) > std::abs(std::abs(b * y) - 1.0)) {
y = b * y;
y *= a;
} else {
Expand Down
Loading