1
# Last Change: Thu Jul 13 04:00 PM 2006 J
9
# pyrex version of _vq. Much faster in high dimension/high number of K
13
label = numpy.zeros(n, int)
14
_imp_vq(data, init, label)
18
def _imp_vq(c_numpy.ndarray data, c_numpy.ndarray init, c_numpy.ndarray label):
26
cdef double *da, *code
30
n = data.dimensions[0]
31
d = data.dimensions[1]
32
nc = init.dimensions[0]
34
if not data.dtype == numpy.dtype(numpy.float64):
35
print '_vq not (yet) implemented for dtype %s'%dtype.name
37
da = (<double*>data.data)
39
if not init.dtype == numpy.dtype(numpy.float64):
40
print '_vq not (yet) implemented for dtype %s'%dtype.name
42
code = (<double*>init.data)
44
if not label.dtype == numpy.dtype(numpy.int32):
45
print '_vq not (yet) implemented for dtype %s'%dtype.name
47
labeld = (<int*>label.data)
53
acc = acc + (da[i * d + j] - code[j]) * \
54
(da[i * d + j] - code[j])
59
acc = acc + (da[i * d + j] - code[k * d + j]) * \
60
(da[i * d + j] - code[k * d + j])