Changeset 96b5640 in git
- Timestamp:
- Aug 19, 2005, 2:49:57 PM (19 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 75a969d43630c43f7a329ae1b448cfe68d0c13a9
- Parents:
- d116ec8d2a0671141e480634f435e120ecfdb2c9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/python/wrapper.h
rd116ec8 r96b5640 1 //$Id: wrapper.h,v 1.1 0 2005-08-17 16:30:46bricken Exp $1 //$Id: wrapper.h,v 1.11 2005-08-19 12:49:57 bricken Exp $ 2 2 #ifndef PYTHON_SINGULAR_WRAPPER_HEADER 3 3 #define PYTHON_SINGULAR_WRAPPER_HEADER 4 4 #include <Python.h> 5 5 #include <boost/python.hpp> 6 #include <sstream> 6 7 #include "mod2.h" 7 8 #include "numbers.h" … … 11 12 #include "Poly.h" 12 13 #include "PowerSeries.h" 14 #include <factory.h> 15 13 16 using namespace boost::python; 17 typedef std::basic_stringstream<char> mysstream; 14 18 Vector unitVector0(int i){ 15 19 return unitVector(i,currRing); 16 20 } 21 17 22 static boost::python::object Number_as_str(Number n) 18 23 { … … 23 28 return boost::python::str(out,strlen(out)); 24 29 } 25 30 static boost::python::object CF_as_str(const CanonicalForm& f) 31 { 32 using boost::python::str; 33 mysstream s; 34 s<<f; 35 return boost::python::str(s.str()); 36 } 26 37 static boost::python::object Poly_as_str(Poly& p) 27 38 { … … 42 53 43 54 BOOST_PYTHON_MODULE(Singular){ 55 boost::python::class_<CanonicalForm>("canonical_form") 56 .def(boost::python::init <const int>()) 57 .def("__str__", CF_as_str) 58 .def(-self) 59 .def(self*=self) 60 .def(self+=self) 61 .def(self-=self) 62 .def(self/=self) 63 .def(self==self) 64 .def(self+self) 65 .def(self*self) 66 .def(self/self) 67 .def(self-self) 68 .def(int()==self) 69 .def(int()+self) 70 .def(int()*self) 71 .def(int()/self) 72 .def(int()-self) 73 .def(self==int()) 74 .def(self+int()) 75 .def(self*int()) 76 .def(self/int()) 77 .def(self-int()) 78 .def(self*=int()) 79 .def(self+=int()) 80 .def(self-=int()) 81 .def(self/=int()); 44 82 boost::python::class_<Number>("number") 45 83 .def(boost::python::init <int>()) … … 79 117 .def(boost::python::init <const char* >()) 80 118 81 //.def("__str__", as_str) 82 //.def(-self) 119 .def(-self) 83 120 .def(self*=self) 84 121 .def(self+=self) … … 94 131 .def(self*self); 95 132 boost::python::class_<Vector>("vector") 96 97 133 .def(boost::python::init <>()) 98 134 .def("__str__", Vector_as_str) … … 100 136 // .def("__str__", Poly_as_str) 101 137 .def("__iter__", boost::python::iterator<Vector>()) 102 138 .def(-self) 103 139 .def(self+=self) 104 140
Note: See TracChangeset
for help on using the changeset viewer.