我试图解决我的应用程序中的瓶颈问题,这是两个矩阵的元素总和。使用指向numpy数组数据的属性属性
我使用NumPy的和用Cython。我有一个cdef
类与矩阵属性。由于Cython仍然不支持类属性中的缓冲区数组,我跟在this之后,并尝试使用指向矩阵的data
属性的指针。结果表明,事情是,我确定我做错了什么。
我试图做的是或多或少如下:
cdef class the_class:
cdef np.ndarray the_matrix
cdef float_t* the_matrix_p
def __init__(self):
the_matrix_p = <float_t*> self.the_matrix.data
cpdef the_function(self):
other_matrix = self.get_other_matrix()
the_matrix_p += other_matrix.data
那么,有什么问题?你遇到了什么错误? –