Boost logo

Boost :

From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2002-05-03 14:29:02


----- Original Message -----
From: "Peter Schmitteckert (boost)" <boost_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, May 03, 2002 10:14 AM
Subject: Re: [boost] ublas iterator [uBLAS vs MTL for sparse matrices]

> Salut,
>
> On Thursday 02 May 2002 21:56, Joerg Walter wrote:
> > ----- Original Message -----
> > From: "Paul C. Leopardi" <leopardi_at_[hidden]>
>
> > > To do this, GluCat routines use MTL iterators which provide iteration
> > > over the non-zero entries of a matrix. This means GluCat can iterate
over
> [..]
>
> > Iteration over a matrix is possible in the following way:
> >
> > for (numerics::sparse_matrix<double>::const_iterator1 itmr =
> > m.begin1 ();
> > itmr != m.end1 ();
> > ++ itmr) {
> > for (numerics::sparse_matrix<double>::const_iterator2 itmc
=
> > itmr.begin ();
> > itmc != itmr.end ();
> > ++ itmc) {
> > std::cout << *itmc << std::endl;
> > }
> > }
>
> I would also like to have an iterator, that iterates over all elements of
a
> matrix in the fastest way (depending on the storage scheme).
> For dense matrices, it should iterate over all elements, for hemitean on
one
> upper or lower triangle block, for sparse matrices over the non-zero
elements,
> etc. For dense matrices stored as a block, or for sparse matrices stored
in a
> std::map this should be more efficient the two loop version.

We recently discussed, that this could be achieved by accessing the internal
representation of a sparse_matrix. In the meantime we (hopefully ;-) added
all necessary members to allow for something like

    for (numerics::sparse_matrix<double>::array_type::const_iterator itm =
m.data().begin ();
        itm != m.data ().end ();
            ++ itm) {
                std::cout << (*itm).first << " " << (*itm).second <<
std::endl;
    }

Is this ok for you?

Regards

Joerg


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk