Skip to content

Commit

Permalink
ENH: Prefer multiplication to division
Browse files Browse the repository at this point in the history
Multiplication is more efficient than division, so
use multiply by reciprical to make 1 division.
  • Loading branch information
hjmjohnson committed Apr 13, 2020
1 parent 8626163 commit 50b91ab
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,10 @@ MattesMutualInformationImageToImageMetricv4<TFixedImage,
{
itkExceptionMacro("Fixed image marginal PDF summed to zero");
}
const PDFValueType inv_totalMassOfPDF = 1.0 / totalMassOfPDF;
for (unsigned int bin = 0; bin < this->m_NumberOfHistogramBins; ++bin)
{
this->m_ThreaderFixedImageMarginalPDF[0][bin] /= totalMassOfPDF;
this->m_ThreaderFixedImageMarginalPDF[0][bin] *= inv_totalMassOfPDF;
}

static constexpr PDFValueType closeToZero = std::numeric_limits<PDFValueType>::epsilon();
Expand Down

0 comments on commit 50b91ab

Please sign in to comment.