[Numpy-discussion] SWIG Numpy and C++ extensions

Doutriaux, Charles doutriaux1@llnl....
Tue Jul 31 17:28:02 CDT 2012

Thanks David,

The clarification on apply is actually a important one!


On 7/31/12 1:04 PM, "David Froger" <david.froger@gmail.com> wrote:

>> I'm looking at SWIG/numpy tutorials
>They are these tutorials:
>Reading numpy.i is also very instructive.
>> 1- How do use "apply" for class functions %apply (bla) myobject::foo ?
>%apply  is  specified  on  function/method   arguments  names  and  types
> only,
>never on function names.  So if for example you use:
>%apply (int* ARGOUT_ARRAY1, int DIM1) {(int* rangevec, int n)}
>it will apply on every functions that have arguments "int* ARGOUT_ARRAY1,
>int DIM1"
>> 2-that's ok if your C++ deals with arrays but what if I actually want
>>to receive the Numpy object so that I can manipulate it directly (or if
>>for example the array isn't contiguous in memory)
>> An"dummy"example of foo function I'd like to wrap:
>>      void FOO::fooNumpy(PyArrayObject *nparray) {
>>       int j;
>>       for(j=0;j<nparray->nd;j++) {
>> printf("Ok array dim %i has length: %i\n",j,nparray->dimensions[j]);
>>       }
>>     }
>I never do it with Swig, will try to make this example works!
>NumPy-Discussion mailing list

More information about the NumPy-Discussion mailing list