I am trying to understand weave.inline to wrap C code in my Python programs. The code below simply takes the Numpy array and multiplicates all of its elements by 2.
inl.py
import numpy
import scipy.weave
a = numpy.array([1.0, 2.0, 3.0])
N = a.shape[0]
print a
code = \
"""
int i;
for(i = 0; i < N; i++)
{
a[i] = a[i] * 2;
}
"""
scipy.weave.inline(code, ['a','N'])
print a
Then I want to carry some functions from inline code to external libraries. Let it be the trivial multiplication by 2. So I create two files:
mult.c
#include "mult.h"
float mult(float n)
{
return n * 2;
}
mult.h
float inc(float n);
Now I want to use function mult in my inline code. But I don't know how do I link my C files with Python inline code. I tried to compile C files as shared library and pass them as headers and libraries in weave, but that was in vain. Any suggestions?