0

Im trying to run some c code in python using inline from scipy.weave.

Lets say we have 2 double arrays and onbe double value, i wish to add each index of the first index to the corresponiding index of the next index, plus the value.

The C code:

double* first;
double* second;
double val;
int length;

int i;
for (i = 0; i < length; i++) {
    second[i] = second[i] + first[i] + val;
}

Then i wish to use the "second" array in my python code again.

Given the following python code:

import numpy
from scipy import weave

first = zeros(10) #first double array
second = ones(10) #second python array
val = 1.0

code = """
    the c code
"""
second = inline(code,[first, second, val, 10])

Now i am not shure if this is the correct way of sending in the arrays/getting it out, and how to use/get acces to them within the c code.

mat
  • 77
  • 1
  • 1
  • 6
  • Could you explain how exactly are you wanting to do this? I don't see how the two languages can be mixed. – augre Nov 02 '15 at 21:27
  • using scipy.weave, http://docs.scipy.org/doc/scipy/reference/tutorial/weave.html – mat Nov 02 '15 at 21:30
  • http://stackoverflow.com/questions/4260528/how-do-i-use-scipy-weave-inline-together-with-external-c-libraries – augre Nov 02 '15 at 21:31

0 Answers0