22 #ifndef LSST_AFW_MATH_POLYNOMIALS_PackedIndex_h_INCLUDED 23 #define LSST_AFW_MATH_POLYNOMIALS_PackedIndex_h_INCLUDED 25 namespace lsst {
namespace geom {
namespace polynomials {
72 constexpr
Index2d() noexcept : flat(0), nx(0), ny(0) {}
76 flat(flat_), nx(nx_), ny(ny_)
86 return !(*
this ==
other);
108 index.
ny = index.
nx + 1;
130 index.
nx = index.
ny + 1;
163 template <PackingOrder packing>
176 return order*(order + 1)/2;
186 return computeOffset(nx + ny) + Traits::computeInnerIndex(nx, ny);
199 _index(computeIndex(nx, ny), nx, ny)
211 Traits::increment(_index);
224 return _index ==
other._index;
229 return !(*
this ==
other);
235 _index(
computeOffset(order + 1), Traits::getEndX(order), Traits::getEndY(order))
247 template <PackingOrder packing>
271 return iterator::computeIndex(nx, ny);
296 constexpr
bool empty() const noexcept {
return size() == 0u; }
300 return _begin ==
other._begin && _end ==
other._end;
305 return !(*
this ==
other);
315 #endif // !LSST_AFW_MATH_POLYNOMIALS_PackedIndex_h_INCLUDED
constexpr Index2d() noexcept
Construct an index with zero entries.
constexpr PackedIndexRange(iterator first, iterator last) noexcept
Construct from begin and end iterators.
static constexpr std::size_t computeIndex(std::size_t nx, std::size_t ny) noexcept
Return the flattened index for the element with the given x and y orders.
static constexpr std::size_t computeSize(std::size_t order) noexcept
Return the flattened size of an expansion with the given maximum order (inclusive).
constexpr pointer operator->() const noexcept
Dereference the iterator, yielding a Index2d const pointer.
static std::size_t getEndY(std::size_t order)
static std::size_t computeInnerIndex(std::size_t nx, std::size_t ny)
constexpr iterator end() const noexcept
Return an iterator to one past the end of the range.
PackedIndexIterator operator++(int) noexcept
Move to the next element in the packed array and return a copy of the iterator before the move...
std::size_t nx
Index into the 1-d function for nx.
A pair of indices is mapped to the flattened position , which yields the (nx, ny) ordering ``` (0...
constexpr PackedIndexIterator(std::size_t nx, std::size_t ny) noexcept
Construct an iterator pointing to the element with the given x and y orders.
std::size_t ny
Index into the 1-d functoin for ny.
typename iterator::pointer pointer
constexpr bool operator==(PackedIndexIterator const &other) const noexcept
Equality comparison.
constexpr iterator cend() const noexcept
Return an iterator to one past the end of the range.
ItemVariant const * other
constexpr Index2d(std::size_t flat_, std::size_t nx_, std::size_t ny_) noexcept
Construct with the provided values.
A specialized iterator range class for PackedIndexIterator, providing size calculation, comparison, and range-based for support.
typename iterator::difference_type difference_type
int computeSize(int order)
Return the size of the coefficient vector for the given order.
A custom tuple that relates the indices of two 1-d functions for x and y to the flattened index for t...
static constexpr std::size_t computeOffset(std::size_t order) noexcept
Return the flattened offset to the start of the given order.
constexpr bool operator!=(Index2d const &other) const noexcept
Inequality comparison.
static std::size_t getEndX(std::size_t order)
A base class for image defects.
static constexpr std::size_t computeSize(std::size_t order) noexcept
Return the flattened size of an expansion with the given maximum order (inclusive).
A pair of indices is mapped to the flattened position , which yields the (nx, ny) ordering ``` (0...
constexpr bool empty() const noexcept
Return true if the number of elements in the flattened expansion is zero.
constexpr iterator cbegin() const noexcept
Return an iterator to the start of the range.
An iterator for traversing "packed" triangular 2-d series expansions, in which two 1-d expansions are...
constexpr bool operator!=(PackedIndexIterator const &other) const noexcept
Inequality comparison.
static std::size_t getEndY(std::size_t order)
typename iterator::reference reference
constexpr reference operator*() const noexcept
Dereference the iterator, yielding a Index2d const reference.
static constexpr std::size_t computeIndex(std::size_t nx, std::size_t ny) noexcept
Return the flattened index for the element with the given x and y orders.
static constexpr PackedIndexIterator makeEnd(std::size_t order) noexcept
Construct an iterator one past the end of an expansion with the given order.
static std::size_t computeInnerIndex(std::size_t nx, std::size_t ny)
static void increment(Index2d &index)
static std::size_t getEndX(std::size_t order)
PackedIndexIterator & operator++() noexcept
Move to the next element in the packed array and return the iterator.
constexpr bool operator==(Index2d const &other) const noexcept
Equality comparison.
constexpr bool operator==(PackedIndexRange const &other) const noexcept
Equality comparison.
std::size_t flat
Index into the flattened 2-d function.
static constexpr std::size_t computeOffset(std::size_t order) noexcept
Return the flattened offset to the start of the given order.
int computeOffset(int order)
Return the offset of the given order in a coefficient vector.
constexpr bool operator!=(PackedIndexRange const &other) const noexcept
Inequality comparison.
constexpr PackedIndexIterator() noexcept
Construct an iterator at the beginning of an expansion of any order.
typename iterator::value_type value_type
constexpr iterator begin() const noexcept
Return an iterator to the start of the range.
PackingOrder
Enum defining the packing orders used to order 2-d polynomial coefficients.
constexpr std::size_t size() const noexcept
Return the number of elements in the flattened expansion.
static void increment(Index2d &index)
Index2d const & reference