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

Spotz, William F wfspotz at sandia.gov
Thu Jan 22 12:09:01 EST 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 at scipy.org [numpy-discussion-bounces at scipy.org] On Behalf Of Rich E [reakinator at 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 at scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list