spielwiese
Last change
on this file since f534a3 was
f534a3,
checked in by Michael Brickenstein <bricken@…>, 19 years ago
|
*bricken: initial version
git-svn-id: file:///usr/local/Singular/svn/trunk@8505 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
2.2 KB
|
Line | |
---|
1 | //$Id: wrapper.h,v 1.1 2005-08-16 12:32:13 bricken Exp $ |
---|
2 | #include "mod2.h" |
---|
3 | #include "numbers.h" |
---|
4 | #include "febase.h" |
---|
5 | #include "Poly.h" |
---|
6 | #include "Number.h" |
---|
7 | #include <Python.h> |
---|
8 | #include <boost/python.hpp> |
---|
9 | |
---|
10 | using namespace boost::python; |
---|
11 | static boost::python::object Number_as_str(Number n) |
---|
12 | { |
---|
13 | using boost::python::str; |
---|
14 | StringSetS(""); |
---|
15 | n.write(); |
---|
16 | char* out=StringAppendS(""); |
---|
17 | return boost::python::str(out,strlen(out)); |
---|
18 | } |
---|
19 | |
---|
20 | static boost::python::object Poly_as_str(Poly p) |
---|
21 | { |
---|
22 | using boost::python::str; |
---|
23 | ring r=p.getRing(); |
---|
24 | |
---|
25 | char* out=p.c_string(); |
---|
26 | return boost::python::str(out,strlen(out)); |
---|
27 | } |
---|
28 | |
---|
29 | BOOST_PYTHON_MODULE(Singular){ |
---|
30 | boost::python::class_<Number>("number") |
---|
31 | .def(boost::python::init <int>()) |
---|
32 | .def("__str__", Number_as_str) |
---|
33 | .def(-self) |
---|
34 | .def(self*=self) |
---|
35 | .def(self+=self) |
---|
36 | .def(self-=self) |
---|
37 | .def(self/=self) |
---|
38 | .def(self==self) |
---|
39 | .def(self+self) |
---|
40 | .def(self*self) |
---|
41 | .def(self/self) |
---|
42 | .def(self-self) |
---|
43 | .def(int()==self) |
---|
44 | .def(int()+self) |
---|
45 | .def(int()*self) |
---|
46 | .def(int()/self) |
---|
47 | .def(int()-self) |
---|
48 | .def(self==int()) |
---|
49 | .def(self+int()) |
---|
50 | .def(self*int()) |
---|
51 | .def(self/int()) |
---|
52 | .def(self-int()) |
---|
53 | .def(self*=int()) |
---|
54 | .def(self+=int()) |
---|
55 | .def(self-=int()) |
---|
56 | .def(self/=int()); |
---|
57 | boost::python::class_<Poly>("polynomial") |
---|
58 | .def(boost::python::init <int>()) |
---|
59 | .def(boost::python::init <Poly>()) |
---|
60 | .def(boost::python::init <std::vector<int> >()) |
---|
61 | .def("__str__", Poly_as_str) |
---|
62 | //read monomials (only) from string |
---|
63 | .def(boost::python::init <const char* >()) |
---|
64 | |
---|
65 | //.def("__str__", as_str) |
---|
66 | //.def(-self) |
---|
67 | .def(self*=self) |
---|
68 | .def(self+=self) |
---|
69 | // .def(self-=self) |
---|
70 | //.def(self/=self) |
---|
71 | //.def(self==self) |
---|
72 | .def(self+self) |
---|
73 | .def(self*=Number()) |
---|
74 | .def(self*self); |
---|
75 | //.def(self/self) |
---|
76 | //.def(self-self) |
---|
77 | //.def(int()==self) |
---|
78 | //.def(int()+self) |
---|
79 | //.def(int()*self) |
---|
80 | //.def(int()/self) |
---|
81 | //.def(int()-self) |
---|
82 | //.def(self==int()) |
---|
83 | //.def(self+int()) |
---|
84 | /* .def(self*int()) */ |
---|
85 | /* .def(self/int()) */ |
---|
86 | /* .def(self-int()) */ |
---|
87 | /* .def(self*=int()) */ |
---|
88 | /* .def(self+=int()) */ |
---|
89 | /* .def(self-=int()) */ |
---|
90 | /* .def(self/=int()); */ |
---|
91 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.