playground.cc
Go to the documentation of this file.
1 #include <kernel/mod2.h>
2 #ifdef HAVE_PYTHON_MOD
3 #include <boost/python.hpp>
4 #include "Poly.h"
5 #include "boost/python/numpy.hpp"
6 using boost::python::numpy::ndarray;
7 using boost::python::self;
8 using boost::python::make_tuple;
9 using boost::python::tuple;
10 using boost::python::object;
11 using boost::python::list;
12 object foo()
13 {
14  list l;
15  for(int j=0;j<2;j++)
16  {
17  list row;
18  for(int i=0;i<10;i++)
19  {
20  Poly ip(i*(j+1),currRing);
21  row.append(ip);
22  //a[boost::python::make_tuple(i%2,i%5)]=ip;
23  //a[boost::python::make_tuple(i%2,i%5)]=ip;
24  }
25  l.append(row);
26  }
27  boost::python::numpy::ndarray a(l);
28  return a;
29 }
30 object foo2(ndarray f)
31 {
32  using boost::python::extract;
33  object o=f.attr("shape");
34 
35  object o1=o[0];
36 
37  object o2=o[1];
38  int l1=extract<int>(o1);
39 
40  Print("%d",l1);
41  int l2=extract<int>(o2);
42  Print("%d",l2);
43  Poly& x = boost::python::extract<Poly&>(f[boost::python::make_tuple(0,0)]);
44  x.print();
45 
46  return boost::python::str("suc");
47 }
48 void export_playground()
49 {
50  def("foo",foo);
51  def("foo2",foo2);
52 }
53 #endif
Definition: janet.h:14
const poly a
Definition: syzextra.cc:212
#define Print
Definition: emacs.cc:83
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
int j
Definition: myNF.cc:70
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:123
Variable x
Definition: cfModGcd.cc:4023
int l
Definition: cfEzgcd.cc:94