From: <R.M...@ex...> - 2001-11-06 21:04:33
|
Hello, Does anyone have a working sparse matrix module for Numeric 20.2.0 and Python 2.1 (or similar). I'm tryinng to get the version in the SciPy CVS tree to work - so far without success. I don't want anything particularly fancy -- not even sparse matrix inversion. Addition and multiplication would be fine. Thanks for any ideas/pointers/software etc! Cheers, Richard. -- Department of Computer Science, Exeter University Voice: +44 1392 264065 R.M...@ex... Secretary: +44 1392 264061 http://www.dcs.ex.ac.uk/people/reverson Fax: +44 1392 264067 |
From: <vi...@id...> - 2002-07-30 13:42:54
|
I had noticed that Travis Oliphant had a sparse.py package, but it no longer is available (clicking on the link gives a "404"). I have a particular kind of sparse matrix that I'd like to use to give vector matrix multiplies. In particular, it's an n x n matrix which has at most k (which is small, usually 2 or 3) non-zeros in each row which are in consecutive locations. I have this encoded as an n x k matrix, the i-th row gives the non-zero values in the i-th row of the big matrix, and an n long vector of indices -- the i-th element gives the starting position in the i-th row. When I want to multiply this matrix by a row vector v on the left. To do the multiplication I do the following: # loc is the location vector n = matrix.shape[0] mm = reshape(v,(-1,1))*matrix w = zeros((n+m),v.typecode()) for i in range(mm.shape[0]): w[loc[i]:loc[i]+matrix.shape[1]] += w[i] w = w[:n] I would like to be able to replace the loop with some Numeric operations. Is there a trick to do this? Note that the n that I'm using is around 100000, so that storing the full matrix is out of the question (and multiplying by that matrix would be extremely inefficient, anyway). -- Victor S. Miller | " ... Meanwhile, those of us who can compute can hardly vi...@id... | be expected to keep writing papers saying 'I can do the CCR, Princeton, NJ | following useless calculation in 2 seconds', and indeed 08540 USA | what editor would publish them?" -- Oliver Atkin |
From: <vi...@id...> - 2002-07-30 15:28:59
|
Sorry, I had a typo in the program. It should be: # M is n by k, and represents a sparse n by n matrix A # the non-zero entries of row i of A start in column loc[i] # and are the i-th row of M in locations loc[i]:loc[i]+k # loc is the location vector n,k = M.shape mm = reshape(v,(-1,1))*M w = zeros((n+m),v.typecode()) # is there a trick to replace the loop below? for i in range(mm.shape[0]): w[loc[i]:loc[i]+k] += mm[i] w = w[:n] -- Victor S. Miller | " ... Meanwhile, those of us who can compute can hardly vi...@id... | be expected to keep writing papers saying 'I can do the CCR, Princeton, NJ | following useless calculation in 2 seconds', and indeed 08540 USA | what editor would publish them?" -- Oliver Atkin |
From: Jochen <jo...@un...> - 2002-07-30 16:23:30
|
On Tue, 30 Jul 2002 09:42:13 -0400 Victor S Miller wrote: Victor> I had noticed that Travis Oliphant had a sparse.py package, Victor> but it no longer is available (clicking on the link gives a Victor> "404"). It's part of scipy now. Greetings, Jochen -- University of North Carolina phone: +1-919-962-4403 Department of Chemistry phone: +1-919-962-1579 Venable Hall CB#3290 (Kenan C148) fax: +1-919-843-6041 Chapel Hill, NC 27599, USA GnuPG key: 44BCCD8E |
From: Herbert L. R. <roi...@ha...> - 2001-11-07 01:04:18
|
Travis Oliphant has one. H. ----- Original Message ----- From: "R.M.Everson" <R.M...@ex...> To: <num...@li...> Sent: Tuesday, November 06, 2001 11:03 AM Subject: [Numpy-discussion] Sparse matrices > > Hello, > > Does anyone have a working sparse matrix module for Numeric 20.2.0 and > Python 2.1 (or similar). I'm tryinng to get the version in the SciPy > CVS tree to work - so far without success. > > I don't want anything particularly fancy -- not even sparse matrix > inversion. Addition and multiplication would be fine. > > Thanks for any ideas/pointers/software etc! > > Cheers, > > Richard. > > -- > Department of Computer Science, Exeter University Voice: +44 1392 264065 > R.M...@ex... Secretary: +44 1392 264061 > http://www.dcs.ex.ac.uk/people/reverson Fax: +44 1392 264067 > > > _______________________________________________ > Numpy-discussion mailing list > Num...@li... > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > |
From: Jochen <jo...@jo...> - 2001-11-07 02:56:09
|
On Tue, 6 Nov 2001 15:01:18 -1000 Herbert L Roitblat wrote: Herbert> Travis Oliphant has one. Isn't that the one in SciPy? Herbert> ----- Original Message ----- Herbert> From: "R.M.Everson" <R.M...@ex...> Herbert> To: <num...@li...> Herbert> Sent: Tuesday, November 06, 2001 11:03 AM Herbert> Subject: [Numpy-discussion] Sparse matrices >> Does anyone have a working sparse matrix module for Numeric 20.2.0 >> and Python 2.1 (or similar). I'm tryinng to get the version in the >> SciPy CVS tree to work - so far without success. Herbert, this inverse citing really is counterproductive on mls. Greetings, Jochen -- Einigkeit und Recht und Freiheit http://www.Jochen-Kuepper.de Liberté, Égalité, Fraternité GnuPG key: 44BCCD8E Sex, drugs and rock-n-roll |