Boost logo

Ublas :

From: Ralf Denzer [MV] (denzer_at_[hidden])
Date: 2008-01-22 03:36:47


Hi,

instead of using a coordinate_matrix maybe you should
try to use a generalized vector of vectors, e.g.

#include <boost/numeric/ublas/vector_of_vector.hpp>

ublas::generalized_vector_of_vector< double,
ublas::row_major,
ublas::vector<ublas::compressed_vector<double> > > A(n,n);

for adding sparse matrices. At least in my application
that's the fastest approach (I hope so). Alternatively use
a
coordinate_vector<double> instead of
compressed_vector<double>

See also Gunters page
http://www.guwi17.de/ublas/matrix_sparse_usage.html

Bye

Ralf

> coordinate matrix and adding the compressed matrixes
>with this
> function:
>
> static void
> add_to (const ublas::compressed_matrix<double>& from,
> ublas::coordinate_matrix<double>& to)
> {
> for (ublas::compressed_matrix<double>::const_iterator1
>i1 = from.begin1 ();
> i1 != from.end1 ();
> ++i1)
> for
>(ublas::compressed_matrix<double>::const_iterator2 i2 =
>i1.begin ();
> i2 != i1.end ();
> ++i2)
> to.append_element (i2.index1 (), i2.index2 (),
>*i2);
> }
>
> and the banded matrixes with an index loop:
>
> for (size_t c = 0; c < cell_size; ++c)
> A_coord.append_element (c, c, B1 (c, c) + B2 (c, c) +
>B3 (c, c));
>
> Both approaches put the time spend in the addition (and
>converting to
> compressed) down to 1 minute. Still, three times as
>much time spend
> on addition than on building the component matrixes.
> Any suggestions
> for how to improve on this?
>
> The only idea I have left is to drop the component
>matrixes, and build
> A directly. But I fear this would leave the code very
>hard to
> maintain.
>
> PS: I build with -DNDEBUG and -O3.
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas