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