|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
MTL: compressed2D insertionHi there,
I have an adjacency matrix of about 30000x30000 with ~200000 nonzero entries and I would like to use it with MTL. The matrix is in a file in matrix market format and I have slightly modified the first Matrix Insertion example to read it. The insertion of the first 100 elements already takes over 15 sec time, what am I doing wrong? I am using Visual Studio 2008 Express. The source code is as follows: // File: insert.cpp #include <iostream> #include <boost/numeric/mtl/mtl.hpp> using namespace mtl; template <typename Matrix> void insval(Matrix& m, int index1, int index2, double val) { // Matrices are not initialized by default m= 0.0; // Create inserter for matrix m matrix::inserter<Matrix> ins(m); // Insert value ins[index1][index2] << val; } int main(int argc, char* argv[]) { compressed2D<double> A(30000, 30000); FILE* matrixfile; matrixfile=fopen("A_cpp.txt","r"); int count=0, index1=0, index2=0; double value=0; clock_t start, finish; double duration; start = clock(); while(fscanf(matrixfile, "%d %d %Lg", &index1, &index2, &value)!=EOF && count<100){// insert first 100 values only count++; insval(A, index1-40360, index2-40360, value); // smallest index is 40360... } finish = clock(); duration = (double)(finish - start) / CLOCKS_PER_SEC; printf( "%2.1f seconds\n", duration ); return 0; } Thanks for your time! Rechnan _______________________________________________ This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/ |
|
|
Re: MTL: compressed2D insertionBurkhard
I think you should use block-wise insertion (see http://www.osl.iu.edu/research/mtl/mtl4/doc/matrix_insertion.html ). This is much faster. Nevertheless since you are reading your matrix data from a file you will need to think about how to block it first. Regards, Elmar -----Original Message----- From: mtl-devel-bounces@... [mailto:mtl-devel-bounces@...] On Behalf Of Burkhard Möller Sent: 16 October 2009 11:52 To: mtl-devel@... Subject: MTL: compressed2D insertion Hi there, I have an adjacency matrix of about 30000x30000 with ~200000 nonzero entries and I would like to use it with MTL. The matrix is in a file in matrix market format and I have slightly modified the first Matrix Insertion example to read it. The insertion of the first 100 elements already takes over 15 sec time, what am I doing wrong? I am using Visual Studio 2008 Express. The source code is as follows: // File: insert.cpp #include <iostream> #include <boost/numeric/mtl/mtl.hpp> using namespace mtl; template <typename Matrix> void insval(Matrix& m, int index1, int index2, double val) { // Matrices are not initialized by default m= 0.0; // Create inserter for matrix m matrix::inserter<Matrix> ins(m); // Insert value ins[index1][index2] << val; } int main(int argc, char* argv[]) { compressed2D<double> A(30000, 30000); FILE* matrixfile; matrixfile=fopen("A_cpp.txt","r"); int count=0, index1=0, index2=0; double value=0; clock_t start, finish; double duration; start = clock(); while(fscanf(matrixfile, "%d %d %Lg", &index1, &index2, &value)!=EOF && count<100){// insert first 100 values only count++; insval(A, index1-40360, index2-40360, value); // smallest index is 40360... } finish = clock(); duration = (double)(finish - start) / CLOCKS_PER_SEC; printf( "%2.1f seconds\n", duration ); return 0; } Thanks for your time! Rechnan _______________________________________________ This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/ Forward this message to spam@... to report this email as spam. Visit our website at http://www.halcrow.com ------------------------------------------------------------------------ The contents of this email are confidential, for the sole use of the intended recipient at the email address to which it has been addressed and do not give rise to any binding legal obligation upon Halcrow companies unless subsequently confirmed on headed business notepaper sent by fax, letter or as an email attachment. Whilst reasonable care has been taken to avoid virus transmission, no responsibility for viruses is taken and it is your responsibility to carry out such checks as you feel appropriate. Emails supplied are as found and there's no guarantee that the messages contained within the body of the email have not been edited after receipt. If you receive this email in error, please contact the sender immediately and delete the message from your system. Thank you. ------------------------------------------------------------------------- _______________________________________________ This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/ |
|
|
Re: MTL: compressed2D insertionHi Elmar,
thanks for your help! Since I am a C++ novice, this will take its time... but I am working on it! Since the adjacency matrix is of a graph that consits of cliques only, the building of the blocks will come in a natural way. Best, Burkhard
|
| Free embeddable forum powered by Nabble | Forum Help |