13 #include "msdevstudio/MSconfig.h" 28 #ifdef ITERATOR_MEMBER_DEFECT 32 using std::runtime_error;
39 RTuple::RTuple (
const std::vector< std::string > & labels )
42 std::size_t
size = labels.size ();
43 for ( std::size_t i = 0; i <
size; i++ ) {
44 vector< double > * vp =
new vector< double > ();
58 vector < string > labels;
59 for (
unsigned int i = 0; i < n; i++ ) {
60 labels.push_back (
string (
"nil" ) );
70 vector< vector<double> *>::iterator it =
m_data.begin();
71 for ( ; it !=
m_data.end(); ++it ) {
83 const RTuple & ntuple = dynamic_cast <
const RTuple & > ( other );
84 vector < vector < double > * > ::const_iterator first
86 while ( first != ntuple.
m_data.end () ) {
87 vector < double > * v =
new vector < double > ( **first++ );
93 for (
unsigned int i = 0; i <
size; i++ ) {
94 const vector < double > & src = other.
getRow ( i );
95 vector < double > * dst =
new vector < double > ( src );
103 vector < vector < double > * >::iterator it =
m_data.begin();
104 while ( it !=
m_data.end() ) {
127 addRow (
const std::vector < double > & v )
131 vector < double > * row =
new vector < double > ( v );
139 if ( row >=
m_data.size() ) {
140 string what (
"RTuple::getRow: argument out of range" );
141 throw runtime_error ( what );
152 assert ( indices.size() ==
rank );
157 unsigned int row = indices[0] /
size;
158 unsigned int col = indices[0] %
size;
159 const vector < double > & rowvec = *
m_data[row];
164 unsigned int col = indices[1];
165 unsigned int row = indices[0];
166 const vector < double > & rowvec = *
m_data[row];
172 unsigned int col = indices[2];
173 unsigned int j = indices[1];
174 unsigned int i = indices[0];
176 assert ( col < size );
180 unsigned int row = j + i *
m_shape[1];
181 const vector < double > & rowvec = *
m_data[row];
std::vector< unsigned int > m_shape
The shape of the data.
RTuple(const RTuple &nt)
The copy constructor creates an ntuple that is a copy of an existing one.
virtual unsigned int rows() const
Returns the number of rows.
virtual void willDelete(const Observable *)
Notifies this Observer object that one of its Observable objects is about to be deleted.
unsigned int getRank() const
Returns the rank of the data source.
virtual void clear()
Clears the RTuple.
virtual double operator[](std::vector< unsigned int > &indices) const
int rank(numeric::array arr)
virtual void copyPrivate(const DataSource &other)
Copies the contents of the other DataSource.
unsigned int columns() const
Returns the number of columns or data arrays available from this DataSource.
virtual void notifyObservers() const
Notifies Observer objects of a change.
virtual void addRow(const std::vector< double > &v)
Adds a row to the end of the ntuple.
virtual void reserve(unsigned int count)
For each column, reserves enough space for the data source to grow to count rows. ...
Base class for DataSource.
intp size(numeric::array arr)
virtual void copy(const DataSource &other)
void throwIfInvalidRowSize(const std::vector< double > &row)
Throws a DataSourceException if the size of the row is not equal to the number of columns...
virtual const std::vector< double > & getRow(unsigned int) const =0
Returns a const reference to slice along the axis known as a row.
A DataSource class implemented with std::vector<double> to store the row data.
virtual double valueAt(unsigned int row, unsigned int column) const
Returns the value in the table in position given by the row and column indexes.
std::vector< std::vector< double > * > m_data
The data rows of the ntuple table.
virtual bool empty() const
Returns true, if RTuple is empty, i.e.
virtual void setLabels(const std::vector< std::string > &v)
Assigns the label to each column from the vector of strings @ v.
virtual const std::vector< double > & getRow(unsigned int index) const
Returns a vector of data elements in one row.
virtual unsigned int rows() const =0
Returns the number of rows.
Observer class interface.
virtual ~RTuple()
The destructor.
column
The column indices for 2 dimension data point tuple.
hippodraw::Range class interface