File: vector_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 (36 lines) | stat: -rw-r--r-- 830 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
#include "kernel/mod2.h"
#ifdef HAVE_PYTHON_MOD
#include <boost/python.hpp>
#include "Poly.h"
#include "vector_wrap.h"
#include "ring_wrap.h"
using boost::python::self;

static boost::python::object Vector_as_str(Vector& p)
{
  using boost::python::str;
  //ring r=p.getRing();

  char* out=p.c_string();
  return boost::python::str(out,strlen(out));
}
static Ring Vector_get_Ring(const Vector & p){
  return p.getRing();
}
void export_vector(){
  boost::python::class_<Vector>("Vector")
    .def(boost::python::init <>())
    .def("__str__", Vector_as_str)

    //    .def("__str__", Poly_as_str)
    .def("__iter__", boost::python::iterator<Vector>())
    .def(-self)
    .def(self+=self)

    .def(self+self)
    .def(self*=Number())
    .def(Poly() * self)
    .def(Number() * self)
    .def("ring",Vector_get_Ring);
}
#endif