Skip to content

Commit

Permalink
Solved bug?
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfomunoz committed May 10, 2024
1 parent 80c9b62 commit fc9e1cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/control-variates/region-sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class region_sampling_importance {
}
auto pos = reg->sample_subrange(sample,range,norm);
Float den = reg->pdf_subrange(pos,range,norm);
return std::tuple<std::array<Float,DIM>,Float>(pos,(den<1.e-10)?Float(0):range.volume()/den);
if (den<1.e-10) den = 1.0;
return std::tuple<std::array<Float,DIM>,Float>(pos,range.volume()/den);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/newton-cotes/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class Region {
const std::array<Float,DIMSUB>& b,const Norm& norm = Norm()) const {
static_assert(DIM>=DIMSUB,"Cannot calculate the subrange pdf for that many dimensions, as the region has less dimensions");
Float den = this->pdf_integral_subrange(a,b,norm);
if (den < 1.e-10) den=1;
if (den<1.e-10) den=1;
return Range(a,b).volume()*norm(this->approximation_at(pos))/den;
}

Expand Down

0 comments on commit fc9e1cd

Please sign in to comment.