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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#include "kernel/mod2.h"
#ifdef HAVE_PYTHON_MOD
#include <boost/python.hpp>
#include "Poly.h"
#include "Ideal.h"
#include "ring_wrap.h"
#include "poly_wrap.h"
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
using boost::python::self;
using namespace boost::python;
static boost::python::object Ideal_as_str(const Ideal& p)
{
using boost::python::str;
//ring r=p.getRing();
str helper;
list tojoin;
int i;
int s=p.size();
//tojoin.append("[");
for(i=0;i<s;i++){
tojoin.append(Poly_as_str(p[i]));
if (i<s-1)
tojoin.append(", ");
}
//tojoin.append("]");
str res=helper.join(tojoin);
return res;
}
static boost::python::object Module_as_str(const Module& p)
{
using boost::python::str;
//ring r=p.getRing();
str helper;
list tojoin;
int i;
int s=p.size();
//tojoin.append("[");
for(i=0;i<s;i++){
tojoin.append(Vector_as_str(p[i]));
if (i<s-1)
tojoin.append(", ");
}
//tojoin.append("]");
str res=helper.join(tojoin);
return res;
}
static Ring Ideal_get_Ring(const Ideal & p){
return p.getRing();
}
void export_ideal()
{
boost::python::class_<Ideal>("Ideal", "supports most operation a\
python list supports with the expception, that elements must\
be Polynomials")
.def(init<>())
.def(init<const Ideal&>())
.def("__str__", Ideal_as_str)
.def("ring",Ideal_get_Ring)
.def(boost::python::init <>())
.def(vector_indexing_suite<Ideal >());
}
void export_module()
{
boost::python::class_<Module>("Module", "supports most operation a\
python list supports with the expception, that elements must\
be Polynomials")
.def(init<>())
.def(init<const Module&>())
.def("__str__", Module_as_str)
.def("ring",Ideal_get_Ring)
.def(boost::python::init <>())
.def(vector_indexing_suite<Module>());
}
#endif
|