![](https://secure.gravatar.com/avatar/500d9977605fceb8c50034674b88aa59.jpg?s=120&d=mm&r=g)
Hi all, I'm looking for a 'row-ish' sparse matrix format that I can operate on (including making new nonzero elements) quickly in C++ or Pyrex. Could anyone recommend one? The LIL format looks nice because it can be expanded without any copying, but I'm worried that having to call PyList_GetItem (or whatever it is), inc/decreffing and converting from Python to C integers will take up a lot of time. PyTrilinos' Epetra looks pretty cool but I'm not sure how much distributed memory stuff I'll be doing and it would take me a long time to understand. I'm thinking that a good solution might be Pyrex wrappers for matrices represented as C++ vectors of rows, which are themselves vectors; would this actually be a good solution, and is anything like this out there already? I'm a total sparse linear algebra neophyte, so if I'm missing some boat entirely please help me get a clue. Many thanks in advance, Anand Patil
![](https://secure.gravatar.com/avatar/e10338b149dd02f6b974b61b0869905c.jpg?s=120&d=mm&r=g)
Hi Anand, I use the COO-format for the creation of the matrix, because it could be assembled quite fast. A second advantage is, that you need to create the sparsity only the first time and then just create a vector with the non-zero entries. For calculations I convert it to CSR-Format, which is also quite fast. With this method I can create a 255^2*255^2 sparse matrix with roughly 8 non-zero entries per row in about 0.25 sec. Creating the matrix in LIL-format or DIC-format is a lot slower. Best regards, Boris On Nov 21, 2007 12:30 AM, Anand Patil <anand.prabhakar.patil@gmail.com> wrote:
Hi all,
I'm looking for a 'row-ish' sparse matrix format that I can operate on (including making new nonzero elements) quickly in C++ or Pyrex. Could anyone recommend one?
The LIL format looks nice because it can be expanded without any copying, but I'm worried that having to call PyList_GetItem (or whatever it is), inc/decreffing and converting from Python to C integers will take up a lot of time. PyTrilinos' Epetra looks pretty cool but I'm not sure how much distributed memory stuff I'll be doing and it would take me a long time to understand.
I'm thinking that a good solution might be Pyrex wrappers for matrices represented as C++ vectors of rows, which are themselves vectors; would this actually be a good solution, and is anything like this out there already?
I'm a total sparse linear algebra neophyte, so if I'm missing some boat entirely please help me get a clue.
Many thanks in advance, Anand Patil _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
participants (2)
-
Anand Patil
-
Boris von Loesch