From: Dominique O. <dom...@gm...> - 2009-11-27 22:00:06
|
Hi Rodrigo, If you look at the jdsym documentation you will see that the input matrix (and preconditioners) need not be in linked-list format, or any other Pysparse format for that matter. The matrix object need only have the shape, matvec and matvec_transp attributes. If you can generate irow, jcol and val arrays efficiently, then it is easy to wrap those into a simple sparse matrix class that provides the required attributes. What kind of preconditioner are you using? Regards, Dominique On Thu, Nov 19, 2009 at 3:44 AM, iza...@t-... <iza...@t-...> wrote: > > Hello Dominique, > > Thank you very much for answering. Conversion to scipy sparse formats is not > as expensive as using put. I can generate the three vectors irow, icol, val > in a short time. The problem is to put the values in the pysparse ll format. > I can even generate a scipy linked list format efficiently, but the problem > is this is not the same as the pysparse linked list format and I can not use > it with jdsym. > > The option to use put is unfortunately very expensive ( I have tried it). I > will try to generate the pysparse matrix directly but I am afraid all the > operations I used are not supported. For example I do a very expensive > double loop operation in C with Pyrex and I am able to generate a n*n vector > that I reshape inside python to do further processing in matrix form. Can I > reshape a vector into pysparse matrix format? > > Best regards > > Rodrigo > > -- > Hi Rodrigo, > > Thanks for using PySparse! All comments can help us improve the > library. A (rough) design decision in PySparse is that matrix > operations should be "cheap", i.e., O(nnz), for matrices that are > indeed sparse. If your matrix is dense, I'm afraid any constructor of > the form spmatrix.ll_mat(K) will require O(n^2) operations. Please > correct me if I'm wrong but the Matrix Market format lists all the > nonzero elements of your matrix, and we *do* need all that information > to construct the matrix. I don't see how to lower this cost. Using a > different sparse format won't help either. > > What could help is detect any exploitable structure in your matrix. > Yes it is dense but it probably isn't random and may have some pattern > to it. For instance, it could be (anti-)symmetric, (block-)circulant, > (block-)Toeplitz, or whatever. I feel that is where savings might be > found. > > Alternatively, is there any chance to bypass the 2-dimensional array > that you process before building the PySparse matrix, construct the > PySparse matrix directly and operate on it instead? Or operate on > arrays of the form (irow,jcol,val) and then use put()? > > I hope this helps. Good luck. > > -- > Dominique > > ---Original-Nachricht----- > Subject: Re: [Pysparse-users] Full matrix conversion to spmatrix.ll_mat > Date: Wed, 18 Nov 2009 23:30:24 +0100 > From: Dominique Orban <dom...@gm...> > To: "iza...@t-..." <iza...@t-...> > > On Wed, Nov 18, 2009 at 11:47 AM, iza...@t-... > <iza...@t-...> wrote: >> Dear Sirs, >> >> Im using pysparse with the eigenvalue solver jdsym. It works great !!. >> The >> only problem I have at the moment is the conversion time from the original >> format of my matrix. Here is a description of my process: >> >> - Read a file wit around 20000 points >> - Process this points and get a very big array (20000*20000) (this part is >> done with pyrex) >> - I reshape the array into a matrix (20000,20000) >> - I do some math ( matrix transpose, matrix scaling, dot product, >> transpose, >> etc.) >> - I get a matrix from which I would like to obtain a couple of >> eigenvectors >> >> In order to use jdsm I need the matrix in linked list format. I have tried >> several things: >> >> - write the matrix in matrix market format (using scipy) and the read with >> spmatrix.ll_mat_from_mtx >> (it takes very very long) >> - convert directly to sparse coo format and then into ll format >> (I get an error that this format is not supported for conversion) >> - use the internal routine put(V,index1,index2) >> (this is faster but still takes a long time compared with the eigenvalue >> problem) >> - I also use >> for ii in range(N): >> for jj in range(N): >> Al[ii,jj]=K[ii,jj] >> (this is almost the same as using put) >> >> >> Is there any way to have it faster in the right format? This will improve >> a >> lot the all process of obtaining the eigenvalues. If would be great to >> have >> something like: >> >> spmatrix.ll_mat(K) >> >> where K is a full matrix. >> >> I appreciate any help with this problem. > > -- Dominique |