File: playground.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 (56 lines) | stat: -rw-r--r-- 1,198 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
#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