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
|
#include "kernel/mod2.h"
#ifdef HAVE_PYTHON_MOD
#include <boost/python.hpp>
#include "Poly.h"
#include "boost/python/numeric.hpp"
using boost::python::numeric::array;
using boost::python::self;
using boost::python::make_tuple;
using boost::python::tuple;
using boost::python::object;
using boost::python::list;
object foo()
{
list l;
for(int j=0;j<2;j++)
{
list row;
for(int i=0;i<10;i++)
{
Poly ip(i*(j+1),currRing);
row.append(ip);
//a[boost::python::make_tuple(i%2,i%5)]=ip;
//a[boost::python::make_tuple(i%2,i%5)]=ip;
}
l.append(row);
}
boost::python::numeric::array::set_module_and_type("Numeric",
"ArrayType"
);
boost::python::numeric::array a(l);
return a;
}
object foo2(array f)
{
using boost::python::extract;
object o=f.attr("shape");
object o1=o[0];
object o2=o[1];
int l1=extract<int>(o1);
Print("%d",l1);
int l2=extract<int>(o2);
Print("%d",l2);
Poly& x = boost::python::extract<Poly&>(f[boost::python::make_tuple(0,0)]);
x.print();
return boost::python::str("suc");
}
void export_playground()
{
def("foo",foo);
def("foo2",foo2);
}
#endif
|