source: git/dyn_modules/python/poly_wrap.cc @ 3c473c

spielwiese
Last change on this file since 3c473c was 3c473c, checked in by Kai Krüger <krueger@…>, 14 years ago
rename directory modules to dyn_modules anticipating "modules" directory for cmake. git-svn-id: file:///usr/local/Singular/svn/trunk@13033 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.5 KB
Line 
1#include <boost/python.hpp>
2#include "mod2.h"
3#include "Poly.h"
4#include "ring_wrap.h"
5#include "intvec_wrap.h"
6#include "poly_wrap.h"
7
8using boost::python::self;
9boost::python::str Poly_as_str(const Poly& p)
10{
11  using boost::python::str;
12  //ring r=p.getRing();
13 
14  char* out=p.c_string();
15  return boost::python::str(out,strlen(out));
16}
17boost::python::str Vector_as_str(const Vector& p)
18{
19  using boost::python::str;
20  //ring r=p.getRing();
21 
22  char* out=p.c_string();
23  return boost::python::str(out,strlen(out));
24}
25static Ring Poly_get_Ring(const Poly & p){
26  return p.getRing();
27}
28void export_poly()
29{
30   boost::python::class_<Poly>("Polynomial", "Wrapper for poly of Singular")
31    .def("ring",Poly_get_Ring)
32    .def(boost::python::init <int>())
33    .def(boost::python::init <Poly>())
34//    .def(boost::python::init <std::vector<int> >())
35    .def(boost::python::init <Number>())
36    .def(boost::python::init <Intvec> ())
37    .def("__str__", Poly_as_str)
38    .def("__iter__", boost::python::iterator<Poly>())
39    //read monomials (only) from string
40    .def(boost::python::init <const char* >())
41   
42    .def("leadCoef",&Poly::leadCoef)
43    .def("leadExp", &Poly::leadExp)
44   
45    .def(-self)
46    .def(self*=self)
47    .def(self+=self)
48    //    .def(self-=self)
49    //.def(self/=self)
50    //.def(self==self)
51    .def(self+self)
52    .def(self*=Number())
53    .def(Number()*self)
54    .def(self+Number())
55    .def(self+=Number())
56    .def(self*=Number())
57   
58    .def(self*self);
59 
60}
61
62
Note: See TracBrowser for help on using the repository browser.