Boost logo

Ublas :

From: Michael Stevens (m-stevens_at_[hidden])
Date: 2005-01-26 11:38:39

On Wednesday 26 January 2005 16:35, Karl Meerbergen wrote:
> On Tuesday 25 January 2005 22:22, Vento Neicapelli wrote:
> > Dear uBlas developer,
> >
> > Is it possible to define a sparse and symmetric matrix. If yes could you
> > send me an example?
> >
> > Regards,
> >
> > vento
> Dear vento,
> In my opinion this is not possible in an efficient way. You could store the
> upper triangular part only in a sparse matrix and develop a library and
> routines for this type.

A bit more background on Karl's suggestion.

You can use a symmetric_adaptor on a sparse type. The syntax would is
        symmetric_adaptor<coordinate_matrix<double>, lower>

This give you something that is clean and simple to use. uBLAS will enforce
the symmetry. However this compond type is very hard for uBLAS to deal with.
When iterating over the elements it has to enforce both the symmetry and deal
with sparseness. These algorithms are not (and probably except in special
cases cannot be) very quick!

My method would be to use the symmetric_adaptor for simplicity and then
optimise algorithms that require greater speed.


Michael Stevens Systems Engineering
Navigation Systems, Estimation  and
                 Bayesian Filtering