I want to pass 1 integer and 2 numpy array into the C function as
followings:
void update_incident_field(int k, float *a, int na, float *b, int nb) {
for (i=0; i
Hi,
I don't know exactly, but try replacing the one line
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float
*b, int nb)};
with two lines:
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na)};
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *b, int nb)};
Don't know about the '{' '}' brakets. b could probably be "more
general" as INPUT_ARRAY1
HTH
-S.
On Thu, May 20, 2010 at 1:43 AM, Steven Nien
I want to pass 1 integer and 2 numpy array into the C function as followings:
void update_incident_field(int k, float *a, int na, float *b, int nb) { for (i=0; i
But I don't know how to write the interface code (***.i) Can someone help me?
Thanks!
The swig interface code I written(did't work, strange output)
%module example %{ #define SWIG_FILE_WITH_INIT #include "example.h" %} %include "numpy.i"
%init %{ import_array(); %}
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float *b, int nb)};
%include "example.h"
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
I tried the following:
%module example
%{
#define SWIG_FILE_WITH_INIT
//#include "example.h"
%}
%include "numpy.i"
%init %{
import_array();
%}
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float
*b, int nb)};
%inline
{
void update_incident_field(int k, float *a, int na, float *b, int nb)
{
for (i=0; i I want to pass 1 integer and 2 numpy array into the C function as
followings: void update_incident_field(int k, float *a, int na, float *b, int
nb) {
for (i=0; i But I don't know how to write the interface code (***.i)
Can someone help me? Thanks! The swig interface code I written(did't work, strange output) %module example
%{
#define SWIG_FILE_WITH_INIT
#include "example.h"
%}
%include "numpy.i" %init %{
import_array();
%} %apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float
*b, int nb)}; %include "example.h" ** Bill Spotz **
** Sandia National Laboratories Voice: (505)845-0170 **
** P.O. Box 5800 Fax: (505)284-0154 **
** Albuquerque, NM 87185-0370 Email: wfspotz@sandia.gov **
Hi
Thanks for all your help!
I found the "strange" result was caused by my algorithm(CUDA).
The swig part is very ok:)
On Thu, May 20, 2010 at 11:18 PM, Bill Spotz
I tried the following:
%module example %{ #define SWIG_FILE_WITH_INIT //#include "example.h" %} %include "numpy.i"
%init %{ import_array(); %}
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float *b, int nb)};
%inline { void update_incident_field(int k, float *a, int na, float *b, int nb) { for (i=0; i
$ swig -python example.i
and the resulting example_wrap.c file looks OK for me. What strange output did you get?
On May 19, 2010, at 7:43 PM, Steven Nien wrote:
I want to pass 1 integer and 2 numpy array into the C function as followings:
void update_incident_field(int k, float *a, int na, float *b, int nb) { for (i=0; i
But I don't know how to write the interface code (***.i) Can someone help me?
Thanks!
The swig interface code I written(did't work, strange output)
%module example %{ #define SWIG_FILE_WITH_INIT #include "example.h" %} %include "numpy.i"
%init %{ import_array(); %}
%apply (float* INPLACE_ARRAY1, int DIM1) {(float *a, int na), (float *b, int nb)};
%include "example.h"
** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-0154 ** ** Albuquerque, NM 87185-0370 Email: wfspotz@sandia.gov **
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (3)
-
Bill Spotz
-
Sebastian Haase
-
Steven Nien