Re: compressed2D insertion

"Hess, Elmar" <[email protected]> Fri, 16 Oct 2009 12:27:48 +0100
Newsgroups gmane.comp.lib.mtl.devel
Message-ID <[email protected]>
Burkhard

I think you should use block-wise insertion (see http://www.osl.iu.edu/rese=
arch/mtl/mtl4/doc/matrix_insertion.html ). This is much faster.
Nevertheless since you are reading your matrix data from a file you will ne=
ed to think about how to block it first.

Regards,
Elmar
 =




-----Original Message-----
From: [email protected] [mailto:[email protected]] On=
 Behalf Of Burkhard M=F6ller
Sent: 16 October 2009 11:52
To: [email protected]
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=3D 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=3Dfopen("A_cpp.txt","r");

    int count=3D0, index1=3D0, index2=3D0;
    double value=3D0;

    clock_t start, finish;
    double duration;

    start =3D clock();

    while(fscanf(matrixfile, "%d %d %Lg", &index1, &index2, &value)!=3DEOF =

&& count<100){// insert first 100 values only
        count++;
        insval(A, index1-40360, index2-40360, value); // smallest index =

is 40360...
    }

    finish =3D clock();

    duration =3D (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 [email protected] 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/