Closed N-Dekker closed 1 month ago
@thewtex Would this PR still be feasible for v5.4.0? It just adds constexpr
keywords to front()
and back()
member functions.
FYI, Adding constexpr to itk::Index::back()
would be a stepping stone towards evaluating the OffsetToIndexTable of BSplineInterpolationWeightFunction
at compile-time, instead of at run-time:
https://github.com/InsightSoftwareConsortium/ITK/blob/4d750726d06ba28c601b8a4bfac8780baa395ff1/Modules/Core/Common/include/itkBSplineInterpolationWeightFunction.h#L124
Which is likely to speed up BSplineInterpolationWeightFunction::Evaluate
:
@thewtex Would this PR still be feasible for v5.4.0? It just adds
constexpr
keywords tofront()
andback()
member functions.
Out of my curiosity, is this for a particular issue? Has it given any measurable performance benefit?
Out of my curiosity, is this for a particular issue? Has it given any measurable performance benefit?
This PR would pave the way to adding constexpr to itk::Index
iteration, by itk::IndexRange
. Which would allow creating the OffsetToIndexTable of BSplineInterpolationWeightFunction at compile-time, instead of at run-time. I haven't yet been able to benchmark, but it may certainly benefit its performance.
Note that itk::Index<N>
is similar to std::array<itk::IndexValueType, N>
, whose front()
and back()
are also marked "constexpr": https://en.cppreference.com/w/cpp/container/array/back
I think we should save it for ITK 6 to avoid any unforeseen issues.
@thewtex OK, thanks. Marked "draft" to avoid that this PR might accidentally be merged before the release of ITK 5.4!
I think this pull request may also be merged now, as v5.4.0 has been tagged (https://github.com/InsightSoftwareConsortium/ITK/pull/4603#issuecomment-2120498131)
Follow-up to pull request https://github.com/InsightSoftwareConsortium/ITK/pull/3236 commit 47bce264791a53853020a3911dd94d060cfbd655 "ENH: Declare begin(), end() of FixedArray, Index, Offset, Size constexpr"