00001
00002
00014 #ifndef NumArrayTuple_H
00015 #define NumArrayTuple_H
00016
00017
00018 #ifdef HAVE_CONFIG_H
00019 #include "config.h"
00020 #endif
00021
00022 #ifdef HAVE_NUMPY
00023 #include <numpy/noprefix.h>
00024 #else
00025 #ifdef HAVE_NUMERIC
00026 #include <Numeric/arrayobject.h>
00027 #else
00028 #include <numarray/arrayobject.h>
00029 typedef int intp;
00030 #endif
00031 #endif
00032
00033 #include "datasrcs/DataSource.h"
00034
00035 namespace boost {
00036 namespace python {
00037 namespace numeric {
00038 class array;
00039 }
00040 }
00041 }
00042
00043 namespace hippodraw {
00044
00054 class NumArrayTuple : public DataSource
00055 {
00056
00057 private:
00058
00061 std::vector < boost::python::numeric::array > m_data;
00062
00067 mutable std::vector < double > m_row;
00068
00069 public:
00070
00073 NumArrayTuple ();
00074
00077 virtual ~NumArrayTuple();
00078
00082 virtual void copy ( const DataSource & );
00083
00087 virtual void notifyObservers ( ) const;
00088
00091 virtual unsigned int rows () const;
00092
00095 virtual bool empty () const;
00096
00097 virtual double valueAt ( unsigned int row, unsigned int column ) const;
00098
00107 int addColumn ( const std::string & label,
00108 boost::python::numeric::array array );
00109
00115 void replaceColumn ( unsigned int index,
00116 boost::python::numeric::array array );
00117
00123 void replaceColumn ( const std::string & label,
00124 boost::python::numeric::array array );
00125
00127 boost::python::numeric::array
00128 getNumArray( const std::string & label ) const;
00129
00131 boost::python::numeric::array
00132 getNumArray( unsigned int index ) const;
00133
00136 virtual const std::vector < double > & getRow ( unsigned int index ) const;
00137
00144 virtual void setShape ( std::vector < unsigned int > & shape );
00145
00148 const std::vector < unsigned int > & getShape () const;
00149
00156 virtual void fillShape ( std::vector < intptr_t > & v,
00157 unsigned int column ) const;
00158
00160 virtual void clear ();
00161
00163 virtual void reserve ( unsigned int count );
00164
00166 virtual double
00167 operator [] ( std::vector < unsigned int > & indices ) const;
00168
00169 };
00170
00171 }
00172
00173 #endif // NumArrayTuple_H