LSST Applications g0f08755f38+9c285cab97,g1635faa6d4+13f3999e92,g1653933729+a8ce1bb630,g1a0ca8cf93+bf6eb00ceb,g28da252d5a+0829b12dee,g29321ee8c0+5700dc9eac,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+fde0dd39b6,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g80478fca09+55a9465950,g82479be7b0+d730eedb7d,g858d7b2824+9c285cab97,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+2a84bb7594,gacf8899fa4+c69c5206e8,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gc28159a63d+9634bc57db,gcf0d15dbbd+4b7d09cae4,gda3e153d99+9c285cab97,gda6a2b7d83+4b7d09cae4,gdaeeff99f8+1711a396fd,ge2409df99d+5e831397f4,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+41c94011de,gf3fb38a9a8+8f07a9901b,gfb92a5be7c+9c285cab97,w.2024.46
LSST Data Management Base Package
|
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. | |
typedef Eigen::Map< Eigen::Array< T, Eigen::Dynamic, 1 > > | Vector |
Workspace vector type. | |
Public Member Functions | |
MatrixBuilderWorkspace (int size) | |
Allocate a block of memory with the given number of elements (of type T). | |
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. | |
int | getRemaining () const |
Return the size (in units of sizeof(T)) of the unused memory in the workspace. | |
Matrix | makeMatrix (int rows, int cols) |
Create a matrix from the workspace memory, and increment the current location accordingly. | |
Vector | makeVector (int size) |
Create a vector from the workspace memory, and increment the current location accordingly. | |
void | increment (int size) |
Manually increment the current location. | |
ndarray::Manager::Ptr | getManager () const |
Return the manager object that owns the block of memory. | |
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.
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.
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.
|
explicit |
Allocate a block of memory with the given number of elements (of type T).
|
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.
|
inline |
Return the manager object that owns the block of memory.
Definition at line 224 of file MatrixBuilder.h.
|
inline |
Return the size (in units of sizeof(T)) of the unused memory in the workspace.
Definition at line 210 of file MatrixBuilder.h.
void lsst::shapelet::MatrixBuilderWorkspace< T >::increment | ( | int | size | ) |
Manually increment the current location.
Matrix lsst::shapelet::MatrixBuilderWorkspace< T >::makeMatrix | ( | int | rows, |
int | cols ) |
Create a matrix from the workspace memory, and increment the current location accordingly.
Vector lsst::shapelet::MatrixBuilderWorkspace< T >::makeVector | ( | int | size | ) |
Create a vector from the workspace memory, and increment the current location accordingly.