[SciPy-User] SWIG + numpy and data types

Matthieu Brucher matthieu.brucher@gmail....
Thu Feb 11 02:21:29 CST 2010


I think your best bet is to add an additional C layer that will expose
the dimension of each array :

void cLandscape_wrap(int* interactions, int size_interaction, float*
contributions, int size_contributions, float* landscape, int

and then apply the SWIG %apply on each pair. This is the easiest way
IMO to achieve your goal.


2010/2/11 Ignacio Vergara <nolambar@gmail.com>:
> Hi
> I hope this is the correct mailing list for this.
> I'm using SWIG to create a module for Python+numpy for a legacy and highly
> optimized C code.
> The function takes 2 array arguments (different sizes) and returns a third
> array. But I've been unable to define the interface file.
> The function definition is
> void cLandscape(int N, int* interactions, float* contributions, float*
> landscape);
> where interactions is a N*(N+1) array, contributions is another array of
> length 2^(K+1) [0 <= K <= N-1] and landscape is the returned array of length
> 2^N. So N is the only relevant length.
> The function loops over 2^N to fill the landscape array.
> The interface typemap line looks like this
> %apply (int DIM1, int* IN_ARRAY1, float* IN_ARRAY1, float* ARGOUT_ARRAY1)
> {(int N, int* interactions, float* contributions, float* landscape)}
> Thanks in advance for any tip and help ;)
> Ignacio Vergara Kausel
> Bachelor in Science, Physics
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user

Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher

More information about the SciPy-User mailing list