Skip to content

Commit

Permalink
PERF: Use vnl_sparse_matrix::get in ComputeJacobianTerms
Browse files Browse the repository at this point in the history
`vnl_sparse_matrix::get(r, c)` just returns when the entry isn't there, and it returns immediately when the row is empty.

A performance improvement may not be noticeable, but it won't harm.
  • Loading branch information
N-Dekker committed Dec 8, 2024
1 parent 9bf49fa commit f928159
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Common/itkComputeJacobianTerms.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,10 @@ ComputeJacobianTerms<TFixedImage, TTransform>::Compute() const -> Terms
double TrC = 0.0;
for (unsigned int p = 0; p < numberOfParameters; ++p)
{
if (!cov.empty_row(p))
{
// avoid creation of element if the row is empty
CovarianceValueType & covpp = cov(p, p);
TrC += covpp;
diagcov[p] = covpp;
}
// Do cov.get(p, p) instead of cov(p, p) to avoid creation of an entry that just has zero.
const CovarianceValueType covpp = cov.get(p, p);
TrC += covpp;
diagcov[p] = covpp;
}

/**
Expand Down

0 comments on commit f928159

Please sign in to comment.