Skip to content

Commit 804f376

Browse files
committed
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
1 parent b25d487 commit 804f376

File tree

5 files changed

+70
-77
lines changed

5 files changed

+70
-77
lines changed

stan/math/opencl/kernel_generator/elt_function_cl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ class lbeta_ : public elt_function_cl<lbeta_<T1, T2>, double, T1, T2> {
365365
using base::arguments_;
366366

367367
public:
368-
using base::rows;
369368
using base::cols;
369+
using base::rows;
370370
static const std::vector<const char*> includes;
371371
explicit lbeta_(T1&& a, T2&& b)
372372
: base("stan_lbeta", std::forward<T1>(a), std::forward<T2>(b)) {

stan/math/opencl/kernels/device_functions/std_normal_lcdf.hpp

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace opencl_kernels {
1212
static constexpr const char* std_normal_lcdf_device_function
1313
= "\n"
1414
"#ifndef STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_STD_NORMAL_LCDF\n"
15-
"#define STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_STD_NORMAL_LCDF\n"
16-
STRINGIFY(
15+
"#define "
16+
"STAN_MATH_OPENCL_KERNELS_DEVICE_FUNCTIONS_STD_NORMAL_LCDF\n" STRINGIFY(
1717
/** \ingroup opencl_kernels
1818
* Return the log standard normal cumulative distribution function
1919
* evaluated from the scaled input `x / sqrt(2)`.
@@ -39,20 +39,18 @@ static constexpr const char* std_normal_lcdf_device_function
3939
const double x6 = pow(scaled_y, 6);
4040
const double x8 = pow(scaled_y, 8);
4141
const double x10 = pow(scaled_y, 10);
42-
const double temp_p
43-
= 0.000658749161529837803157 + 0.0160837851487422766278 / x2
44-
+ 0.125781726111229246204 / x4
45-
+ 0.360344899949804439429 / x6
46-
+ 0.305326634961232344035 / x8
47-
+ 0.0163153871373020978498 / x10;
42+
const double temp_p = 0.000658749161529837803157
43+
+ 0.0160837851487422766278 / x2
44+
+ 0.125781726111229246204 / x4
45+
+ 0.360344899949804439429 / x6
46+
+ 0.305326634961232344035 / x8
47+
+ 0.0163153871373020978498 / x10;
4848
const double temp_q
49-
= -0.00233520497626869185443
50-
- 0.0605183413124413191178 / x2
51-
- 0.527905102951428412248 / x4
52-
- 1.87295284992346047209 / x6
49+
= -0.00233520497626869185443 - 0.0605183413124413191178 / x2
50+
- 0.527905102951428412248 / x4 - 1.87295284992346047209 / x6
5351
- 2.56852019228982242072 / x8 - 1.0 / x10;
54-
lcdf_n = log(0.5 * M_2_SQRTPI + (temp_p / temp_q) / x2)
55-
- M_LN2 - log(-scaled_y) - x2;
52+
lcdf_n = log(0.5 * M_2_SQRTPI + (temp_p / temp_q) / x2) - M_LN2
53+
- log(-scaled_y) - x2;
5654
} else {
5755
lcdf_n = -INFINITY;
5856
}
@@ -78,11 +76,10 @@ static constexpr const char* std_normal_lcdf_device_function
7876
t = 1.0 / (1.0 + 0.3275911 * scaled_y);
7977
t2 = t * t;
8078
t4 = pow(t, 4);
81-
dnlcdf
82-
= 0.5 * M_2_SQRTPI
83-
/ (exp(x2) - 0.254829592 + 0.284496736 * t
84-
- 1.421413741 * t2 + 1.453152027 * t2 * t
85-
- 1.061405429 * t4);
79+
dnlcdf = 0.5 * M_2_SQRTPI
80+
/ (exp(x2) - 0.254829592 + 0.284496736 * t
81+
- 1.421413741 * t2 + 1.453152027 * t2 * t
82+
- 1.061405429 * t4);
8683
} else if (scaled_y > 2.5) {
8784
t = scaled_y - 2.7;
8885
t2 = t * t;
@@ -95,46 +92,41 @@ static constexpr const char* std_normal_lcdf_device_function
9592
t = scaled_y - 2.3;
9693
t2 = t * t;
9794
t4 = pow(t, 4);
98-
dnlcdf = 0.002846135439 - 0.01310032351 * t
99-
+ 0.02732189391 * t2 - 0.03326906904 * t2 * t
100-
+ 0.02482478940 * t4 - 0.009883071924 * t4 * t
101-
- 0.0002771362254 * pow(t, 6);
95+
dnlcdf = 0.002846135439 - 0.01310032351 * t + 0.02732189391 * t2
96+
- 0.03326906904 * t2 * t + 0.02482478940 * t4
97+
- 0.009883071924 * t4 * t - 0.0002771362254 * pow(t, 6);
10298
} else if (scaled_y > 1.5) {
10399
t = scaled_y - 1.85;
104100
t2 = t * t;
105101
t4 = pow(t, 4);
106-
dnlcdf = 0.01849212058 - 0.06876280470 * t
107-
+ 0.1099906382 * t2 - 0.09274533184 * t2 * t
108-
+ 0.03543327418 * t4 + 0.005644855518 * t4 * t
109-
- 0.01111434424 * pow(t, 6);
102+
dnlcdf = 0.01849212058 - 0.06876280470 * t + 0.1099906382 * t2
103+
- 0.09274533184 * t2 * t + 0.03543327418 * t4
104+
+ 0.005644855518 * t4 * t - 0.01111434424 * pow(t, 6);
110105
} else if (scaled_y > 0.8) {
111106
t = scaled_y - 1.15;
112107
t2 = t * t;
113108
t4 = pow(t, 4);
114-
dnlcdf = 0.1585747034 - 0.3898677543 * t
115-
+ 0.3515963775 * t2 - 0.09748053605 * t2 * t
116-
- 0.04347986191 * t4 + 0.02182506378 * t4 * t
117-
+ 0.01074751427 * pow(t, 6);
109+
dnlcdf = 0.1585747034 - 0.3898677543 * t + 0.3515963775 * t2
110+
- 0.09748053605 * t2 * t - 0.04347986191 * t4
111+
+ 0.02182506378 * t4 * t + 0.01074751427 * pow(t, 6);
118112
} else if (scaled_y > 0.1) {
119113
t = scaled_y - 0.45;
120114
t2 = t * t;
121115
t4 = pow(t, 4);
122-
dnlcdf = 0.6245634904 - 0.9521866949 * t
123-
+ 0.3986215682 * t2 + 0.04700850676 * t2 * t
124-
- 0.03478651979 * t4 - 0.01772675404 * t4 * t
125-
+ 0.0006577254811 * pow(t, 6);
116+
dnlcdf = 0.6245634904 - 0.9521866949 * t + 0.3986215682 * t2
117+
+ 0.04700850676 * t2 * t - 0.03478651979 * t4
118+
- 0.01772675404 * t4 * t + 0.0006577254811 * pow(t, 6);
126119
} else if (10.0 * log(fabs(scaled_y)) < log(DBL_MAX)) {
127120
t = 1.0 / (1.0 - 0.3275911 * scaled_y);
128121
t2 = t * t;
129122
t4 = pow(t, 4);
130123
dnlcdf
131124
= M_2_SQRTPI
132-
/ (0.254829592 * t - 0.284496736 * t2
133-
+ 1.421413741 * t2 * t - 1.453152027 * t4
134-
+ 1.061405429 * t4 * t);
125+
/ (0.254829592 * t - 0.284496736 * t2 + 1.421413741 * t2 * t
126+
- 1.453152027 * t4 + 1.061405429 * t4 * t);
135127
if (scaled_y < -29.0) {
136-
dnlcdf += 0.0015065154280332 * x2 - 0.3993154819705530 * scaled_y
137-
- 4.2919418242931700;
128+
dnlcdf += 0.0015065154280332 * x2
129+
- 0.3993154819705530 * scaled_y - 4.2919418242931700;
138130
} else if (scaled_y < -17.0) {
139131
dnlcdf += 0.0001263257217272 * x2 * scaled_y
140132
+ 0.0123586859488623 * x2

stan/math/opencl/prim/exp_mod_normal_lcdf.hpp

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ exp_mod_normal_lcdf(const T_y_cl& y, const T_loc_cl& mu,
9090
auto use_stable = cdf_n <= 0.0 || !isfinite(cdf_n);
9191

9292
auto exp_term_2 = exp(-square(scaled_diff_diff));
93-
auto deriv_1 = elt_multiply(elt_multiply(lambda_val, exp_term), cdf_term_2_phi);
93+
auto deriv_1
94+
= elt_multiply(elt_multiply(lambda_val, exp_term), cdf_term_2_phi);
9495
auto deriv_2 = INV_SQRT_TWO_PI
9596
* elt_multiply(elt_multiply(exp_term, exp_term_2), sigma_inv);
9697
auto deriv_3
@@ -103,10 +104,10 @@ exp_mod_normal_lcdf(const T_y_cl& y, const T_loc_cl& mu,
103104
+ elt_multiply(deriv_3 - deriv_2, scaled_diff) * SQRT_TWO,
104105
cdf_n);
105106
auto direct_lambda_deriv = elt_divide(
106-
elt_multiply(
107-
exp_term,
108-
INV_SQRT_TWO_PI * elt_multiply(sigma_val, exp_term_2)
109-
- elt_multiply(elt_multiply(v, sigma_val) - diff, cdf_term_2_phi)),
107+
elt_multiply(exp_term,
108+
INV_SQRT_TWO_PI * elt_multiply(sigma_val, exp_term_2)
109+
- elt_multiply(elt_multiply(v, sigma_val) - diff,
110+
cdf_term_2_phi)),
110111
cdf_n);
111112

112113
auto log_cdf_term_1 = std_normal_lcdf_scaled_impl(scaled_diff);
@@ -121,33 +122,29 @@ exp_mod_normal_lcdf(const T_y_cl& y, const T_loc_cl& mu,
121122
= elt_multiply(dlog_cdf_term_1, sigma_inv * INV_SQRT_TWO);
122123
auto scaled_diff_diff_deriv
123124
= elt_multiply(dlog_cdf_term_2_phi, sigma_inv * INV_SQRT_TWO);
124-
auto stable_y_deriv = elt_multiply(cdf_term_1_weight, scaled_diff_deriv)
125-
- elt_multiply(cdf_term_2_weight,
126-
-lambda_val + scaled_diff_diff_deriv);
125+
auto stable_y_deriv
126+
= elt_multiply(cdf_term_1_weight, scaled_diff_deriv)
127+
- elt_multiply(cdf_term_2_weight, -lambda_val + scaled_diff_diff_deriv);
127128
auto stable_mu_deriv = -stable_y_deriv;
128-
auto stable_sigma_deriv = elt_multiply(
129-
cdf_term_1_weight,
130-
-elt_multiply(dlog_cdf_term_1,
131-
elt_multiply(scaled_diff,
132-
sigma_inv)))
133-
- elt_multiply(
134-
cdf_term_2_weight,
135-
elt_multiply(lambda_val, v)
136-
- elt_multiply(
137-
dlog_cdf_term_2_phi,
138-
elt_multiply(
139-
scaled_diff + v * INV_SQRT_TWO,
140-
sigma_inv)));
141-
auto stable_lambda_deriv
142-
= -elt_multiply(cdf_term_2_weight,
143-
elt_multiply(v, sigma_val) - diff
144-
- elt_multiply(dlog_cdf_term_2_phi,
145-
sigma_val * INV_SQRT_TWO));
146-
auto cdf_log_expr = colwise_sum(select(use_stable, log_cdf_n, direct_cdf_log));
129+
auto stable_sigma_deriv
130+
= elt_multiply(cdf_term_1_weight,
131+
-elt_multiply(dlog_cdf_term_1,
132+
elt_multiply(scaled_diff, sigma_inv)))
133+
- elt_multiply(
134+
cdf_term_2_weight,
135+
elt_multiply(lambda_val, v)
136+
- elt_multiply(
137+
dlog_cdf_term_2_phi,
138+
elt_multiply(scaled_diff + v * INV_SQRT_TWO, sigma_inv)));
139+
auto stable_lambda_deriv = -elt_multiply(
140+
cdf_term_2_weight,
141+
elt_multiply(v, sigma_val) - diff
142+
- elt_multiply(dlog_cdf_term_2_phi, sigma_val * INV_SQRT_TWO));
143+
auto cdf_log_expr
144+
= colwise_sum(select(use_stable, log_cdf_n, direct_cdf_log));
147145
auto y_deriv = select(use_stable, stable_y_deriv, direct_y_deriv);
148146
auto mu_deriv = select(use_stable, stable_mu_deriv, direct_mu_deriv);
149-
auto sigma_deriv
150-
= select(use_stable, stable_sigma_deriv, direct_sigma_deriv);
147+
auto sigma_deriv = select(use_stable, stable_sigma_deriv, direct_sigma_deriv);
151148
auto lambda_deriv
152149
= select(use_stable, stable_lambda_deriv, direct_lambda_deriv);
153150

test/unit/math/opencl/rev/exp_mod_normal_lcdf_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ TEST(ProbDistributionsDoubleExpModNormalLcdf, opencl_matches_cpu_big) {
179179
mu, sigma, lambda);
180180
}
181181

182-
TEST(ProbDistributionsDoubleExpModNormalLcdf, opencl_matches_cpu_big_transpose) {
182+
TEST(ProbDistributionsDoubleExpModNormalLcdf,
183+
opencl_matches_cpu_big_transpose) {
183184
constexpr int N = 153;
184185

185186
Eigen::Matrix<double, Eigen::Dynamic, 1> y

test/unit/math/opencl/util.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ inline void expect_eq(const T1& a, const T2& b, const char* msg,
8181
}
8282
template <typename T>
8383
inline void expect_eq(const std::vector<T>& a, const std::vector<T>& b,
84-
const char* msg, stan::test::relative_tolerance tol
84+
const char* msg,
85+
stan::test::relative_tolerance tol
8586
= stan::test::relative_tolerance()) {
8687
EXPECT_EQ(a.size(), b.size());
8788
for (int i = 0; i < a.size(); i++) {
@@ -119,7 +120,8 @@ auto recursive_sum(const std::vector<T>& a) {
119120
template <typename T, require_not_st_var<T>* = nullptr>
120121
inline void expect_adj_near(const T& a, const T& b, const char* msg) {}
121122
inline void expect_adj_near(var a, var b, const char* msg) {
122-
stan::test::expect_near_rel(msg, a.adj(), b.adj(), stan::test::relative_tolerance(1e-5));
123+
stan::test::expect_near_rel(msg, a.adj(), b.adj(),
124+
stan::test::relative_tolerance(1e-5));
123125
}
124126
template <typename T1, typename T2, require_all_eigen_t<T1, T2>* = nullptr,
125127
require_vt_same<T1, T2>* = nullptr>
@@ -128,7 +130,8 @@ inline void expect_adj_near(const T1& a, const T2& b, const char* msg) {
128130
EXPECT_EQ(a.cols(), b.cols()) << msg;
129131
const auto& a_ref = math::to_ref(a);
130132
const auto& b_ref = math::to_ref(b);
131-
stan::test::expect_near_rel(msg, a_ref.adj(), b_ref.adj(), stan::test::relative_tolerance(1e-5));
133+
stan::test::expect_near_rel(msg, a_ref.adj(), b_ref.adj(),
134+
stan::test::relative_tolerance(1e-5));
132135
}
133136
template <typename T>
134137
inline void expect_adj_near(const std::vector<T>& a, const std::vector<T>& b,
@@ -355,9 +358,9 @@ inline void compare_cpu_opencl_prim_rev(const Functor& functor,
355358
}
356359

357360
template <typename Functor, typename... Args>
358-
inline void compare_cpu_opencl_prim_rev(
359-
const Functor& functor, stan::test::relative_tolerance tol,
360-
const Args&... args) {
361+
inline void compare_cpu_opencl_prim_rev(const Functor& functor,
362+
stan::test::relative_tolerance tol,
363+
const Args&... args) {
361364
internal::compare_cpu_opencl_prim_rev_impl(
362365
functor, tol, std::make_index_sequence<sizeof...(args)>{}, args...);
363366
recover_memory();

0 commit comments

Comments
 (0)