我試圖解決我的應用程序中的瓶頸問題,這是兩個矩陣的元素總和。使用指向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
那麼,有什麼問題?你遇到了什麼錯誤? –