octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sparse matrices


From: Paul Thomas
Subject: Re: sparse matrices
Date: Tue, 13 Apr 2004 20:47:33 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

Andy Adler wrote:

On Tue, 13 Apr 2004, Paul Thomas wrote:

You are correct about the awkwardness of compressed column and
compressed row formats.  It is not apparent to me that the extra
compression over the coordinate ordered ( that doesn't sound like the
right name) format;  ie

                 a( i1 , j1 )        i1           j1
                 a(i2  ,j2  )        i2           j2

This format doesn't solve the difficulties. If you wish to
extract an element a(3,5); you can't directly index the matrix,
but you will need to search to find if the element exists.
To make searching efficient, the elements should be stored sorted,
but that is an additional complexity every time the matrix is changed.
Maybe a standard map would be the way to go, using the indices as the key? That way the sorting would be kept out of sight, within the standard library interface. Sequential access, using an iterator, is pretty rapid, and even keyed access only grows logarithmically with the number of non-zero elements.

I used SPARSEKIT2 by Yousef Saad, which has loads of conversion routines
between different formats in it and all the basic arithmetic operations.
It is, however, written in F77.

SPARSEKIT2 info can be found here:
http://www-users.cs.umn.edu/~saad/software/SPARSKIT/sparskit.html

It contains many, but not all, of the needed utility functions.
It is licenced under the GPL, and contains a sparse math implementation
( http://www-users.cs.umn.edu/~saad/spmath/ ) which provides
a "Matlab-like" interface.

I haven't used this tool; but it does look useful.
I partially wrote (ie everything that I needed) an F90 interface that made the functions look like Matlab's. F90 not have implemented automatic destructors for user defined types, when going out of scope, required a bit of artistic licence, to stop memory leaks, but that is another story. Code written in F90 usually outperformed Matlab by small factors. Form this, I would conclude that Sparsekit2 is sufficiently efficient.

andy


I am going out of scope myself for two weeks but would be happy to discuss this further on my return.

Paul T



reply via email to

[Prev in Thread] Current Thread [Next in Thread]