Skip to content

Commit

Permalink
Applying suggested changes from review (Issue #2881)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbales2 committed Mar 15, 2020
1 parent 45fff72 commit 7582cce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/stan/mcmc/hmc/hamiltonians/dense_e_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class dense_e_point : public ps_point {
*
* @return reference to the inverse metric
*/
const Eigen::MatrixXd& get_inv_metric() {
const Eigen::MatrixXd& get_inv_metric() const {
return inv_e_metric_;
}

Expand All @@ -57,7 +57,7 @@ class dense_e_point : public ps_point {
*
* @return reference to transpose of Cholesky factor
*/
const Eigen::MatrixXd& get_transpose_llt_inv_metric() {
const Eigen::MatrixXd& get_transpose_llt_inv_metric() const {
return inv_e_metric_llt_matrixU_;
}

Expand Down
5 changes: 3 additions & 2 deletions src/stan/mcmc/hmc/hamiltonians/diag_e_metric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ class diag_e_metric : public base_hamiltonian<Model, diag_e_point, BaseRNG> {
boost::variate_generator<BaseRNG&, boost::normal_distribution<> >
rand_diag_gaus(rng, boost::normal_distribution<>());

for (int i = 0; i < z.p.size(); ++i)
z.p(i) = rand_diag_gaus() / sqrt(z.get_inv_metric()(i));
z.p = z.get_inv_metric().unaryExpr([&](auto&& x) {
return rand_diag_gaus() / sqrt(x);
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/stan/mcmc/hmc/hamiltonians/diag_e_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class diag_e_point : public ps_point {
*
* @return reference to the inverse metric
*/
const Eigen::VectorXd& get_inv_metric() {
const Eigen::VectorXd& get_inv_metric() const {
return inv_e_metric_;
}

Expand Down

0 comments on commit 7582cce

Please sign in to comment.