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 Types | Public Member Functions | List of all members
lsst::shapelet::MatrixBuilderWorkspace< T > Class Template Reference

Reusable, shareable workspace for MatrixBuilder. More...

#include <MatrixBuilder.h>

Public Types

typedef Eigen::Map< Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic > > Matrix
 Workspace matrix type. More...
 
typedef Eigen::Map< Eigen::Array< T, Eigen::Dynamic, 1 > > Vector
 Workspace vector type. More...
 

Public Member Functions

 MatrixBuilderWorkspace (int size)
 Allocate a block of memory with the given number of elements (of type T). More...
 
 MatrixBuilderWorkspace (MatrixBuilderWorkspace const &other)
 Copy the current state of the workspace, allowing multiple MatrixBuilders to start their workspace arrays at the same point in memory and hence share workspace. More...
 
int getRemaining () const
 Return the size (in units of sizeof(T)) of the unused memory in the workspace. More...
 
Matrix makeMatrix (int rows, int cols)
 Create a matrix from the workspace memory, and increment the current location accordingly. More...
 
Vector makeVector (int size)
 Create a vector from the workspace memory, and increment the current location accordingly. More...
 
void increment (int size)
 Manually increment the current location. More...
 
ndarray::Manager::Ptr getManager () const
 Return the manager object that owns the block of memory. More...
 

Detailed Description

template<typename T>
class lsst::shapelet::MatrixBuilderWorkspace< T >

Reusable, shareable workspace for MatrixBuilder.

Multiple MatrixBuilders are often used together to evaluate a multi-shapelet model, and in this case it's more efficient for the MatrixBuilders to use the same memory for temporary arrays rather than have them each allocate their own workspace. At other times, it may be useful to use one workspace for a sequence of throwaway MatrixBuilders, to avoid unnecessary memory allocations. This class manages the memory used for a MatrixBuilder's workspace arrays, and provides methods for tracking it and sharing it between multple MatrixBuilders. See MatrixBuilderFactory for examples.

MatrixBuilderWorkspace holds a ndarray::Manager::Ptr that "owns" the block of memory. This is passed on to any MatrixBuilders constructed with it, ensuring that the block of memory remains alive with the MatrixBuilder even if the workspace object goes out of scope - so it is not necessary to keep the workspace object alive manually for the duration of its users.

In addition, MatrixBuilderWorkspace tracks both the current point in memory, and increments this as workspace matrices and vectors are created from it. It also checks that any created arrays do not exceed the bounds of the allocated memory. In order to share workspace memory between MatrixBuilders, the workspace object is simply copied - copied objects share the same memory, but maintain different "current" pointers, and hence create arrays from the same block of memory.

Definition at line 188 of file MatrixBuilder.h.

Member Typedef Documentation

◆ Matrix

template<typename T >
typedef Eigen::Map< Eigen::Array<T,Eigen::Dynamic,Eigen::Dynamic> > lsst::shapelet::MatrixBuilderWorkspace< T >::Matrix

Workspace matrix type.

Definition at line 191 of file MatrixBuilder.h.

◆ Vector

template<typename T >
typedef Eigen::Map< Eigen::Array<T,Eigen::Dynamic,1> > lsst::shapelet::MatrixBuilderWorkspace< T >::Vector

Workspace vector type.

Definition at line 192 of file MatrixBuilder.h.

Constructor & Destructor Documentation

◆ MatrixBuilderWorkspace() [1/2]

template<typename T >
lsst::shapelet::MatrixBuilderWorkspace< T >::MatrixBuilderWorkspace ( int  size)
explicit

Allocate a block of memory with the given number of elements (of type T).

◆ MatrixBuilderWorkspace() [2/2]

template<typename T >
lsst::shapelet::MatrixBuilderWorkspace< T >::MatrixBuilderWorkspace ( MatrixBuilderWorkspace< T > const &  other)
inline

Copy the current state of the workspace, allowing multiple MatrixBuilders to start their workspace arrays at the same point in memory and hence share workspace.

See MatrixBuilderFactory for an example.

Definition at line 203 of file MatrixBuilder.h.

203  :
204  _current(other._current),
205  _end(other._end),
206  _manager(other._manager)
207  {}

Member Function Documentation

◆ getManager()

template<typename T >
ndarray::Manager::Ptr lsst::shapelet::MatrixBuilderWorkspace< T >::getManager ( ) const
inline

Return the manager object that owns the block of memory.

Definition at line 224 of file MatrixBuilder.h.

224 { return _manager; }

◆ getRemaining()

template<typename T >
int lsst::shapelet::MatrixBuilderWorkspace< T >::getRemaining ( ) const
inline

Return the size (in units of sizeof(T)) of the unused memory in the workspace.

Definition at line 210 of file MatrixBuilder.h.

210 { return _end - _current; }

◆ increment()

template<typename T >
void lsst::shapelet::MatrixBuilderWorkspace< T >::increment ( int  size)

Manually increment the current location.

◆ makeMatrix()

template<typename T >
Matrix lsst::shapelet::MatrixBuilderWorkspace< T >::makeMatrix ( int  rows,
int  cols 
)

Create a matrix from the workspace memory, and increment the current location accordingly.

◆ makeVector()

template<typename T >
Vector lsst::shapelet::MatrixBuilderWorkspace< T >::makeVector ( int  size)

Create a vector from the workspace memory, and increment the current location accordingly.


The documentation for this class was generated from the following file: