42 unsigned int dim =
m_shape.size();
45 for (
unsigned int i=0; i < dim; i++) {
56 assert (
sz == m_data.size());
90 for (
unsigned int i=0; i < n; i++)
109 const std::string&
msg)
111 throw std::runtime_error (
msg +
": " +
context);
127void read_array (Arrayrep& rep,
136 bool know_size =
false;
137 if (rep.m_shape.size() > nest) {
144 rep.m_shape.push_back (0);
157 if (
rep.m_data.size() > 0 && nest >=
rep.m_shape.size())
162 read_array (rep,
s, nest+1,
context);
164 }
while (
s.at_open());
169 while (
s.at_num (elt)) {
170 rep.m_data.push_back (elt);
181 rep.m_shape[nest] =
n;
183 else if (
rep.m_shape[nest] != n) {
206 m_data.push_back (1);
208 m_data.push_back (0);
211 std::istringstream is (
str);
223 m_data.push_back (elt);
246 if (!m_data.size()) {
247 stream <<
"[ ]" << std::endl;
252 stream << m_data[0] << std::endl;
259 for (
unsigned i=1;i<
m_shape.size();i++)
261 if (totSize!=m_data.size())
262 error(
"",
"Array is inconsistent!");
264 std::vector<Arrayelt>::size_type dataIndex=0;
266 stream <<
"]" << std::endl;
280 if (dimIndex<(
m_shape.size()-1)) {
282 for (
unsigned i=0;i<
m_shape[dimIndex];i++) {
291 stream <<
"[" << m_data[idx++];
292 for (
unsigned i=1;i<
m_shape[dimIndex];i++)
293 stream <<
", " << m_data[idx++];
Helper class for converting strings to Array's.
Representation class for Array's.
Helper class for converting strings to Array's.
Namespace for helper functions.
float Arrayelt
The type of an element of an Array.
void write_array(std::ostream &stream) const
Creates a text representation of the array content.
void write_subarray(std::ostream &stream, std::vector< Arrayelt >::size_type &idx, unsigned dimIndex) const
Helper function for write_array.
void init_sizes(bool resize_data=false)
Initialize the m_sizes vector from the m_shape vector.
Arrayrep()
Default constructor.
*Subarray for faster access See above *This member could be considered transient std::vector< unsigned int > m_sizes
*The array shape *One entry per giving the size of each dimension std::vector< unsigned int > m_shape