LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Namespaces | Classes | Typedefs | Enumerations | Functions
lsst::geom::polynomials Namespace Reference

Low-level polynomials (including special polynomials) in C++. More...

Namespaces

 detail
 

Classes

class  Basis1d
 A basis interface for 1-d series expansions. More...
 
class  Basis2d
 A basis interface for 2-d series expansions. More...
 
class  BinomialMatrix
 A class that computes binomial coefficients up to a certain power. More...
 
class  Chebyshev1Recurrence
 A Recurrence for Chebyshev polynomials of the first kind. More...
 
class  Function1d
 A 1-d function defined by a series expansion and its coefficients. More...
 
class  Function2d
 A 2-d function defined by a series expansion and its coefficients. More...
 
class  PackedBasis2d
 A Basis2d formed from the product of a Basis1d for each of x and y, truncated at the sum of their orders. More...
 
class  PackedBasisWorkspace2d
 A workspace object that can be used to avoid extra memory allocations in repeated calls to PackedBasis2d methods. More...
 
struct  Index2d
 A custom tuple that relates the indices of two 1-d functions for x and y to the flattened index for the 2-d function they form. More...
 
class  PackedIndexIterator
 An iterator for traversing "packed" triangular 2-d series expansions, in which two 1-d expansions are truncated according to the sum of their orders and all values for one order are stored before any values of the subsequent order. More...
 
class  PackedIndexRange
 A specialized iterator range class for PackedIndexIterator, providing size calculation, comparison, and range-based for support. More...
 
class  PolynomialRecurrence
 A Recurrence for standard polynomials. More...
 
struct  Recurrence
 A recurrence relation concept for RecurrenceBasis1d. More...
 
class  RecurrenceBasis1d
 A basis for 1-d series expansions defined by a recurrence relation. More...
 
class  SafeSum
 A numerically stable summation algorithm for floating-point numbers. More...
 
class  ScaledBasis1d
 A 1-d basis that transforms all input points before evaluating nested basis. More...
 
class  ScaledBasis2d
 A 2-d basis that transforms all input points before evaluating nested basis. More...
 
class  Scaling1d
 A 1-d affine transform that can be used to map one interval to another. More...
 
class  Scaling2d
 A 2-d separable affine transform that can be used to map one interval to another. More...
 

Typedefs

using Chebyshev1Basis1d = RecurrenceBasis1d< Chebyshev1Recurrence >
 A Basis1d for Chebyshev polynomials of the first kind. More...
 
using ScaledChebyshev1Basis1d = ScaledBasis1d< Chebyshev1Basis1d >
 A Basis1d for scaled Chebyshev polynomials of the first kind. More...
 
template<PackingOrder packing>
using Chebyshev1Basis2d = PackedBasis2d< Chebyshev1Basis1d, packing >
 A Basis2d for Chebyshev polynomials of the first kind, templated on packing order. More...
 
template<PackingOrder packing>
using ScaledChebyshev1Basis2d = ScaledBasis2d< Chebyshev1Basis2d< packing > >
 A Basis2d for scaled Chebyshev polynomials of the first kind, templated on packing order. More...
 
using Chebyshev1Basis2dXY = Chebyshev1Basis2d< PackingOrder::XY >
 A Basis2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::XY. More...
 
using Chebyshev1Basis2dYX = Chebyshev1Basis2d< PackingOrder::YX >
 A Basis2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::YX. More...
 
using ScaledChebyshev1Basis2dXY = ScaledChebyshev1Basis2d< PackingOrder::XY >
 A Basis2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::XY. More...
 
using ScaledChebyshev1Basis2dYX = ScaledChebyshev1Basis2d< PackingOrder::YX >
 A Basis2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::YX. More...
 
using Chebyshev1Function1d = Function1d< Chebyshev1Basis1d >
 A Function1d for Chebyshev polynomials of the first kind. More...
 
using ScaledChebyshev1Function1d = Function1d< ScaledChebyshev1Basis1d >
 A Function1d for scaled Chebyshev polynomials of the first kind. More...
 
template<PackingOrder packing>
using Chebyshev1Function2d = Function2d< Chebyshev1Basis2d< packing > >
 A Function2d for Chebyshev polynomials of the first kind, templated on packing order. More...
 
template<PackingOrder packing>
using ScaledChebyshev1Function2d = Function2d< ScaledChebyshev1Basis2d< packing > >
 A Function2d for scaled Chebyshev polynomials of the first kind, templated on packing order. More...
 
using Chebyshev1Function2dXY = Chebyshev1Function2d< PackingOrder::XY >
 A Function2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::XY. More...
 
using Chebyshev1Function2dYX = Chebyshev1Function2d< PackingOrder::YX >
 A Function2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::YX. More...
 
using ScaledChebyshev1Function2dXY = ScaledChebyshev1Function2d< PackingOrder::XY >
 A Function2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::XY. More...
 
using ScaledChebyshev1Function2dYX = ScaledChebyshev1Function2d< PackingOrder::YX >
 A Function2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::YX. More...
 
using PolynomialBasis1d = RecurrenceBasis1d< PolynomialRecurrence >
 A Basis1d for standard polynomials. More...
 
using ScaledPolynomialBasis1d = ScaledBasis1d< PolynomialBasis1d >
 A ScaledBasis1d for standard polynomials. More...
 
template<PackingOrder packing>
using PolynomialBasis2d = PackedBasis2d< PolynomialBasis1d, packing >
 A Basis2d for standard polynomials, templated on packing order. More...
 
template<PackingOrder packing>
using ScaledPolynomialBasis2d = ScaledBasis2d< PolynomialBasis2d< packing > >
 A Basis2d for scaled standard polynomials, templated on packing order. More...
 
using PolynomialBasis2dXY = PolynomialBasis2d< PackingOrder::XY >
 A Basis2d for standard polynomials, ordered via PackingOrder::XY. More...
 
using PolynomialBasis2dYX = PolynomialBasis2d< PackingOrder::YX >
 A Basis2d for standard polynomials, ordered via PackingOrder::YX. More...
 
using ScaledPolynomialBasis2dXY = ScaledPolynomialBasis2d< PackingOrder::XY >
 A Basis2d for scaled standard polynomials, ordered via PackingOrder::XY. More...
 
using ScaledPolynomialBasis2dYX = ScaledPolynomialBasis2d< PackingOrder::YX >
 A Basis2d for scaled standard polynomials, ordered via PackingOrder::YX. More...
 
using PolynomialFunction1d = Function1d< PolynomialBasis1d >
 A Function1d for standard polynomials. More...
 
using ScaledPolynomialFunction1d = Function1d< ScaledPolynomialBasis1d >
 A Function1d for scaled standard polynomials. More...
 
template<PackingOrder packing>
using PolynomialFunction2d = Function2d< PolynomialBasis2d< packing > >
 A Function2d for standard polynomials. More...
 
template<PackingOrder packing>
using ScaledPolynomialFunction2d = Function2d< ScaledPolynomialBasis2d< packing > >
 A Function2d for scaled standard polynomials. More...
 
using PolynomialFunction2dXY = PolynomialFunction2d< PackingOrder::XY >
 A Function2d for standard polynomials, ordered via PackingOrder::XY. More...
 
using PolynomialFunction2dYX = PolynomialFunction2d< PackingOrder::YX >
 A Function2d for standard polynomials, ordered via PackingOrder::YX. More...
 
using ScaledPolynomialFunction2dXY = ScaledPolynomialFunction2d< PackingOrder::XY >
 A Function2d for scaled standard polynomials, ordered via PackingOrder::XY. More...
 
using ScaledPolynomialFunction2dYX = ScaledPolynomialFunction2d< PackingOrder::YX >
 A Function2d for scaled standard polynomials, ordered via PackingOrder::YX. More...
 

Enumerations

enum class  PackingOrder { YX , XY }
 Enum defining the packing orders used to order 2-d polynomial coefficients. More...
 
enum class  SumMode { FAST , SAFE }
 Enum used to control how to sum polynomial terms. More...
 

Functions

template<typename Basis >
Function1d< Basis > makeFunction1d (Basis const &basis, Eigen::VectorXd const &coefficients)
 Create a Function1d of the appropriate type from a Basis1d and an Eigen object containing coefficients. More...
 
template<typename Basis , typename Iterator >
Function1d< Basis > makeFunction1d (Basis const &basis, Iterator first, Iterator last)
 Create a Function1d of the appropriate type from a Basis1d and an iterator range to copy coefficients from. More...
 
template<typename Basis >
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 coefficients. More...
 
template<typename Basis , typename Iterator >
Function2d< Basis > makeFunction2d (Basis const &basis, Iterator first, Iterator last)
 Create a Function2d of the appropriate type from a Basis2d and an iterator range to copy coefficients from. More...
 
PolynomialFunction1d simplified (ScaledPolynomialFunction1d const &f)
 Calculate the standard polynomial function that is equivalent to a scaled standard polynomial function. More...
 
template<PackingOrder packing>
PolynomialFunction2d< packing > simplified (ScaledPolynomialFunction2d< packing > const &f)
 Calculate the standard polynomial function that is equivalent to a scaled standard polynomial function. More...
 
Scaling1d makeUnitRangeScaling1d (double min, double max) noexcept
 Return a Scaling1d that maps the interval [min, max] to [-1, 1]. More...
 
Scaling2d makeUnitRangeScaling2d (geom::Box2D const &box)
 Return a Scaling1d that maps the given box to [-1, 1]x[-1, 1]. More...
 
template PolynomialFunction2d< PackingOrder::XYsimplified (ScaledPolynomialFunction2d< PackingOrder::XY > const &)
 
template PolynomialFunction2d< PackingOrder::YXsimplified (ScaledPolynomialFunction2d< PackingOrder::YX > const &)
 

Detailed Description

Low-level polynomials (including special polynomials) in C++.

The geom::polynomials library provides low-level classes for efficiently evaluating polynomial basis functions and expansions in C++. The classes here:

They are intended to be used as the building blocks of higher-level objects that are visible to Python users and persisted with our data products, such as afw::math::ChebyshevBoundedField and the afw::math::Function hierarchy.

At present, the library only includes support for 1-d and 2-d standard polynomials and Chebyshev polynomials of the first kind, but adding support for any other function defined by a recurrence relation (i.e. any other special polynomial) should be extremely easy (see RecurrenceBasis1d), and need not be done within the polynomials library itself.

For both 1-d and 2-d, the library contains the following kinds of objects:

The library also includes a few utility classes and functions:

Typedef Documentation

◆ Chebyshev1Basis1d

A Basis1d for Chebyshev polynomials of the first kind.

Definition at line 48 of file Chebyshev1Basis1d.h.

◆ Chebyshev1Basis2d

template<PackingOrder packing>
using lsst::geom::polynomials::Chebyshev1Basis2d = typedef PackedBasis2d<Chebyshev1Basis1d, packing>

A Basis2d for Chebyshev polynomials of the first kind, templated on packing order.

Definition at line 34 of file Chebyshev1Basis2d.h.

◆ Chebyshev1Basis2dXY

A Basis2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::XY.

Definition at line 41 of file Chebyshev1Basis2d.h.

◆ Chebyshev1Basis2dYX

A Basis2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::YX.

Definition at line 44 of file Chebyshev1Basis2d.h.

◆ Chebyshev1Function1d

A Function1d for Chebyshev polynomials of the first kind.

Definition at line 31 of file Chebyshev1Function1d.h.

◆ Chebyshev1Function2d

template<PackingOrder packing>
using lsst::geom::polynomials::Chebyshev1Function2d = typedef Function2d<Chebyshev1Basis2d<packing> >

A Function2d for Chebyshev polynomials of the first kind, templated on packing order.

Definition at line 32 of file Chebyshev1Function2d.h.

◆ Chebyshev1Function2dXY

A Function2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::XY.

Definition at line 39 of file Chebyshev1Function2d.h.

◆ Chebyshev1Function2dYX

A Function2d for Chebyshev polynomials of the first kind, ordered via PackingOrder::YX.

Definition at line 42 of file Chebyshev1Function2d.h.

◆ PolynomialBasis1d

A Basis1d for standard polynomials.

Definition at line 50 of file PolynomialBasis1d.h.

◆ PolynomialBasis2d

template<PackingOrder packing>
using lsst::geom::polynomials::PolynomialBasis2d = typedef PackedBasis2d<PolynomialBasis1d, packing>

A Basis2d for standard polynomials, templated on packing order.

Definition at line 34 of file PolynomialBasis2d.h.

◆ PolynomialBasis2dXY

A Basis2d for standard polynomials, ordered via PackingOrder::XY.

Definition at line 41 of file PolynomialBasis2d.h.

◆ PolynomialBasis2dYX

A Basis2d for standard polynomials, ordered via PackingOrder::YX.

Definition at line 44 of file PolynomialBasis2d.h.

◆ PolynomialFunction1d

A Function1d for standard polynomials.

Definition at line 31 of file PolynomialFunction1d.h.

◆ PolynomialFunction2d

template<PackingOrder packing>
using lsst::geom::polynomials::PolynomialFunction2d = typedef Function2d<PolynomialBasis2d<packing> >

A Function2d for standard polynomials.

Definition at line 32 of file PolynomialFunction2d.h.

◆ PolynomialFunction2dXY

A Function2d for standard polynomials, ordered via PackingOrder::XY.

Definition at line 39 of file PolynomialFunction2d.h.

◆ PolynomialFunction2dYX

A Function2d for standard polynomials, ordered via PackingOrder::YX.

Definition at line 42 of file PolynomialFunction2d.h.

◆ ScaledChebyshev1Basis1d

A Basis1d for scaled Chebyshev polynomials of the first kind.

Definition at line 51 of file Chebyshev1Basis1d.h.

◆ ScaledChebyshev1Basis2d

template<PackingOrder packing>
using lsst::geom::polynomials::ScaledChebyshev1Basis2d = typedef ScaledBasis2d<Chebyshev1Basis2d<packing> >

A Basis2d for scaled Chebyshev polynomials of the first kind, templated on packing order.

Definition at line 38 of file Chebyshev1Basis2d.h.

◆ ScaledChebyshev1Basis2dXY

A Basis2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::XY.

Definition at line 47 of file Chebyshev1Basis2d.h.

◆ ScaledChebyshev1Basis2dYX

A Basis2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::YX.

Definition at line 50 of file Chebyshev1Basis2d.h.

◆ ScaledChebyshev1Function1d

A Function1d for scaled Chebyshev polynomials of the first kind.

Definition at line 34 of file Chebyshev1Function1d.h.

◆ ScaledChebyshev1Function2d

template<PackingOrder packing>
using lsst::geom::polynomials::ScaledChebyshev1Function2d = typedef Function2d<ScaledChebyshev1Basis2d<packing> >

A Function2d for scaled Chebyshev polynomials of the first kind, templated on packing order.

Definition at line 36 of file Chebyshev1Function2d.h.

◆ ScaledChebyshev1Function2dXY

A Function2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::XY.

Definition at line 45 of file Chebyshev1Function2d.h.

◆ ScaledChebyshev1Function2dYX

A Function2d for scaled Chebyshev polynomials of the first kind, ordered via PackingOrder::YX.

Definition at line 48 of file Chebyshev1Function2d.h.

◆ ScaledPolynomialBasis1d

A ScaledBasis1d for standard polynomials.

Definition at line 53 of file PolynomialBasis1d.h.

◆ ScaledPolynomialBasis2d

template<PackingOrder packing>
using lsst::geom::polynomials::ScaledPolynomialBasis2d = typedef ScaledBasis2d<PolynomialBasis2d<packing> >

A Basis2d for scaled standard polynomials, templated on packing order.

Definition at line 38 of file PolynomialBasis2d.h.

◆ ScaledPolynomialBasis2dXY

A Basis2d for scaled standard polynomials, ordered via PackingOrder::XY.

Definition at line 47 of file PolynomialBasis2d.h.

◆ ScaledPolynomialBasis2dYX

A Basis2d for scaled standard polynomials, ordered via PackingOrder::YX.

Definition at line 50 of file PolynomialBasis2d.h.

◆ ScaledPolynomialFunction1d

A Function1d for scaled standard polynomials.

Definition at line 34 of file PolynomialFunction1d.h.

◆ ScaledPolynomialFunction2d

template<PackingOrder packing>
using lsst::geom::polynomials::ScaledPolynomialFunction2d = typedef Function2d<ScaledPolynomialBasis2d<packing> >

A Function2d for scaled standard polynomials.

Definition at line 36 of file PolynomialFunction2d.h.

◆ ScaledPolynomialFunction2dXY

A Function2d for scaled standard polynomials, ordered via PackingOrder::XY.

Definition at line 45 of file PolynomialFunction2d.h.

◆ ScaledPolynomialFunction2dYX

A Function2d for scaled standard polynomials, ordered via PackingOrder::YX.

Definition at line 48 of file PolynomialFunction2d.h.

Enumeration Type Documentation

◆ PackingOrder

Enum defining the packing orders used to order 2-d polynomial coefficients.

Enumerator
YX 

A pair of indices \((nx, ny)\) is mapped to the flattened position \(i = (nx+ny)(nx+ny+1)/2 + nx\), which yields the (nx, ny) ordering.

(0, 0), (0, 1), (1, 0), (0, 2), (1, 1), (2, 0), ...

In other words, if \(a_i\) are the coefficients of a 2-d polynomial expansion with order=2, the full polynomial is:

\[ a_0 + a_1 y + a_2 x + a_3 y^2 + a_4 x y + a_5 x^2 \]

XY 

A pair of indices \((nx, ny)\) is mapped to the flattened position \(i = (nx+ny)(nx+ny+1)/2 + ny\), which yields the (nx, ny) ordering.

(0, 0), (1, 0), (0, 1), (2, 0), (1, 1), (0, 2), ...

In other words, if \(a_i\) are the coefficients of a 2-d polynomial expansion with order=2, the full polynomial is:

\[ a_0 + a_1 x + a_2 y + a_3 x^2 + a_4 x y + a_5 y^2 \]

Definition at line 28 of file PackedIndex.h.

28  {
29 
43  YX,
44 
58  XY
59 };
@ 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.

◆ SumMode

Enum used to control how to sum polynomial terms.

Enumerator
FAST 

Summation using regular floating-point addition.

SAFE 

Compensated summation using SafeSum. Involves ~4x as many floating point operations.

Definition at line 32 of file SafeSum.h.

32  {
34  FAST,
36  SAFE
37 };
@ SAFE
Compensated summation using SafeSum. Involves ~4x as many floating point operations.
@ FAST
Summation using regular floating-point addition.

Function Documentation

◆ makeFunction1d() [1/2]

template<typename Basis >
Function1d<Basis> lsst::geom::polynomials::makeFunction1d ( Basis const &  basis,
Eigen::VectorXd const &  coefficients 
)

Create a Function1d of the appropriate type from a Basis1d and an Eigen object containing coefficients.

Definition at line 144 of file Function1d.h.

144  {
145  return Function1d<Basis>(basis, coefficients);
146 }
ndarray::Array< double const, 2, 2 > coefficients
table::Key< table::Array< double > > basis
Definition: PsfexPsf.cc:361

◆ makeFunction1d() [2/2]

template<typename Basis , typename Iterator >
Function1d<Basis> lsst::geom::polynomials::makeFunction1d ( Basis const &  basis,
Iterator  first,
Iterator  last 
)

Create a Function1d of the appropriate type from a Basis1d and an iterator range to copy coefficients from.

Definition at line 150 of file Function1d.h.

150  {
151  return Function1d<Basis>(basis, first, last);
152 }

◆ makeFunction2d() [1/2]

template<typename Basis >
Function2d<Basis> lsst::geom::polynomials::makeFunction2d ( Basis const &  basis,
Eigen::VectorXd const &  coefficients 
)

Create a Function2d of the appropriate type from a Basis2d and an Eigen object containing coefficients.

Definition at line 155 of file Function2d.h.

155  {
156  return Function2d<Basis>(basis, coefficients);
157 }

◆ makeFunction2d() [2/2]

template<typename Basis , typename Iterator >
Function2d<Basis> lsst::geom::polynomials::makeFunction2d ( Basis const &  basis,
Iterator  first,
Iterator  last 
)

Create a Function2d of the appropriate type from a Basis2d and an iterator range to copy coefficients from.

Definition at line 161 of file Function2d.h.

161  {
162  return Function2d<Basis>(basis, first, last);
163 }

◆ makeUnitRangeScaling1d()

Scaling1d lsst::geom::polynomials::makeUnitRangeScaling1d ( double  min,
double  max 
)
inlinenoexcept

Return a Scaling1d that maps the interval [min, max] to [-1, 1].

Definition at line 120 of file Scaling1d.h.

120  {
121  return Scaling1d(2.0/(max - min), -0.5*(min + max));
122 }
int min
int max

◆ makeUnitRangeScaling2d()

Scaling2d lsst::geom::polynomials::makeUnitRangeScaling2d ( geom::Box2D const &  box)
inline

Return a Scaling1d that maps the given box to [-1, 1]x[-1, 1].

Definition at line 112 of file Scaling2d.h.

112  {
113  return Scaling2d(
114  makeUnitRangeScaling1d(box.getMinX(), box.getMaxX()),
115  makeUnitRangeScaling1d(box.getMinY(), box.getMaxY())
116  );
117 }
Scaling1d makeUnitRangeScaling1d(double min, double max) noexcept
Return a Scaling1d that maps the interval [min, max] to [-1, 1].
Definition: Scaling1d.h:120

◆ simplified() [1/4]

PolynomialFunction1d lsst::geom::polynomials::simplified ( ScaledPolynomialFunction1d const &  f)

Calculate the standard polynomial function that is equivalent to a scaled standard polynomial function.

The returned polynomial will course have different coefficients than the input one, as these need to account for the scaling without it being explicitly applied.

Definition at line 32 of file PolynomialFunction1d.cc.

32  {
33  auto const & basis = f.getBasis();
34  std::vector<SafeSum<double>> sums(basis.size());
35  double const s = basis.getScaling().getScale();
36  double const v = basis.getScaling().getShift();
37  double sn = 1; // s^n
38  BinomialMatrix binomial(basis.getNested().getOrder());
39  for (std::size_t n = 0; n < basis.size(); ++n, sn *= s) {
40  double vk = 1; // v^k
41  for (std::size_t k = 0; k <= n; ++k, vk *= v) {
42  sums[n - k] += sn*binomial(n, k)*f[n]*vk;
43  }
44  }
45  Eigen::VectorXd result = Eigen::VectorXd::Zero(basis.size());
46  for (std::size_t n = 0; n < basis.size(); ++n) {
47  result[n] = static_cast<double>(sums[n]);
48  }
49  return makeFunction1d(basis.getNested(), result);
50 }
py::object result
Definition: _schema.cc:429
Function1d< Basis > makeFunction1d(Basis const &basis, Eigen::VectorXd const &coefficients)
Create a Function1d of the appropriate type from a Basis1d and an Eigen object containing coefficient...
Definition: Function1d.h:144

◆ simplified() [2/4]

template<PackingOrder packing>
PolynomialFunction2d< packing > lsst::geom::polynomials::simplified ( ScaledPolynomialFunction2d< packing > const &  f)

Calculate the standard polynomial function that is equivalent to a scaled standard polynomial function.

The coefficients of the returned polynomial will be different from those of the input in order to fold in the scaling. This is primarily useful in contexts where external code does not support the (more numerically stable) scaled representation, such as the FITS WCS SIP convention.

Definition at line 47 of file PolynomialFunction2d.cc.

47  {
48  auto const & basis = f.getBasis();
49  std::vector<SafeSum<double>> sums(basis.size());
50  std::size_t const n = basis.getOrder();
51  auto rPow = computePowers(basis.getScaling().getX().getScale(), n);
52  auto sPow = computePowers(basis.getScaling().getY().getScale(), n);
53  auto uPow = computePowers(basis.getScaling().getX().getShift(), n);
54  auto vPow = computePowers(basis.getScaling().getY().getShift(), n);
55  BinomialMatrix binomial(basis.getNested().getOrder());
56  for (auto const & i : basis.getIndices()) {
57  for (std::size_t j = 0; j <= i.nx; ++j) {
58  double tmp = binomial(i.nx, j)*uPow[j] *
59  f[i.flat]*rPow[i.nx]*sPow[i.ny];
60  for (std::size_t k = 0; k <= i.ny; ++k) {
61  sums[basis.index(i.nx - j, i.ny - k)] +=
62  binomial(i.ny, k)*vPow[k]*tmp;
63  }
64  }
65  }
66  Eigen::VectorXd result = Eigen::VectorXd::Zero(basis.size());
67  for (std::size_t i = 0; i < basis.size(); ++i) {
68  result[i] = static_cast<double>(sums[i]);
69  }
70  return makeFunction2d(basis.getNested(), result);
71 }
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...
Definition: Function2d.h:155
void computePowers(Eigen::VectorXd &r, double x)
Fill an array with integer powers of x, so .

◆ simplified() [3/4]

template PolynomialFunction2d<PackingOrder::XY> lsst::geom::polynomials::simplified ( ScaledPolynomialFunction2d< PackingOrder::XY > const &  )

◆ simplified() [4/4]

template PolynomialFunction2d<PackingOrder::YX> lsst::geom::polynomials::simplified ( ScaledPolynomialFunction2d< PackingOrder::YX > const &  )