Skip to content

Instantly share code, notes, and snippets.

@jskDr
Created February 26, 2014 13:02
Show Gist options
  • Save jskDr/9229118 to your computer and use it in GitHub Desktop.
Save jskDr/9229118 to your computer and use it in GitHub Desktop.
Cython with numpy in ipython
%%cython
import numpy as np
cimport numpy as np
from libc.math cimport sqrt
cimport cython
ctypedef double (*mertric_ptr)(np.ndarray, np.ndarray)
cdef double euclidean_distance( np.ndarray[double, ndim=1, mode='c'] x1):
N = x1.shape[0]
for i in range( N):
print x1[i]
return 0.0
def run():
X = np.ones( 10, dtype='double')
euclidean_distance( X)
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment