Skip to content

Commit

Permalink
minor optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaperju committed Aug 7, 2024
1 parent f066091 commit 146c5d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/convex_bodies/hpolytope.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,9 @@ class HPolytope {

template <typename update_parameters, typename set_type, typename AA_type>
std::pair<NT, int> line_positive_intersect(Point const& r,
Point const& v,
VT& Ar,
VT& Av,
NT const& lambda_prev,
VT& distances_vec,
set_type& distances_set,
AA_type const& AA,
Expand All @@ -593,7 +593,8 @@ class HPolytope {
*(Av_data + it.row()) += (-2.0 * inner_prev) * it.value();
*(Ar_data + it.row()) -= (-2.0 * inner_prev * params.moved_dist) * it.value();

distances_set.erase(std::make_pair(*(dvec_data + it.row()), it.row()));
if(*(dvec_data + it.row()) > params.moved_dist - lambda_prev)
distances_set.erase(std::make_pair(*(dvec_data + it.row()), it.row()));

*(dvec_data + it.row()) = (*(b_data + it.row()) - *(Ar_data + it.row())) / *(Av_data + it.row());

Expand Down
2 changes: 1 addition & 1 deletion include/random_walks/uniform_accelerated_billiard_walk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct AcceleratedBilliardWalk
{
std::pair<NT, int> pbpair;
if constexpr (std::is_same<MT, Eigen::SparseMatrix<NT, Eigen::RowMajor>>::value) {
pbpair = P.line_positive_intersect(_p, _v, _lambdas, _Av, _distances_vec,
pbpair = P.line_positive_intersect(_p, _lambdas, _Av, _lambda_prev, _distances_vec,
_distances_set, _AA, _update_parameters);
} else {
pbpair = P.line_positive_intersect(_p, _v, _lambdas, _Av, _lambda_prev,
Expand Down

0 comments on commit 146c5d7

Please sign in to comment.