source: git/modules/python/wrapper.h @ 4e2486

fieker-DuValspielwiese
Last change on this file since 4e2486 was 4e2486, checked in by Michael Brickenstein <bricken@…>, 19 years ago
*bricken: more work on vectors git-svn-id: file:///usr/local/Singular/svn/trunk@8515 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.1 KB
Line 
1//$Id: wrapper.h,v 1.5 2005-08-17 09:14:21 bricken Exp $
2#ifndef PYTHON_SINGULAR_WRAPPER_HEADER
3#define PYTHON_SINGULAR_WRAPPER_HEADER
4#include <Python.h>
5#include <boost/python.hpp>
6#include "mod2.h"
7#include "numbers.h"
8#include "febase.h"
9
10#include "Number.h"
11#include "Poly.h"
12
13using namespace boost::python;
14
15static boost::python::object Number_as_str(Number n)
16{
17  using boost::python::str;
18  StringSetS("");
19  n.write();
20  char* out=StringAppendS("");
21  return boost::python::str(out,strlen(out));
22}
23
24static boost::python::object Poly_as_str(Poly& p)
25{
26  using boost::python::str;
27  ring r=p.getRing();
28 
29  char* out=p.c_string();
30  return boost::python::str(out,strlen(out));
31}
32
33
34BOOST_PYTHON_MODULE(Singular){
35  boost::python::class_<Number>("number")
36    .def(boost::python::init <int>())
37    .def("__str__", Number_as_str)
38    .def(-self)
39    .def(self*=self)
40    .def(self+=self)
41    .def(self-=self)
42    .def(self/=self)
43    .def(self==self)
44    .def(self+self)
45    .def(self*self)
46    .def(self/self)
47    .def(self-self)
48    .def(int()==self)
49    .def(int()+self)
50    .def(int()*self)
51    .def(int()/self)
52    .def(int()-self)
53    .def(self==int())
54    .def(self+int())
55    .def(self*int())
56    .def(self/int())
57    .def(self-int())
58    .def(self*=int())
59    .def(self+=int())
60    .def(self-=int())
61    .def(self/=int());
62    boost::python::class_<Poly>("polynomial")
63    .def(boost::python::init <int>())
64    .def(boost::python::init <Poly>())
65    .def(boost::python::init <std::vector<int> >())
66    .def(boost::python::init <Number>())
67    .def("__str__", Poly_as_str)
68    .def("__iter__", boost::python::iterator<Poly>())
69    //read monomials (only) from string
70    .def(boost::python::init <const char* >())
71   
72      //.def("__str__", as_str)
73      //.def(-self)
74    .def(self*=self)
75    .def(self+=self)
76      //    .def(self-=self)
77      //.def(self/=self)
78      //.def(self==self)
79    .def(self+self)
80    .def(self*=Number())
81    .def(self*Number())
82    .def(self+Number())
83    .def(self+=Number())
84    .def(self*=Number())
85    .def(self*self);
86    boost::python::class_<PolyBase<POLY_VARIANT_MODUL> >("vector")
87   
88    .def(boost::python::init <>())
89   
90   
91    .def("__str__", Poly_as_str)
92    .def("__iter__", boost::python::iterator<PolyBase<POLY_VARIANT_MODUL> >())
93    //read monomials (only) from string
94    //.def(boost::python::init <const char* >())
95   
96      //.def("__str__", as_str)
97      //.def(-self)
98
99    .def(self+=self)
100      //    .def(self-=self)
101      //.def(self/=self)
102      //.def(self==self)
103    .def(self+self)
104    .def(self*=Number())
105      .def(self*Number());
106      //.def(self+Number())
107      //.def(self+=Number())
108      //.def(self*=Number());
109
110  //boost::python::class_<TermReference>("termreference");
111    //.def(self/self)
112      //.def(self-self)
113      //.def(int()==self)
114      //.def(int()+self)
115      //.def(int()*self)
116      //.def(int()/self)
117      //.def(int()-self)
118      //.def(self==int())
119      //.def(self+int())
120    /* .def(self*int()) */
121/*     .def(self/int()) */
122/*     .def(self-int()) */
123/*     .def(self*=int()) */
124/*     .def(self+=int()) */
125/*     .def(self-=int()) */
126/*     .def(self/=int()); */
127
128}
129#endif
Note: See TracBrowser for help on using the repository browser.