Skip to content

Instantly share code, notes, and snippets.

@arjones6
arjones6 / numpy_cffi_arrays.py
Created May 7, 2013 16:22
Passing multidimensional numpy arrays to C using cffi.
import numpy
from cffi import FFI
ffi = FFI()
ffi.cdef("""
void single_test(double *x, int n);
void multi_test(double **x, int n, int m);
""")
C = ffi.dlopen("./simple.so")
@arjones6
arjones6 / simple.c
Last active December 17, 2015 02:09
Simple C functions taking arrays as arguments.
void single_test(double *x, int n);
void array_math_test(double *x, int n, int m);
void multi_test(double **x, int n, int m);
void single_test(double *x, int n)
{
int i;
for (i = 0; i < n; i++)
x[i] += i;
}