-
-
Notifications
You must be signed in to change notification settings - Fork 723
PERF: Use FixedArray for table within BSplineInterpolationWeightFunction #2721
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| #include "itkContinuousIndex.h" | ||
| #include "itkArray.h" | ||
| #include "itkArray2D.h" | ||
| #include "itkIndexRange.h" | ||
| #include "itkMath.h" | ||
|
|
||
| namespace itk | ||
|
|
@@ -112,15 +113,21 @@ class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction | |
| #endif | ||
|
|
||
| protected: | ||
| BSplineInterpolationWeightFunction(); | ||
| BSplineInterpolationWeightFunction() = default; | ||
| ~BSplineInterpolationWeightFunction() override = default; | ||
|
|
||
| private: | ||
| /** Lookup table type. */ | ||
| using TableType = Array2D<unsigned int>; | ||
| using TableType = FixedArray<IndexType, NumberOfWeights>; | ||
|
|
||
| /** Table mapping linear offset to indices. */ | ||
| TableType m_OffsetToIndexTable; | ||
| const TableType m_OffsetToIndexTable{ [] { | ||
| TableType table; | ||
| // Note: Copied the constexpr value `SupportSize` to a temporary, `SizeType{ SupportSize }`, to prevent a GCC | ||
| // (Ubuntu 7.5.0-3ubuntu1~18.04) link error, "undefined reference to `SupportSize`". | ||
| std::copy_n(ZeroBasedIndexRange<SpaceDimension>(SizeType{ SupportSize }).cbegin(), NumberOfWeights, table.begin()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it isn't making sense to defined const auto supportSize {Self::SupportSize};As to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Leengit Indeed, it appears that the link error could also be avoided by a local In general, it might become cumbersome to spell out the type name of the The value of the constexpr Do you like that? 😺
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fear that it will give the same errors that we are already / still seeing in cdash. But if it doesn't then I like it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Leengit Try it out at https://godbolt.org/z/YGTh9q1Po 😃 As follows (using GCC 10.3):
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Leengit Related section from https://github.com/cplusplus/draft/releases/download/n4892/n4892.pdf (C++ Working Draft, 2021-06-18): D.7 Redeclaration of static constexpr data members [depr.static.constexpr] 1 For compatibility with prior revisions of C++, a constexpr static data member may be redundantly redeclared — end example]
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a good idea. Is this for C++23? Do they have an alternative way of making references and pointers work for class static constexpr members, or are they saying that the class declaration needs to be sufficient? |
||
| return table; | ||
| }() }; | ||
| }; | ||
| } // end namespace itk | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.