[Numpy-discussion] default float type of array not accepted by SWIG wrapped C functions

Spotz, William F wfspotz@sandia....
Thu Jan 22 11:09:01 CST 2009


Rich,

Basic python only supports double precision floats, so that is not an option.

NumPy does not have, as far as I know, a way to set the default precision, although it might be a reasonable request.

As for the SWIG interface file, almost anything is possible.  Can you give an example of a function prototype you are wrapping, the %apply directive you use and and example of python code accessing it?

-Bill
________________________________________
From: numpy-discussion-bounces@scipy.org [numpy-discussion-bounces@scipy.org] On Behalf Of Rich E [reakinator@gmail.com]
Sent: Thursday, January 22, 2009 11:45 AM
To: Discussion of Numerical Python
Subject: [Numpy-discussion] default float type of array not accepted by SWIG wrapped C functions

Hi all,

I have a SWIG wrapped C library that uses 32bit floating point arrays,
using the numpy.i typemapping system for passing the arrays.  For
every array that I make, I have to convert it using astype('float32'),
else python complains that I tried to pass a double-precision array.

Is there any way to set the default floating point precision to 32bit,
in python or in the SWIG interface file?

regards,
Rich
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


More information about the Numpy-discussion mailing list