|
lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
|
XtcData::Array<T> subclass that keeps its own copy of the shape (set_shape() asserts ndim < MAXNDIM) and either points at an external buffer or owns a heap buffer, deleted in the destructor. More...
#include <NDArray.hh>
Inherits XtcData::Array< T >.
Public Types | |
| enum | { MAXNDIM = XtcData::MaxRank } |
| Size of the internal shape array. More... | |
| typedef psalg::types::shape_t | shape_t |
| Alias for psalg::types::shape_t (uint32_t). | |
| typedef psalg::types::size_t | size_t |
| Alias for psalg::types::size_t (uint32_t). | |
| typedef XtcData::Array< T > | base |
| Alias for the base class XtcData::Array<T>. | |
| using | NON_CONST_T = typename remove_const< T >::type |
| T with const removed; element type of the owned buffer. | |
Public Member Functions | |
| NDArray (const shape_t *sh, const size_t ndim, void *buf_ext=0) | |
| Set the shape from sh and ndim, then use buf_ext as the data buffer without copying; if buf_ext is null, allocate an owned buffer of size() elements. | |
| NDArray (const shape_t *sh, const size_t ndim, const void *buf_ext) | |
| Set the shape from sh and ndim, then point at the const buffer buf_ext without copying (nothing is allocated if it is null). | |
| NDArray () | |
| Empty array: no shape (rank 0) and no data. | |
| ~NDArray () | |
| Delete the owned buffer, if any. | |
| NDArray (const base &o) | |
| Copy the shape of the Array o and deep-copy its size() elements into an owned buffer. | |
| NDArray (const NDArray< T > &o) | |
| Copy the shape of o and deep-copy its size() elements into an owned buffer. | |
| NDArray< T > & | operator= (const NDArray< T > &o) |
| Unless o is this object, copy o's base members, then its shape and a deep copy of its data into an owned buffer. | |
| void | set_shape (const shape_t *shape=NULL, const size_t ndim=0) |
| Copy ndim entries of shape (if it is not null) into the internal shape array and set the rank; asserts ndim < MAXNDIM. | |
| void | set_shape_string (const std::string &str) |
| Converts string like "(5920, 388)" to array for _shape[]={5920, 388}. | |
| void | reshape (const shape_t *shape, const size_t ndim) |
| Same as set_shape(shape, ndim). | |
| T * | data () |
| Return the data pointer. | |
| const T * | const_data () const |
| Return the data pointer as const T*. | |
| shape_t * | shape () const |
| Return the shape pointer. | |
| size_t | ndim () const |
| Return the rank. | |
| size_t | rank () const |
| Return the rank (same as ndim()). | |
| size_t | size () const |
| Return the product of the first ndim() shape entries (1 for rank 0). | |
| void | set_ndarray (base &a) |
| Copy the shape of a and point at its data without copying (an owned buffer is released). | |
| void | set_ndarray (NDArray< T > &a) |
| Copy the shape of a and point at its data without copying (an owned buffer is released). | |
| void | set_const_data_buffer (const void *buf_ext=0) |
| CONST !!! *buf sets pointer to external data buffer WARNING shape needs to be set first, othervice size() is undefined! | |
| void | set_data_buffer (void *buf_ext=0) |
| sets pointer to data WARNING shape needs to be set first, othervice size() is undefined! | |
| void | set_data_copy (const void *buf=0) |
| copy content of external buffer in object memory buffer WARNING shape needs to be set first, othervice size() is undefined! | |
| void | reserve_data_buffer (const size_t size) |
| Reserves internal data buffer for array of requested size. | |
| std::string | string_ndarray (const size_t max_nvalues=5) |
| Return "typeid=... ndim=... size=... shape=(...) data=..." listing at most max_nvalues values, followed by "..." if there are more; an empty string for rank 0. | |
Public Member Functions inherited from XtcData::Array< T > | |
| Array (void *data, uint32_t *shape, uint32_t rank) | |
| Wrap data (reinterpreted as T*), shape and rank; nothing is copied. | |
| Array () | |
| Construct an empty view: null data and shape pointers, rank 0. | |
| Array (const Array &a) | |
| Copy the data pointer, shape pointer and rank of a (shallow copy). | |
| Array & | operator= (const Array &o) |
| Copy the data pointer, shape pointer and rank of o (shallow); self-assignment does nothing. | |
| T & | operator() (unsigned i) |
| Return a reference to element i. | |
| T & | operator() (unsigned i, unsigned j) |
| Return a reference to element (i, j) at offset i*shape[1]+j. | |
| T & | operator() (unsigned i, unsigned j, unsigned k) |
| Return a reference to element (i, j, k) at the row-major offset. | |
| T & | operator() (unsigned i, unsigned j, unsigned k, unsigned l) |
| Return a reference to element (i, j, k, l) at the row-major offset. | |
| T & | operator() (unsigned i, unsigned j, unsigned k, unsigned l, unsigned m) |
| Return a reference to element (i, j, k, l, m) at the row-major offset. | |
| uint32_t | rank () const |
| Return the rank. | |
| uint32_t * | shape () const |
| Return the shape pointer (not a copy). | |
| T * | data () |
| Return the data pointer. | |
| const T * | const_data () const |
| Return the data pointer as const T*. | |
| uint64_t | num_elem () const |
| Return the product of shape[0] . | |
| void | shape (uint32_t a, uint32_t b=0, uint32_t c=0, uint32_t d=0, uint32_t e=0) |
| Write a, b, c, d, e into shape[0..4] (always five entries). | |
| void | set_rank (uint32_t rank) |
| Set the rank. | |
| void | set_shape (uint32_t *shape) |
| Set the shape pointer. | |
| void | set_data (void *data) |
| Set the data pointer (reinterpreted as T*). | |
Public Attributes | |
| bool | T_IS_CONST = std::is_const<T>::value |
| True if T is const. It is a non-static member, so every object stores it. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const NDArray< T > &o) |
| Write the same description as string_ndarray() with at most 4 values to os (nothing for rank 0) and return os. | |
Additional Inherited Members | |
Protected Attributes inherited from XtcData::Array< T > | |
| uint32_t * | _shape |
| T * | _data |
| uint32_t | _rank |
XtcData::Array<T> subclass that keeps its own copy of the shape (set_shape() asserts ndim < MAXNDIM) and either points at an external buffer or owns a heap buffer, deleted in the destructor.
Copy construction and assignment deep-copy the data into an owned buffer.
| typedef XtcData::Array<T> psalg::NDArray< T >::base |
Alias for the base class XtcData::Array<T>.
| using psalg::NDArray< T >::NON_CONST_T = typename remove_const<T>::type |
T with const removed; element type of the owned buffer.
| typedef psalg::types::shape_t psalg::NDArray< T >::shape_t |
Alias for psalg::types::shape_t (uint32_t).
| typedef psalg::types::size_t psalg::NDArray< T >::size_t |
Alias for psalg::types::size_t (uint32_t).
Size of the internal shape array.
| Enumerator | |
|---|---|
| MAXNDIM | Equal to XtcData::MaxRank (5); set_shape() asserts ndim < MAXNDIM. |
Set the shape from sh and ndim, then use buf_ext as the data buffer without copying; if buf_ext is null, allocate an owned buffer of size() elements.
Set the shape from sh and ndim, then point at the const buffer buf_ext without copying (nothing is allocated if it is null).
|
inline |
Empty array: no shape (rank 0) and no data.
|
inline |
Delete the owned buffer, if any.
Copy the shape of the Array o and deep-copy its size() elements into an owned buffer.
Copy the shape of o and deep-copy its size() elements into an owned buffer.
Return the data pointer as const T*.
|
inline |
Return the data pointer.
|
inline |
Return the rank.
|
inline |
Unless o is this object, copy o's base members, then its shape and a deep copy of its data into an owned buffer.
|
inline |
Return the rank (same as ndim()).
Reserves internal data buffer for array of requested size.
For externally defined data buffer do not do anything, othervise reserves memory on heap. size is a number of values
Same as set_shape(shape, ndim).
|
inline |
CONST !!! *buf sets pointer to external data buffer WARNING shape needs to be set first, othervice size() is undefined!
sets pointer to data WARNING shape needs to be set first, othervice size() is undefined!
copy content of external buffer in object memory buffer WARNING shape needs to be set first, othervice size() is undefined!
Copy the shape of a and point at its data without copying (an owned buffer is released).
If a has no data, an owned buffer of size() elements is allocated instead.
Copy the shape of a and point at its data without copying (an owned buffer is released).
If a has no data, an owned buffer of size() elements is allocated instead.
Copy ndim entries of shape (if it is not null) into the internal shape array and set the rank; asserts ndim < MAXNDIM.
The data buffer is not changed.
Converts string like "(5920, 388)" to array for _shape[]={5920, 388}.
|
inline |
Return the shape pointer.
|
inline |
Return the product of the first ndim() shape entries (1 for rank 0).
|
inline |
Return "typeid=... ndim=... size=... shape=(...) data=..." listing at most max_nvalues values, followed by "..." if there are more; an empty string for rank 0.
Write the same description as string_ndarray() with at most 4 values to os (nothing for rank 0) and return os.
True if T is const. It is a non-static member, so every object stores it.