Reputation: 33827
I want to pass numpy array of known size and type via SWIG to C function
# .py
data = numpy.arange( N , dtype=numpy.int32 )
external_c_function( data )
# .i
extern void external_c_function( int32_t* data );
# .c
void external_c_function( int32_t* data)
{
// ...
}
Unfortunately, I will get an error:
TypeError: in method 'external_c_function', argument 1 of type 'int32_t *'
What is the easiest way to pass numpy array to SWIG?
Upvotes: 3
Views: 1947
Reputation: 735
You can use numpy.i
. Just have a look at http://www.scipy.org/Cookbook/SWIG_NumPy_examples
Upvotes: 1