[Numpy-discussion] Help using numPy to create a very large multi dimensional array
Wed Apr 18 06:04:37 CDT 2007
Finally I was able to read the data, by using the command you sair with some
matrix = numpy.array([[float(x) for x in line.split()[1:]] for line in
But that doesn't solve my speed problem, now instead of taking 40seconds in
the slow step, takes 1min ant 10seconds :(
The slow step is this cycle:
for j in range(0, clust):
for k in range(j+1, clust):
for e in range(0, columns):
result = list_j[e] - list_k[e]
dist += result * result
if (dist < min):
ind = j
ind = k
min = dist
I also try with list_j = numpy.array but it only slower even more the
Does anyone have any ideia how I can speed up this step?
2007/4/18, Christian K. <email@example.com>:
> Bruno Santos wrote:
> > I try to use the expression as you said, but I'm not getting the desired
> > result,
> > My text file look like this:
> > # num rows=115 num columns=2634
> > AbassiM.txt 0.033023 0.033023 0.033023 0.165115 0.462321....0.000000
> > AgricoleW.txt 0.038691 0.038691 0.038691 0.232147 0.541676....0.215300
> > AliR.txt 0.041885 0.041885 0.041885 0.125656 0.586395....0.633580
> > .....
> > ....
> > ....
> > ZhangJ.txt 0.047189 0.047189 0.047189 0.155048 0.613452....0.000000
> I guess N.fromfile can't handle non numeric data. Use something like
> this instead (not tested):
> import numpy as N
> data = open('name of file').readlines()
> data = N.array([[float(x) for x in row.split(' ')[1:]] for row in
> (the above expression should be one line)
> Numpy-discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion