numpy_demo.pyx 191 Bytes
Newer Older
1
cimport numpy as cnp
2

3 4

def sum_of_squares(cnp.ndarray[double, ndim=1] arr):
5 6 7 8 9
    cdef long N = arr.shape[0]
    cdef double ss = 0
    for i in range(N):
        ss += arr[i]**2
    return ss