我有一小段现有的 C 代码,我想使用 Cython 进行包装。我想设置一些 numpy 数组,然后将这些数组作为参数传递给函数,这些函数接受标准的 C 数组(1维和2维)。在编写合适的 .pyx 代码以正确处理这些内容方面,我有些困惑。
文件 funcs.h 中有几个函数,但是该文件中典型的函数大致如下:
double InnerProduct(double *A, double **coords1, double **coords2, const int len)
我随后有一个对应行的.pyx文件:cdef extern from "funcs.h":
double InnerProduct(double *A, double **coords1, double **coords2, int len)
我去掉了const,因为cython不支持它。 我现在遇到的问题是如何编写包装器代码来将一个MxN的numpy数组传递给**coords1和**coords2参数。
我一直在寻找正确的文档或教程来解决这种类型的问题。 任何建议都将不胜感激。