1 // we need the following typemap for arrays of doubles in Perl
3 %typemap
(in
) float value
[ANY] {
5 if
(!PySequence_Check
($input
)) {
6 PyErr_SetString
(PyExc_ValueError
,"Expected a sequence");
9 if
(PySequence_Length
($input
) != $
1_dim0
) {
10 PyErr_SetString
(PyExc_ValueError
,"Size mismatch. Expected $1_dim0 elements");
13 $
1 = (float
*) malloc
($
1_dim0
*sizeof
(float
));
14 for
(i
= 0; i
< $
1_dim0
; i
++) {
15 PyObject
*o
= PySequence_GetItem
($input
,i
);
16 if
(PyNumber_Check
(o
)) {
17 $
1[i
] = (float
) PyFloat_AsDouble
(o
);
19 PyErr_SetString
(PyExc_ValueError
,"Sequence elements must be numbers");
25 %typemap
(freearg
) float value
[ANY] {