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 08:53:35 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

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

etc.

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.

Paul T

Andy Adler wrote:

On Mon, 12 Apr 2004, John W. Eaton wrote:

I'd like to get sparse matrices into the core Octave sources.

This will make a lot of people happy.

I've looked at the sparse directory in octave-forge, and I think it
would need a lot of work before I would include it as part of Octave.
One big problem I see is that it makes extensive use of malloc and
free, but for something in the core of Octave, it would really be best
to use new and delete, and then only in constructors/destructors, so
that we can avoid memory leaks.

The octave-forge sparse uses malloc/free because the underlying
SuperLU implementation does. Of course, this could be modified.

For starters, I would just like to be able to store data in a sparse
format and have some basic operations (assignment, indexing,
arithmetic ops, etc.).  It seems that the SuperLU package provides
some code for these things, but again, I think the implementation
would need a lot of work before it could be included as a part of
Octave.

SuperLU provides very minimal support for the basic sparse operations
you mentionned. Most of the rest was written by me. To be honest,
its surprisingly hard to write basic algebra operations on sparse
matrices. Keeping track of indexes while debugging the operations
was a huge challenge; not to mention trying to develop efficient
implementations.

Does anyone know of some good general-purpose code for handling sparse
matrix storage?

As of a few years ago, there were very few of these, and none under
a GPL compatible licence. I hope that that has changed.

SuperLU is fast, but I think somewhat less stable than that used
by matlab. Also, it is missing some column re-ordering functions.

If something like this does not exist, then it seems to me that
writing our own code for it should not be too hard.  The first
question is, what is the best storage scheme to use?  It seems that
something like compressed sparse column format is widely used, but it
does not allow one to add or remove elements efficiently.  It seems
that there must be better ways to manage the storage internally while
we might be adding or removing elements, then we could convert to a
particular storage format when needed to call a solver.

The compressed column sparse (Harwell-Boeing format) or compressed
row sparse seem to be by far the most common schemes. Also, this
is what Matlab uses internally. However, you are correct that
this format makes it hard to add or remove elements.

Comments or suggestions?

By (biased) opinion is that we should:
a) look for a good, free, sparse toolkit
and if that doesn't work
b) modify the octave-forge stuff as appropriate.

As I mentionned, I think debugging new sparse matrix code is
harder than refactoring a working package.

Andy






reply via email to

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