My Project
Loading...
Searching...
No Matches
Singular
dyn_modules
python
playground.cc
Go to the documentation of this file.
1
#include "
kernel/mod2.h
"
2
#ifdef HAVE_PYTHON
3
#include <boost/python.hpp>
4
#include "
Poly.h
"
5
#include "boost/python/numeric.hpp"
6
using
boost::python::numeric::array;
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::numeric::array::set_module_and_type(
"Numeric"
,
28
"ArrayType"
29
);
30
boost::python::numeric::array a(
l
);
31
return
a;
32
}
33
object
foo2
(array
f
)
34
{
35
using
boost::python::extract;
36
object
o=
f
.attr(
"shape"
);
37
38
object
o1=o[0];
39
40
object
o2=o[1];
41
int
l1=extract<int>(o1);
42
43
Print
(
"%d"
,l1);
44
int
l2=extract<int>(o2);
45
Print
(
"%d"
,l2);
46
Poly
&
x
= boost::python::extract<Poly&>(
f
[boost::python::make_tuple(0,0)]);
47
x
.print();
48
49
return
boost::python::str(
"suc"
);
50
}
51
void
export_playground
()
52
{
53
def(
"foo"
,
foo
);
54
def(
"foo2"
,
foo2
);
55
}
56
#endif
Poly.h
l
int l
Definition
cfEzgcd.cc:100
i
int i
Definition
cfEzgcd.cc:132
x
Variable x
Definition
cfModGcd.cc:4090
f
FILE * f
Definition
checklibs.c:9
Print
#define Print
Definition
emacs.cc:80
j
int j
Definition
facHensel.cc:110
mod2.h
export_playground
void export_playground()
Definition
playground.cc:51
foo
object foo()
Definition
playground.cc:12
foo2
object foo2(array f)
Definition
playground.cc:33
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition
polys.cc:13
Poly
Definition
janet.h:15
Generated on Thu Mar 20 2025 00:00:00 for My Project by
doxygen 1.13.2
for
Singular