RE: Filling sparse matrix by A(i, i)=... .Fast for small matrices, slow for large.Is there a better way to fill the matrix?
"Guilherme Parreira" <[email protected]> Mon, 25 Apr 2005 12:42:29 -0300
| Newsgroups | gmane.comp.lib.mtl.devel |
|---|---|
| Message-ID | <[email protected]> |
The MTL documentation says to use iterators in order to speed up computation in matrices, but I don't know how. Regards, ============================== Eng. Guilherme F. Parreira Electrical Engineering Graduate Student GOPAC - UFMG - Brazil ============================== -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Tony Sent: domingo, 24 de abril de 2005 10:23 To: [email protected] Subject: MTL: Filling sparse matrix by A(i, i)=... .Fast for small matrices,slow for large.Is there a better way to fill the matrix? Hi I have a sparse matrix #define N 10000 typedef matrix< Type, rectangle<>, compressed<>, row_major >::type Matrix; Matrix A(N,N); and I am filling it up something like for(i=0; i < N ; i++){ A(i,i) = .... lots of other stuff in here setting up other elements of A } In my case I have quite a complex set of if statements in the loop setting up the A matrix and I have a maximum of 12 non zero entries on each row. The code works fine for small matrix sizes, say N less than 50,000. But when I set N larger than this the code runs very slowly. In my case I would like to run the code with N=1500000. But I need to leave the computer on for several days for A to be constructed. Question: Can I fill the elements of A in a faster way? I am wondering if if would be faster adding a whole row at a time to A, but I don't know how to do this, if this is a possibility can someone please show me how to do this and/or any other ways I can speed up filling up the elements of A Thank you for your time Tony _______________________________________________ This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/ _______________________________________________ This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/