Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: Fill jsj (JacobianOfSpatialJacobian) in-place and remove jsj1 #891

Merged
merged 1 commit into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Common/Transforms/itkAdvancedCombinationTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1034,16 +1034,15 @@ AdvancedCombinationTransform<TScalarType, NDimensions>::GetJacobianOfSpatialJaco
JacobianOfSpatialJacobianType & jsj,
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const
{
SpatialJacobianType sj0;
JacobianOfSpatialJacobianType jsj1;
SpatialJacobianType sj0;
m_InitialTransform->GetSpatialJacobian(inputPoint, sj0);
m_CurrentTransform->GetJacobianOfSpatialJacobian(
m_InitialTransform->TransformPoint(inputPoint), jsj1, nonZeroJacobianIndices);
m_InitialTransform->TransformPoint(inputPoint), jsj, nonZeroJacobianIndices);

jsj.resize(nonZeroJacobianIndices.size());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This jsj.resize(nonZeroJacobianIndices.size()) may no longer be necessary, but it's hard for me decide, just by looking at those few lines of code.

for (unsigned int mu = 0; mu < nonZeroJacobianIndices.size(); ++mu)
for (auto & matrix : jsj)
{
jsj[mu] = jsj1[mu] * sj0;
matrix *= sj0;
}

} // end GetJacobianOfSpatialJacobianUseComposition()
Expand All @@ -1061,17 +1060,16 @@ AdvancedCombinationTransform<TScalarType, NDimensions>::GetJacobianOfSpatialJaco
JacobianOfSpatialJacobianType & jsj,
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const
{
SpatialJacobianType sj0, sj1;
JacobianOfSpatialJacobianType jsj1;
SpatialJacobianType sj0, sj1;
m_InitialTransform->GetSpatialJacobian(inputPoint, sj0);
m_CurrentTransform->GetJacobianOfSpatialJacobian(
m_InitialTransform->TransformPoint(inputPoint), sj1, jsj1, nonZeroJacobianIndices);
m_InitialTransform->TransformPoint(inputPoint), sj1, jsj, nonZeroJacobianIndices);

sj = sj1 * sj0;
jsj.resize(nonZeroJacobianIndices.size());
for (unsigned int mu = 0; mu < nonZeroJacobianIndices.size(); ++mu)
for (auto & matrix : jsj)
{
jsj[mu] = jsj1[mu] * sj0;
matrix *= sj0;
}

} // end GetJacobianOfSpatialJacobianUseComposition()
Expand Down