Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

num_util.h

Go to the documentation of this file.
00001 #ifndef NUM_UTIL_H__
00002 #define NUM_UTIL_H__
00003 
00004 #include <boost/python.hpp>
00005 
00006 #ifdef HAVE_NUMERIC
00007 #include <Numeric/arrayobject.h>
00008 #else
00009 #include <numarray/arrayobject.h>
00010 #endif
00011 
00012 #include <iostream>
00013 #include <sstream>
00014 #include <vector>
00015 #include <map>
00016 
00017 
00022 namespace num_util{
00024 
00029   boost::python::numeric::array makeNum(boost::python::object x);
00030 
00038   boost::python::numeric::array makeNum(int n, PyArray_TYPES t);
00039 
00047   boost::python::numeric::array makeNum(std::vector<int> dimens, 
00048                                         PyArray_TYPES t);
00049                                       
00056   boost::python::numeric::array makeNum(int * data, int n);
00057 
00064   boost::python::numeric::array makeNum(float * data, int n);
00065 
00072   boost::python::numeric::array makeNum(double * data, int n);
00073 
00081   boost::python::numeric::array makeNum(char * data, std::vector<int> dims);
00082 
00090   boost::python::numeric::array makeNum(short * data, std::vector<int> dims);
00091 
00099   boost::python::numeric::array makeNum(int * data, std::vector<int> dims);
00100 
00108   boost::python::numeric::array makeNum(float * data, std::vector<int> dims);
00109 
00117   boost::python::numeric::array makeNum(double * data, std::vector<int> dims);
00118 
00124   boost::python::numeric::array makeNum(const 
00125                                         boost::python::numeric::array& arr);
00126 
00132   PyArray_TYPES type(boost::python::numeric::array arr);
00133 
00141   void check_type(boost::python::numeric::array arr, 
00142                   PyArray_TYPES expected_type);
00143 
00149   int rank(boost::python::numeric::array arr);
00150 
00157   void check_rank(boost::python::numeric::array arr, int expected_rank);
00158   
00164   int size(boost::python::numeric::array arr);
00165   
00173   void check_size(boost::python::numeric::array arr, int expected_size);
00174 
00180   std::vector<int> shape(boost::python::numeric::array arr);
00181 
00188   int get_dim(boost::python::numeric::array arr, int dimnum);
00189 
00197   void check_shape(boost::python::numeric::array arr, 
00198                    std::vector<int> expected_dims);
00199 
00208   void check_dim(boost::python::numeric::array arr, int dimnum, int dimsize);
00209 
00215   bool iscontiguous(boost::python::numeric::array arr);
00216 
00222   void check_contiguous(boost::python::numeric::array arr);
00223 
00229   char* data(boost::python::numeric::array arr);
00230 
00237   void copy_data(boost::python::numeric::array arr, char* new_data);
00238   
00244   boost::python::numeric::array clone(boost::python::numeric::array arr);
00245   
00252   boost::python::numeric::array astype(boost::python::numeric::array arr, 
00253                                        PyArray_TYPES t);
00254 
00260   bool spacesaver(boost::python::numeric::array arr);
00261   
00268   void savespace(boost::python::numeric::array arr, bool set_savespace);
00269 
00275   int refcount(boost::python::numeric::array arr);
00276 
00282   std::vector<int> strides(boost::python::numeric::array arr);
00283 
00290   void check_PyArrayElementType(boost::python::object newo);
00291 
00295   typedef std::map<PyArray_TYPES, std::string> KindStringMap;
00296 
00300   typedef std::map<PyArray_TYPES, char> KindCharMap;
00301 
00305   typedef std::map<char, PyArray_TYPES> KindTypeMap;
00306 
00312   std::string type2string(PyArray_TYPES t_type);
00313 
00319   char type2char(PyArray_TYPES t_type);
00320   
00326   PyArray_TYPES char2type(char e_type);
00327 
00334   template <class T>
00335   inline std::string vector_str(const std::vector<T>& vec);
00336 
00344   inline void check_size_match(std::vector<int> dims, int n);
00345 
00346 } //  namespace num_util
00347 
00348 #endif

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3