[Numpy-discussion] numpy C++ swig class example

Rubin, Jared JARED.RUBIN at saic.com
Tue Jun 9 22:52:43 EDT 2009

I am using the numpy.i interface file and have gotten the cookbook/swig example to work from scipy.
Are there any examples of appyling the numpy.i to a C++ header file. I would like to generate a lightweight
Array2D class that just uses doubles and would have the following header file

class Array2D {
    int _nrow;
    int _ncol;
    double* data;
  Array2DD(int nrow, int ncol, double *data);

// I would expect the have the following Array2D.i interface file
%module array2DD

#include "Array2D.h"

%include "numpy.i"

%init %{

%ignore Array2D();
%ignore Array2D(long nrow, long ncol);
%apply (int DIM1, int DIM2, double* IN_ARRAY2) {(int nrow, int ncol, double *data)}
%include "Array2D.h"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090609/21aed1be/attachment.html>

More information about the NumPy-Discussion mailing list