Skip to content

Commit

Permalink
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-buildbot committed Aug 1, 2023
1 parent 24759b4 commit 58b3e6b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
8 changes: 5 additions & 3 deletions stan/math/prim/functor/hcubature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ template <typename F, typename ParsPairT>
std::pair<double, double> gauss_kronrod(const F& integrand, const double a,
const double b,
const ParsPairT& pars_pair) {
Eigen::VectorXd c {{0.5 * (a + b)}};
Eigen::VectorXd c{{0.5 * (a + b)}};
Eigen::VectorXd cp(1);
Eigen::VectorXd cm(1);
double delta = 0.5 * (b - a);
Expand Down Expand Up @@ -520,10 +520,12 @@ double hcubature(const F& integrand, const ParsTuple& pars, const int dim,
auto&& box = ms[err_idx];

double w = (box.b_[box.kdiv_] - box.a_[box.kdiv_]) / 2;
Eigen::VectorXd ma = Eigen::Map<const Eigen::VectorXd>(box.a_.data(), box.a_.size());
Eigen::VectorXd ma
= Eigen::Map<const Eigen::VectorXd>(box.a_.data(), box.a_.size());

ma[box.kdiv_] += w;
Eigen::VectorXd mb = Eigen::Map<const Eigen::VectorXd>(box.b_.data(), box.b_.size());
Eigen::VectorXd mb
= Eigen::Map<const Eigen::VectorXd>(box.b_.data(), box.b_.size());
mb[box.kdiv_] -= w;

double result_1;
Expand Down
3 changes: 1 addition & 2 deletions stan/math/prim/prob/wiener_full_lpdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ inline ReturnT wiener_full_lpdf(const T_y& y, const T_a& a, const T_t0& t0,
T_st0>::value) {
return 0;
}

using T_y_ref = ref_type_t<T_y>;
using T_a_ref = ref_type_t<T_a>;
using T_v_ref = ref_type_t<T_v>;
Expand Down Expand Up @@ -392,7 +392,6 @@ inline ReturnT wiener_full_lpdf(const T_y& y, const T_a& a, const T_t0& t0,
}
}


const double log_error_density = log(1e-6); // precision for density
const double error_bound = precision_derivatives; // precision for
// derivatives (controllable by user)
Expand Down
42 changes: 21 additions & 21 deletions test/unit/math/prim/functor/hcubature_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ stan::return_type_t<T_x, double> f7(const T_x& x, double a) {

template <typename F, typename ArgsTupleT>
void test_integration(const F& f, const ArgsTupleT& pars, int dim,
const Eigen::VectorXd& a, const Eigen::VectorXd& b, int maxEval,
double reqAbsError, const Eigen::VectorXd& reqRelError,
double val) {
const Eigen::VectorXd& a, const Eigen::VectorXd& b,
int maxEval, double reqAbsError,
const Eigen::VectorXd& reqRelError, double val) {
using stan::math::hcubature;

for (auto tolerance : reqRelError) {
Expand All @@ -122,44 +122,44 @@ TEST(StanMath_hcubature_prim, test1) {
// https://www.quantargo.com/help/r/latest/packages/cubature/2.0.4.1/hcubature

int dim = 1;
const Eigen::VectorXd a {{0.0}};
const Eigen::VectorXd b {{1.0}};
const Eigen::VectorXd reqRelError {{1e-4, 1e-6, 1e-7}};
const Eigen::VectorXd a{{0.0}};
const Eigen::VectorXd b{{1.0}};
const Eigen::VectorXd reqRelError{{1e-4, 1e-6, 1e-7}};
test_integration(hcubature_test::f1<const Eigen::VectorXd>, std::make_tuple(),
dim, a, b, 6000, 0.0, reqRelError, 0.841471);

dim = 2;
const Eigen::VectorXd a_2 {{0.0, 0.0}};
const Eigen::VectorXd b_2 {{1.0, 1.0}};
const Eigen::VectorXd a_2{{0.0, 0.0}};
const Eigen::VectorXd b_2{{1.0, 1.0}};
test_integration(hcubature_test::f2<const Eigen::VectorXd>, std::make_tuple(),
dim, a_2, b_2, 6000, 0.0, reqRelError, 0.7080734);

const Eigen::VectorXd reqRelError_2 {{1e-4}};
const Eigen::VectorXd reqRelError_2{{1e-4}};
test_integration(hcubature_test::f3<const Eigen::VectorXd>,
std::make_tuple(0.50124145262344534123412), dim, a_2, b_2, 10000,
0.0, reqRelError_2, 0.1972807);
std::make_tuple(0.50124145262344534123412), dim, a_2, b_2,
10000, 0.0, reqRelError_2, 0.1972807);

// (Gaussian centered at 1/2)
test_integration(hcubature_test::f4<const Eigen::VectorXd>,
std::make_tuple(0.1), dim, a_2, b_2, 6000, 0.0, reqRelError, 1);
std::make_tuple(0.1), dim, a_2, b_2, 6000, 0.0, reqRelError,
1);

dim = 3;
const Eigen::VectorXd a_3 {{0.0, 0.0, 0.0}};
const Eigen::VectorXd b_3 {{1.0, 1.0, 1.0}};
const Eigen::VectorXd reqRelError_3 {{1e-4, 1e-6}};
const Eigen::VectorXd a_3{{0.0, 0.0, 0.0}};
const Eigen::VectorXd b_3{{1.0, 1.0, 1.0}};
const Eigen::VectorXd reqRelError_3{{1e-4, 1e-6}};
test_integration(hcubature_test::f5<const Eigen::VectorXd>, std::make_tuple(),
dim, a_3, b_3, 6000, 0.0, reqRelError_3, 1.00001);

const Eigen::VectorXd reqRelError_4 {{1e-4, 1e-6, 1e-8}};
const Eigen::VectorXd reqRelError_4{{1e-4, 1e-6, 1e-8}};
test_integration(hcubature_test::f6<const Eigen::VectorXd>, std::make_tuple(),
dim, a_3, b_3, 6000, 0.0, reqRelError_4, 1);

// (Tsuda's example)
dim = 4;
const Eigen::VectorXd a_4 {{0.0, 0.0, 0.0, 0.0}};
const Eigen::VectorXd b_4 {{1.0, 1.0, 1.0, 1.0}};
const Eigen::VectorXd a_4{{0.0, 0.0, 0.0, 0.0}};
const Eigen::VectorXd b_4{{1.0, 1.0, 1.0, 1.0}};
test_integration(hcubature_test::f7<const Eigen::VectorXd>,
std::make_tuple((1 + sqrt(10.0)) / 9.0), dim, a_4, b_4, 20000,
0.0, reqRelError_3, 0.999998);

std::make_tuple((1 + sqrt(10.0)) / 9.0), dim, a_4, b_4,
20000, 0.0, reqRelError_3, 0.999998);
}

0 comments on commit 58b3e6b

Please sign in to comment.