[974] | 1 | cdef extern from "sphere_fast.h": |
---|
| 2 | cdef void fast_scale_vec(double, double[]) |
---|
| 3 | cdef void circum_batch(double*, double*) |
---|
| 4 | cdef void circum_fast_(int, long*, double*, double*) |
---|
| 5 | cdef void barycenters_fast_(int, long*, long*, double*, double*, double*, double*, double*) |
---|
| 6 | |
---|
| 7 | def scale_vec(double scale, double[::1] vec): |
---|
| 8 | fast_scale_vec(scale, &vec[0]) |
---|
| 9 | |
---|
| 10 | def circum_test(double[:,::1] pts, double[:,::1] circ): |
---|
| 11 | circum_batch(&pts[0,0], &circ[0,0]) |
---|
| 12 | |
---|
| 13 | def circum_fast(long[:,::1] ind, double[:,::1] pts, double[:,::1] circ): |
---|
| 14 | cdef int N = ind.shape[0] # number of circumcenters to compute |
---|
| 15 | # print('Computing %d circumcenters'%N) |
---|
| 16 | circum_fast_(N, &ind[0,0], &pts[0,0], &circ[0,0]) |
---|
| 17 | |
---|
| 18 | def barycenters_fast(long[::1] degree, long[::1] index, |
---|
| 19 | double[:,::1] point, double[::1] w_i, |
---|
| 20 | double[:,::1] vertex, double[::1] w_v, |
---|
| 21 | double[:,::1] bary): |
---|
| 22 | cdef int N=degree.shape[0] # number of voronoi cells |
---|
| 23 | |
---|
| 24 | cdef int sum=0 |
---|
| 25 | for i in range(N): |
---|
| 26 | sum += degree[i] |
---|
| 27 | |
---|
| 28 | # print(degree[0:10]) |
---|
| 29 | # print('Computing %d barycenters'%N) |
---|
| 30 | # print('degree.sum() = %d'%sum ) |
---|
| 31 | # print('index.size = %d'%index.size ) |
---|
| 32 | # print('point.shape = ', point.shape ) |
---|
| 33 | # print('vertex.shape = ', vertex.shape ) |
---|
| 34 | # print('bary.shape = ', bary.shape ) |
---|
| 35 | |
---|
| 36 | return barycenters_fast_(N, °ree[0], &index[0], |
---|
| 37 | &point[0,0], &w_i[0], |
---|
| 38 | &vertex[0,0], &w_v[0], |
---|
| 39 | &bary[0,0]) |
---|