Created
February 26, 2014 13:02
-
-
Save jskDr/9229118 to your computer and use it in GitHub Desktop.
Cython with numpy in ipython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%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