[SciPy-user] indexes in very large matrices

Kurt J kurtjx at gmail.com
Mon Mar 17 14:32:55 EDT 2008


Whoa! that is _really_ fast.  Thanks Robert!!  However, it seems i'm only
going thru the first row of my matrix, i'm a bit confused...

On Mon, Mar 17, 2008 at 6:09 PM, Robert Kern <robert.kern at gmail.com> wrote:

> On Mon, Mar 17, 2008 at 12:58 PM, Kurt J <kurtjx at gmail.com> wrote:
> > Hi List,
> >
> > I have a rather large matrix (15k x 15k) and I was hoping there was a
> nice
> > efficient way to search thru it.  Currently I am just using for loops to
> go
> > thru the rows and columns...
> >
> > > for i, iKey in enumerate(self.matrixKey):
> > >             for j, jKey in enumerate(self.matrixKey):
> > >                 if self.matrix[i][j] <= threshold and not
> > self.matrix[i][j] == 0.0:
> > >                     print "threshold at " + str(iKey) + " and "
> +str(jKey)
> > >
> >
> >
> > Can I do something more clever?  Quicker?
>
> Sure.
>
>  iarr, jarr = numpy.nonzero((self.matrix <= threshold) & (self.matrix !=
> 0))
>  for i, j in zip(iarr, jarr):
>      print 'threshold at %s and %s' % (self.matrixKey[i], self.matrixKey
> [j])
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080317/5137b045/attachment.html>


More information about the SciPy-User mailing list