forked from szy21/pycles_GCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lookup.pyx
31 lines (23 loc) · 798 Bytes
/
Lookup.pyx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!python
#cython: boundscheck=False
#cython: wraparound=False
#cython: initializedcheck=False
#cython: cdivision=True
import numpy as np
cimport numpy as np
cdef class Lookup:
def __init__(self):
pass
cpdef initialize(self, double[:] x, double[:] y):
cdef long n = np.shape(y)[0]
init_table( &self.LookupStructC, n, &x[0], &y[0])
return
cpdef finalize(self):
free_table(&self.LookupStructC)
return
cpdef table_bounds(self):
return self.LookupStructC.x_min, self.LookupStructC.x_max, self.LookupStructC.y_min, self.LookupStructC.y_max
cpdef lookup(self, double x):
return lookup(&self.LookupStructC, x)
cdef inline double fast_lookup(self, double x) nogil:
return lookup(&self.LookupStructC, x)