spielwiese
Last change
on this file since 383b2c8 was
383b2c8,
checked in by Oleksandr Motsak <motsak@…>, 12 years ago
|
CHG: mod2.h should better be included as <kernel/mod2.h>
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <boost/python.hpp> |
---|
2 | #include <kernel/mod2.h> |
---|
3 | #include "Poly.h" |
---|
4 | #include "boost/python/numeric.hpp" |
---|
5 | using boost::python::numeric::array; |
---|
6 | using boost::python::self; |
---|
7 | using boost::python::make_tuple; |
---|
8 | using boost::python::tuple; |
---|
9 | using boost::python::object; |
---|
10 | using boost::python::list; |
---|
11 | object foo(){ |
---|
12 | list l; |
---|
13 | for(int j=0;j<2;j++){ |
---|
14 | list row; |
---|
15 | for(int i=0;i<10;i++){ |
---|
16 | Poly ip(i*(j+1),currRing); |
---|
17 | row.append(ip); |
---|
18 | //a[boost::python::make_tuple(i%2,i%5)]=ip; |
---|
19 | //a[boost::python::make_tuple(i%2,i%5)]=ip; |
---|
20 | } |
---|
21 | l.append(row); |
---|
22 | } |
---|
23 | array::set_module_and_type("Numeric", |
---|
24 | "ArrayType" |
---|
25 | ); |
---|
26 | array a(l); |
---|
27 | return a; |
---|
28 | |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | } |
---|
33 | boost::python::object foo2(array f){ |
---|
34 | using boost::python::extract; |
---|
35 | object o=f.attr("shape"); |
---|
36 | |
---|
37 | object o1=o[0]; |
---|
38 | |
---|
39 | object o2=o[1]; |
---|
40 | int l1=extract<int>(o1); |
---|
41 | |
---|
42 | Print("%d",l1); |
---|
43 | int l2=extract<int>(o2); |
---|
44 | Print("%d",l2); |
---|
45 | Poly& x = boost::python::extract<Poly&>(f[boost::python::make_tuple(0,0)]); |
---|
46 | x.print(); |
---|
47 | |
---|
48 | return boost::python::str("suc"); |
---|
49 | } |
---|
50 | void export_playground(){ |
---|
51 | def("foo",foo); |
---|
52 | def("foo2",foo2); |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.