In [1]:
%reload_ext Cython

In [22]:
%%cython
import numpy as np
cimport numpy as np
import cython

cdef myfunct():
    pass
#    object[double, ndim=1] V1, object[double, ndim=1] V2,object[double, ndim=1] V3, object[double, ndim=1] O,object[double, ndim=1] D):
#    cdef float EPSILON = 0.000001
#    e1 = np.subtract(V2,V1)
#    e2 = np.subtract(V3,V1)
#    P = np.cross(D, e2)
#    det = np.dot(e1, P)
#    if det > -EPSILON and det < EPSILON : return 0, 0
#    inv_det = float(1.0)/det
#    T = np.subtract(O, V1)
#    u = round(np.dot(T, P) * inv_det, 6)
#    if u < 0.0 or u > 1.0 : return 0, 0
#    Q = np.cross(T, e1)
#    v = round(np.dot(D, Q) * inv_det, 6)
#    if v < 0.0 or (u + v)  > 1.0 : return 0, 0
#    t = np.dot(e2, Q) * inv_det
#    if t > EPSILON :
#        return t, det
#    return 0, 0

In [23]:
V1 = np.array([0.0,0.0,-1.0])
V2 = np.array([0.0,0.0,1.0])
V3 = np.array([0.0,1.0,0.0])
p0 = [-1.0,0.5,0.0]
p1 = [1.0,0.5,0.0]
O = np.array(p0)
D = np.subtract(p1,p0)

In [30]:
type(D[0])


Out[30]:
numpy.float64

In [24]:
%%timeit -n1
myfunct(V1, V2, V3, O, D)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-24-9547a479f096> in <module>()
----> 1 get_ipython().run_cell_magic(u'timeit', u'-n1', u'myfunct(V1, V2, V3, O, D)')

C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.pyc in run_cell_magic(self, magic_name, line, cell)
   2113             magic_arg_s = self.var_expand(line, stack_depth)
   2114             with self.builtin_trap:
-> 2115                 result = fn(magic_arg_s, cell)
   2116             return result
   2117 

<decorator-gen-59> in timeit(self, line, cell)

C:\Anaconda\lib\site-packages\IPython\core\magic.pyc in <lambda>(f, *a, **k)
    186     # but it's overkill for just that one bit of state.
    187     def magic_deco(arg):
--> 188         call = lambda f, *a, **k: f(*a, **k)
    189 
    190         if callable(arg):

C:\Anaconda\lib\site-packages\IPython\core\magics\execution.pyc in timeit(self, line, cell)
   1047                     break
   1048                 number *= 10
-> 1049         all_runs = timer.repeat(repeat, number)
   1050         best = min(all_runs) / number
   1051 

C:\Anaconda\lib\timeit.pyc in repeat(self, repeat, number)
    228         r = []
    229         for i in range(repeat):
--> 230             t = self.timeit(number)
    231             r.append(t)
    232         return r

C:\Anaconda\lib\site-packages\IPython\core\magics\execution.pyc in timeit(self, number)
    137         gc.disable()
    138         try:
--> 139             timing = self.inner(it, self.timer)
    140         finally:
    141             if gcold:

<magic-timeit> in inner(_it, _timer)

NameError: global name 'myfunct' is not defined

In [ ]: