File: poly_wrap.cc

package info (click to toggle)
singular 1%3A4.1.1-p2%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,856 kB
  • sloc: cpp: 288,280; ansic: 17,387; lisp: 4,242; yacc: 1,654; python: 1,608; makefile: 1,424; lex: 1,387; perl: 632; sh: 567; xml: 182
file content (62 lines) | stat: -rw-r--r-- 1,512 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "kernel/mod2.h"
#ifdef HAVE_PYTHON_MOD
#include <boost/python.hpp>
#include "Poly.h"
#include "ring_wrap.h"
#include "intvec_wrap.h"
#include "poly_wrap.h"

using boost::python::self;
boost::python::str Poly_as_str(const Poly& p)
{
  using boost::python::str;
  //ring r=p.getRing();

  char* out=p.c_string();
  return boost::python::str(out,strlen(out));
}
boost::python::str Vector_as_str(const Vector& p)
{
  using boost::python::str;
  //ring r=p.getRing();

  char* out=p.c_string();
  return boost::python::str(out,strlen(out));
}
static Ring Poly_get_Ring(const Poly & p){
  return p.getRing();
}
void export_poly()
{
   boost::python::class_<Poly>("Polynomial", "Wrapper for poly of Singular")
    .def("ring",Poly_get_Ring)
    .def(boost::python::init <int>())
    .def(boost::python::init <Poly>())
//    .def(boost::python::init <std::vector<int> >())
    .def(boost::python::init <Number>())
    .def(boost::python::init <Intvec> ())
    .def("__str__", Poly_as_str)
    .def("__iter__", boost::python::iterator<Poly>())
    //read monomials (only) from string
    .def(boost::python::init <const char* >())

    .def("leadCoef",&Poly::leadCoef)
    .def("leadExp", &Poly::leadExp)

    .def(-self)
    .def(self*=self)
    .def(self+=self)
    //    .def(self-=self)
    //.def(self/=self)
    //.def(self==self)
    .def(self+self)
    .def(self*=Number())
    .def(Number()*self)
    .def(self+Number())
    .def(self+=Number())
    .def(self*=Number())

    .def(self*self);

}
#endif