22 #ifndef LSST_AFW_MATH_POLYNOMIALS_PackedBasis2d_h_INCLUDED 23 #define LSST_AFW_MATH_POLYNOMIALS_PackedBasis2d_h_INCLUDED 30 namespace lsst {
namespace geom {
namespace polynomials {
32 template <
typename Basis1d, PackingOrder packing>
51 template <
typename Recurrence, PackingOrder packing>
58 template <
typename Basis>
74 template <
typename Basis1d, PackingOrder packing>
97 template <
typename ...Args>
125 return Scaled(*
this, first);
130 return IndexRange::computeIndex(x, y);
181 template <
typename Vector>
185 _basis1d.fill(point.getX(), workspace._x);
186 _basis1d.fill(point.getY(), workspace._y);
190 auto accumulate = [
coefficients, &workspace,
this](
auto & sum) {
191 for (
auto const & index : getIndices()) {
192 sum += coefficients[index.flat]*workspace._x[index.nx]*workspace._y[index.ny];
203 result =
static_cast<double>(
z);
209 template <
typename Vector>
212 auto workspace = makeWorkspace();
213 return sumWith(point, coefficients, workspace, mode);
227 template <
typename Vector>
230 _basis1d.fill(point.getX(), workspace._x);
231 _basis1d.fill(point.getY(), workspace._y);
232 for (
auto const & index : getIndices()) {
233 std::forward<Vector>(
basis)[index.flat] = workspace._x[index.nx]*workspace._y[index.ny];
238 template <
typename Vector>
240 auto workspace = makeWorkspace();
241 fill(point, std::forward<Vector>(
basis), workspace);
250 #endif // !LSST_AFW_MATH_POLYNOMIALS_PackedBasis2d_h_INCLUDED
PackedBasisWorkspace2d(std::size_t order)
Construct workspace for a basis with the given order.
std::size_t getOrder() const noexcept
Return the maximum order of the basis.
friend class PackedBasis2d
Summation using regular floating-point addition.
Workspace makeWorkspace() const
Allocate a workspace that can be passed to sumWith() and fill() to avoid repeated memory allocations...
double sumWith(geom::Point2D const &point, Vector const &coefficients, SumMode mode=SumMode::FAST) const
Evaluate a basis expansion with the given coefficients (internal workspace version).
A numerically stable summation algorithm for floating-point numbers.
void fill(geom::Point2D const &point, Vector &&basis, Workspace &workspace) const
Evaluate the basis at a given point.
A 2-d function defined by a series expansion and its coefficients.
A specialized iterator range class for PackedIndexIterator, providing size calculation, comparison, and range-based for support.
int computeSize(int order)
Return the size of the coefficient vector for the given order.
std::size_t size() const noexcept
Return the number of basis functions.
SumMode
Enum used to control how to sum polynomial terms.
void fill(geom::Point2D const &point, Vector &&basis) const
Evaluate the basis at a given point (internal workspace version).
A 2-d separable affine transform that can be used to map one interval to another. ...
double sumWith(geom::Point2D const &point, Vector const &coefficients, Workspace &workspace, SumMode mode=SumMode::FAST) const
Evaluate a basis expansion with the given coefficients.
A base class for image defects.
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Typedefs to be used for probability and parameter values.
An iterator for traversing "packed" triangular 2-d series expansions, in which two 1-d expansions are...
PackedBasis2d(Args &&...args)
Construct by forwarding all arguments to the 1-d basis constructor.
table::Key< table::Array< double > > basis
IndexRange getIndices() const noexcept
Return a range of iterators that dereference to Index2d.
A 2-d basis that transforms all input points before evaluating nested basis.
std::size_t getOrder() const
Return the maximum order this workspace supports.
A Basis2d formed from the product of a Basis1d for each of x and y, truncated at the sum of their ord...
PackedBasis2d(Basis1d const &basis1d)
Construct from a 1-d basis that will be used for both x and y.
A basis interface for 1-d series expansions.
A workspace object that can be used to avoid extra memory allocations in repeated calls to PackedBasi...
Scaled scaled(Scaling2d const &first) const
Return a scaled basis that delegates to a copy of this.
static constexpr std::size_t computeSize(std::size_t order)
Return the size of a PackedBasis with the given order.
std::size_t index(std::size_t x, std::size_t y) const
Return the flattened index of the basis function with the given x and y orders.
ndarray::Array< double const, 2, 2 > coefficients