Wrapper for matrix inputs/outputs (C#)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Wrapper for matrix inputs/outputs (C#)

Fredrik Lingvall
Hi All,

I'm new to swig (and C#) and trying to use swig to generate C# wrappers
for a C-library where the functions takes matrix input and output
arguments. A C-funtion can, for example, look like

  int err = conv(double* Cout,  const double* Ain, int A_m,  int A_n,
const double *Bin, int B_m, int B_n);

and I want the corresponding C# call to look like:

  C = conv(A, B);

The matrices can large so making copies of A and B in the wrapper is not
an option. The dimension of the C matrix is given by the dimensions of
the input arguments and, for the example above, the C matrix should have
the dimension (A_m+B_m-1) x A_n. The wrapper(s) must :

1) Allocate output matrices (using C# code?)

2) Get pointers from the allocated matrices data (data is stored
column-by-column like in Fortran and BLAS/LAPACK etc.)

3) Call the C-function

4) return the output matrices to C# without making any (new) copies.

I managed to get swig to generate wrappers for Python by using
%rename/%ignore and some Numpy C-code before the C-function call but how
is this done for C#?



Swig-user mailing list
[hidden email]