NumArrayTuple.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 
14 #ifndef NumArrayTuple_H
15 #define NumArrayTuple_H
16 
17 // for have numarray etc
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #ifdef HAVE_NUMPY
23 #include <numpy/noprefix.h>
24 #else
25 #ifdef HAVE_NUMERIC
26 #include <Numeric/arrayobject.h>
27 #else
28 #include <numarray/arrayobject.h>
29 typedef int intp;
30 #endif
31 #endif
32 
33 #include "datasrcs/DataSource.h"
34 
35 namespace boost {
36  namespace python {
37  namespace numeric {
38  class array;
39  }
40  }
41 }
42 
43 namespace hippodraw {
44 
54 class NumArrayTuple : public DataSource
55 {
56 
57  private:
58 
61  std::vector < boost::python::numeric::array > m_data;
62 
67  mutable std::vector < double > m_row;
68 
69  public:
70 
73  NumArrayTuple ();
74 
77  virtual ~NumArrayTuple();
78 
82  virtual void copy ( const DataSource & );
83 
87  virtual void notifyObservers ( ) const;
88 
91  virtual unsigned int rows () const;
92 
95  virtual bool empty () const;
96 
97  virtual double valueAt ( unsigned int row, unsigned int column ) const;
98 
107  int addColumn ( const std::string & label,
108  boost::python::numeric::array array );
109 
115  void replaceColumn ( unsigned int index,
116  boost::python::numeric::array array );
117 
123  void replaceColumn ( const std::string & label,
124  boost::python::numeric::array array );
125 
127  boost::python::numeric::array
128  getNumArray( const std::string & label ) const;
129 
131  boost::python::numeric::array
132  getNumArray( unsigned int index ) const;
133 
136  virtual const std::vector < double > & getRow ( unsigned int index ) const;
137 
144  virtual void setShape ( std::vector < unsigned int > & shape );
145 
148  const std::vector < unsigned int > & getShape () const;
149 
156  virtual void fillShape ( std::vector < intptr_t > & v,
157  unsigned int column ) const;
158 
160  virtual void clear ();
161 
163  virtual void reserve ( unsigned int count );
164 
166  virtual double
167  operator [] ( std::vector < unsigned int > & indices ) const;
168 
169 };
170 
171 } // namespace hippodraw
172 
173 #endif // NumArrayTuple_H
column
The column indices for 2 dimension data point tuple.
int intp
Definition: NumArrayTuple.h:29
const std::vector< unsigned int > & getShape() const
Returns the shape of the data elements.
virtual void setShape(std::vector< unsigned int > &shape)
Sets the shape of the data elements.
virtual bool empty() const
Returns true, if NumArrayTuple is empty, i.e.
std::vector< boost::python::numeric::array > m_data
The numarray objects that contains the data.
Definition: NumArrayTuple.h:61
void replaceColumn(unsigned int index, boost::python::numeric::array array)
Replaces the column indexed by index with the array.
NumArrayTuple()
The default constructor.
virtual void copy(const DataSource &)
Raises exception because with this release making a copy is not supported.
std::vector< double > m_row
A temporary array of data from one row of each column.
Definition: NumArrayTuple.h:67
virtual ~NumArrayTuple()
The destructor.
virtual double valueAt(unsigned int row, unsigned int column) const
hippodraw::DataSource class interface.
Namespace for HippoDraw.
Definition: AxesType.cxx:21
Base class for DataSource.
Definition: DataSource.h:55
virtual const std::vector< double > & getRow(unsigned int index) const
Returns a const reference to slice along the axis known as a row.
boost::python::numeric::array getNumArray(const std::string &label) const
Return the reference to the desired numarray by column label.
virtual void fillShape(std::vector< intptr_t > &v, unsigned int column) const
Fills the vector with the shape of a column.
virtual void clear()
Raises assertion as this method is not implemented yet.
virtual double operator[](std::vector< unsigned int > &indices) const
Raises assertion as this method is not implemented yet.
virtual unsigned int rows() const
Returns the size of the slice for the next to last dimension.
int addColumn(const std::string &label, boost::python::numeric::array array)
Adds a column to the end of the NumArrayTuple.
virtual void reserve(unsigned int count)
Raises assertion as this method is not implemented yet.
std::vector< intptr_t > shape(numeric::array arr)
Definition: num_util.cpp:317
virtual void notifyObservers() const
Notifies observers.
A DataSource class implemented with a Python numarray array to store the column data.
Definition: NumArrayTuple.h:54

Generated for HippoDraw Class Library by doxygen