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
Public Member Functions | Public Attributes | List of all members
lsst::afw::math::detail::TrapezoidalPacker Struct Referencefinal

A helper class ChebyshevBoundedField, for mapping trapezoidal matrices to 1-d arrays. More...

#include <TrapezoidalPacker.h>

Public Member Functions

 TrapezoidalPacker (ChebyshevBoundedFieldControl const &ctrl)
 
void pack (ndarray::Array< double, 1, 1 > const &out, ndarray::Array< double const, 1, 1 > const &tx, ndarray::Array< double const, 1, 1 > const &ty) const
 
void pack (ndarray::Array< double, 1, 1 > const &out, ndarray::Array< double const, 2, 2 > const &unpacked) const
 
void unpack (ndarray::Array< double, 2, 2 > const &out, ndarray::Array< double const, 1, 1 > const &packed) const
 
ndarray::Array< double, 2, 2 > unpack (ndarray::Array< double const, 1, 1 > const &packed) const
 

Public Attributes

int nx
 
int ny
 
int m
 
int size
 

Detailed Description

A helper class ChebyshevBoundedField, for mapping trapezoidal matrices to 1-d arrays.

This class is not Swigged, and should not be included by any other .h files (including lsst/afw/math/detail.h); it's for internal use by ChebyshevBoundedField only, and it's only in a header file instead of that .cc file only so it can be unit tested.

We characterize the matrices by their number of columns (nx) and rows (ny), and the number of complete rows minus one (m).

This splits up the matrix into a rectangular part, in which the number of columns is the same for each row, and a wide trapezoidal or triangular part, in which the number of columns decreases by one for each row.

Here are some examples of how this class handles different kinds of matrices:

A wide trapezoidal matrix with orderX=4, orderY=3: nx=5, ny=4, m=0

0 1 2 3 4 5 6 7 8 9 10 11 12 13

A tall trapezoidal matrix with orderX=2, orderY=4 nx=3, ny=5, m=2

0 1 2 3 4 5 6 7 8 9 10 11

A triangular matrix with orderX=3, orderY=3 nx=4, ny=5, m=0

0 1 2 3 4 5 6 7 8 9

A wide rectangular matrix with orderX=3, orderY=2 nx=4, ny=3, m=3

0 1 2 3 4 5 6 7 8 9 10 11

A tall rectangular matrix with orderX=2, orderY=3 nx=3, ny=4, m=4

0 1 2 3 4 5 6 7 8 9 10 11

Definition at line 90 of file TrapezoidalPacker.h.

Constructor & Destructor Documentation

◆ TrapezoidalPacker()

lsst::afw::math::detail::TrapezoidalPacker::TrapezoidalPacker ( ChebyshevBoundedFieldControl const &  ctrl)
explicit

Definition at line 31 of file TrapezoidalPacker.cc.

32  : nx(ctrl.orderX + 1), ny(ctrl.orderY + 1) {
33  if (ctrl.triangular) {
34  if (nx >= ny) {
35  m = 0;
36  size = (nx - ny) * ny + (ny * (ny + 1)) / 2;
37  } else {
38  m = ny - nx;
39  size = m * nx + (nx * (nx + 1)) / 2;
40  }
41  } else {
42  m = ny;
43  size = nx * ny;
44  }
45 }

Member Function Documentation

◆ pack() [1/2]

void lsst::afw::math::detail::TrapezoidalPacker::pack ( ndarray::Array< double, 1, 1 > const &  out,
ndarray::Array< double const, 1, 1 > const &  tx,
ndarray::Array< double const, 1, 1 > const &  ty 
) const

Definition at line 47 of file TrapezoidalPacker.cc.

49  {
50  double* outIter = out.begin();
51  for (int i = 0; i < m; ++i) { // loop over rectangular part
52  for (int j = 0; j < nx; ++j, ++outIter) {
53  *outIter = ty[i] * tx[j];
54  }
55  }
56  for (int i = m; i < ny; ++i) { // loop over wide trapezoidal part
57  for (int j = 0, nj = nx + m - i; j < nj; ++j, ++outIter) {
58  *outIter = ty[i] * tx[j];
59  }
60  }
61 }

◆ pack() [2/2]

void lsst::afw::math::detail::TrapezoidalPacker::pack ( ndarray::Array< double, 1, 1 > const &  out,
ndarray::Array< double const, 2, 2 > const &  unpacked 
) const

Definition at line 63 of file TrapezoidalPacker.cc.

64  {
65  double* outIter = out.begin();
66  for (int i = 0; i < m; ++i) { // loop over rectangular part
67  ndarray::Array<double const, 1, 1> unpackedRow = unpacked[i];
68  for (int j = 0; j < nx; ++j, ++outIter) {
69  *outIter = unpackedRow[j];
70  }
71  }
72  for (int i = m; i < ny; ++i) { // loop over wide trapezoidal part
73  ndarray::Array<double const, 1, 1> unpackedRow = unpacked[i];
74  for (int j = 0, nj = nx + m - i; j < nj; ++j, ++outIter) {
75  *outIter = unpackedRow[j];
76  }
77  }
78 }

◆ unpack() [1/2]

ndarray::Array< double, 2, 2 > lsst::afw::math::detail::TrapezoidalPacker::unpack ( ndarray::Array< double const, 1, 1 > const &  packed) const

Definition at line 98 of file TrapezoidalPacker.cc.

99  {
100  ndarray::Array<double, 2, 2> out = ndarray::allocate(ny, nx);
101  unpack(out, packed);
102  return out;
103 }
void unpack(ndarray::Array< double, 2, 2 > const &out, ndarray::Array< double const, 1, 1 > const &packed) const

◆ unpack() [2/2]

void lsst::afw::math::detail::TrapezoidalPacker::unpack ( ndarray::Array< double, 2, 2 > const &  out,
ndarray::Array< double const, 1, 1 > const &  packed 
) const

Definition at line 80 of file TrapezoidalPacker.cc.

81  {
82  out.deep() = 0.0;
83  double const* packedIter = packed.begin();
84  for (int i = 0; i < m; ++i) { // loop over rectangular part
85  ndarray::Array<double, 1, 1> outRow = out[i];
86  for (int j = 0; j < nx; ++j, ++packedIter) {
87  outRow[j] = *packedIter;
88  }
89  }
90  for (int i = m; i < ny; ++i) { // loop over wide trapezoidal part
91  ndarray::Array<double, 1, 1> outRow = out[i];
92  for (int j = 0, nj = nx + m - i; j < nj; ++j, ++packedIter) {
93  outRow[j] = *packedIter;
94  }
95  }
96 }

Member Data Documentation

◆ m

int lsst::afw::math::detail::TrapezoidalPacker::m

Definition at line 106 of file TrapezoidalPacker.h.

◆ nx

int lsst::afw::math::detail::TrapezoidalPacker::nx

Definition at line 104 of file TrapezoidalPacker.h.

◆ ny

int lsst::afw::math::detail::TrapezoidalPacker::ny

Definition at line 105 of file TrapezoidalPacker.h.

◆ size

int lsst::afw::math::detail::TrapezoidalPacker::size

Definition at line 107 of file TrapezoidalPacker.h.


The documentation for this struct was generated from the following files: