Charles R Harris
Fri May 2 21:21:55 CDT 2008
On Fri, May 2, 2008 at 8:02 PM, Keith Goodman <email@example.com> wrote:
> On Fri, May 2, 2008 at 6:29 PM, Charles R Harris
> <firstname.lastname@example.org> wrote:
> > Isn't the lengthy part finding the distance between clusters? I can
> > of several ways to do that, but I think you will get a real speedup by
> > that in c or c++. I have a module made in boost python that holds
> > and returns a list of lists containing their elements. Clusters are
> > by joining any two elements, one from each. It wouldn't take much to add
> > distance function, but you could use the list of indices in each cluster
> > pull a subset out of the distance matrix and then find the minimum
> > in that. This also reminds me of Huffman codes.
> You're right. Finding the distance is slow. Is there any way to speed
> up the function below? It returns the row and column indices of the
> min value of the NxN array x.
> def dist(x):
> x = x + 1e10 * np.eye(x.shape)
x += x + diag(ones(x.shape)*1e10
would be faster.
> i, j = np.where(x == x.min())
> return i, j
i = x.argmin()
j = i % x.shape
i = i / x.shape
But I wouldn't worry about speed yet if you are just trying things out.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion