22 #ifndef LSST_AFW_MATH_POLYNOMIALS_Function2d_h_INCLUDED
23 #define LSST_AFW_MATH_POLYNOMIALS_Function2d_h_INCLUDED
29 namespace lsst {
namespace geom {
namespace polynomials {
41 template <
typename Basis_>
57 _coefficients(Eigen::VectorXd::Zero(basis.
size()))
63 _coefficients(coefficients)
65 assert(basis.size() ==
static_cast<std::size_t>(_coefficients.size()));
69 template <
typename Iterator>
72 _coefficients(basis.
size())
75 std::copy(first, last, &_coefficients[0]);
111 return _basis.sumWith(point, _coefficients, mode);
116 return _basis.sumWith(point, _coefficients, workspace, mode);
138 return _coefficients.head(
size());
150 Eigen::VectorXd _coefficients;
154 template <
typename Basis>
160 template <
typename Basis,
typename Iterator>
A 2-d function defined by a series expansion and its coefficients.
Function2d & operator=(Function2d &&)=default
Default move assignment.
Function2d(Basis const &basis, Eigen::VectorXd const &coefficients)
Construct with coefficients from an Eigen object.
Workspace makeWorkspace() const
Allocate workspace that can be passed to operator() to avoid repeated memory allocations.
auto getCoefficients()
Return the coefficient vector as an Eigen matrix-like object.
Basis const & getBasis() const
Return the associated Basis2d object.
Function2d(Function2d &&)=default
Default move constructor.
const_iterator end() const
const_iterator cbegin() const
double & operator[](std::size_t n)
Return the coefficient associated with the nth basis function.
double const * const_iterator
std::size_t size() const
Return the number of coefficients.
Basis_ Basis
The basis type used by this function.
typename Basis::Workspace Workspace
Type returned by makeWorkspace().
auto getCoefficients() const
double operator()(geom::Point2D const &point, Workspace &workspace, SumMode mode=SumMode::FAST) const
Evaluate the function at the given point.
const_iterator begin() const
double operator()(geom::Point2D const &point, SumMode mode=SumMode::FAST) const
Evaluate the function at the given point.
double const & operator[](std::size_t n) const
Function2d(Basis const &basis)
Construct with zero-valued coefficients.
Function2d(Basis const &basis, Iterator first, Iterator last)
Construct by copying coefficients from an STL iterator range.
Function2d(Function2d const &)=default
Default copy constructor.
const_iterator cend() const
Function2d & operator=(Function2d const &)=default
Default copy assignment.
Function2d< typename Basis::Scaled > scaled(Scaling2d const &scaling) const
Return a new function that applies the given scaling to all points before evaluation.
iterator begin()
Iterators over coefficients.
A 2-d separable affine transform that can be used to map one interval to another.
Function2d< Basis > makeFunction2d(Basis const &basis, Eigen::VectorXd const &coefficients)
Create a Function2d of the appropriate type from a Basis2d and an Eigen object containing coefficient...
SumMode
Enum used to control how to sum polynomial terms.
@ FAST
Summation using regular floating-point addition.