我试着在python中使用inline-from运行一些c代码精纺. 你知道吗
假设我们有2个双数组和onbe双值,我想把第一个索引的每个索引加上下一个索引的对应索引,再加上这个值。你知道吗
C代码:
double* first;
double* second;
double val;
int length;
int i;
for (i = 0; i < length; i++) {
second[i] = second[i] + first[i] + val;
}
然后我希望在python代码中再次使用“second”数组。你知道吗
给定以下python代码:
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])
如果这是发送阵列/取出阵列的正确方法,以及如何在c代码中使用/访问阵列,那么我就不是舒尔了。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐