Skip to content

Instantly share code, notes, and snippets.

@b-rodrigues
Created December 2, 2014 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-rodrigues/1c12c4d2c64ffb7b7d11 to your computer and use it in GitHub Desktop.
Save b-rodrigues/1c12c4d2c64ffb7b7d11 to your computer and use it in GitHub Desktop.
cimport cython
cdef class MatOpC:
#no need to declare the matrices anymore, they're declared inside the pxd file
#cdef public double[:, ::1] matA, matB
def __init__(self, A, B):
self.matA = A
self.matB = B
@cython.boundscheck(False)
@cython.wraparound(False)
cpdef cumsumC(self):
cdef int i, j, lA, lB
cdef float result = 0
lA = len(self.matA)
lB = len(self.matB)
for i in range(0,lA):
for j in range(0,lB):
result = result + self.matA[i,j] * self.matB[i,j]
return(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment