![]() |
ATLAS Offline Software
|
Representation class for Array's. More...
#include <Arrayrep.h>
Public Member Functions | |
| Arrayrep () | |
| Default constructor. More... | |
| Arrayrep (const std::string &str, const std::string &context="") | |
| Construct from a string. More... | |
| Arrayrep (const std::vector< unsigned int > &shape) | |
| Construct an empty array of a given shape. More... | |
| Arrayrep (const unsigned int shape[], unsigned int n) | |
| Construct an empty array of a given shape. More... | |
| void | init_sizes (bool resize_data=false) |
Initialize the m_sizes vector from the m_shape vector. More... | |
| void | write_array (std::ostream &stream) const |
| Creates a text representation of the array content. More... | |
| void | write_subarray (std::ostream &stream, std::vector< Arrayelt >::size_type &idx, unsigned dimIndex) const |
| Helper function for write_array. More... | |
Public Attributes | |
| std::vector< Arrayelt > | m_data |
| The array data, stored using the C array ordering. More... | |
| std::vector< unsigned int > | m_shape |
| The array shape. More... | |
| std::vector< unsigned int > | m_sizes |
| Subarray sizes, for faster access. More... | |
Representation class for Array's.
This class is used for the implementation of multidimensional array constants. The user interface is provided by the Array template class. Given an Array<N> a, we want a[i] to be an Array<N-1>. However, we don't want to have to copy the array data. Thus, the Array class just holds a reference to the actual array data. Those data are stored in an instance of Arrayrep.
An Arrayrep is defined by two vectors: one giving all the array elements, and the second giving the shape of the array. (A shape is a vector with one integer per array dimension, the integers giving the size of the dimensions.)
We maintain one additional array as an optimization. m_sizes[0] contains the total size in elements of the array resulting from a single indexing operation. m_sizes[1] contains the size of the array resulting from two indexing operations, and so on. m_sizes has the same length as m_shape, but the last element is always 1. The function init_sizes will initialize the m_sizes array from the contents of m_shape.
A scalar (0-dimensional array) is represented by m_shape (and m_sizes) being empty, and m_data having a single element.
If both m_shape and m_data are empty, then the representation is uninitialized.
Definition at line 61 of file Control/CxxUtils/CxxUtils/Arrayrep.h.
|
inline |
Default constructor.
This makes an uninitialized Arrayrep.
Definition at line 68 of file Control/CxxUtils/CxxUtils/Arrayrep.h.
Construct from a string.
| str | The string to convert. |
| context | An optional string to use for error reporting. |
Parse the string and initialize the array. This string should be like ‘[[1, 2], [3, 4]]’.
Definition at line 202 of file Arrayrep.cxx.
|
explicit |
Construct an empty array of a given shape.
| shape | The shape of the array. |
Initialize an array of a given shape. The array will contain all 0's.
Definition at line 69 of file Arrayrep.cxx.
|
explicit |
Construct an empty array of a given shape.
| shape | The shape of the array. |
| n | The length of the shape array. |
Initialize an array of a given shape. The array will contain all 0's. This version is more convenient to call with a constant shape.
Definition at line 86 of file Arrayrep.cxx.
| void CaloRec::Arrayrep::init_sizes | ( | bool | resize_data = false | ) |
Initialize the m_sizes vector from the m_shape vector.
| resize_data | Should m_data be resized appropriately? |
The contents of the m_sizes vector are initialized from the contents of the m_shape vector. If resize_data is true, then the size of m_data is changed to the total size indicated by m_shape. Otherwise, we verify that m_data has the correct size, and raise an assertion if not.
Definition at line 34 of file Arrayrep.cxx.
| void CaloRec::Arrayrep::write_array | ( | std::ostream & | stream | ) | const |
Creates a text representation of the array content.
Helper function for write_array.
| std::ostream | where the text should be written |
Writes the content of the array to a ostream. The sub-arrays are enclosed by square brackets and separated by commas.
| stream | where the array should be written |
| idx | Current index in m_data |
| dimIndex | Current index in m_shapes |
Calls itself recursively with dimIndex-1
Definition at line 245 of file Arrayrep.cxx.
| void CaloRec::Arrayrep::write_subarray | ( | std::ostream & | stream, |
| std::vector< Arrayelt >::size_type & | idx, | ||
| unsigned | dimIndex | ||
| ) | const |
Helper function for write_array.
Creates a text representation of the array content.
| stream | where the array should be written |
| idx | Current index in m_data |
| dimIndex | Current index in m_shapes |
Calls itself recursively with dimIndex-1
| std::ostream | where the text should be written |
Writes the content of the array to a ostream. The sub-arrays are enclosed by square brackets and separated by commas.
Definition at line 279 of file Arrayrep.cxx.
| std::vector<Arrayelt> CaloRec::Arrayrep::m_data |
The array data, stored using the C array ordering.
Definition at line 102 of file Control/CxxUtils/CxxUtils/Arrayrep.h.
| std::vector<unsigned int> CaloRec::Arrayrep::m_shape |
The array shape.
One entry per dimension, giving the size of each dimension.
Definition at line 106 of file Control/CxxUtils/CxxUtils/Arrayrep.h.
| std::vector<unsigned int> CaloRec::Arrayrep::m_sizes |
Subarray sizes, for faster access.
See above. This member could be considered transient.
Definition at line 110 of file Control/CxxUtils/CxxUtils/Arrayrep.h.
1.8.18