|
Ublas : |
Subject: Re: [ublas] how to iterate over the elements of a mapped_matrix ?
From: Riccardo Rossi (rrossi_at_[hidden])
Date: 2011-02-08 02:40:31
Hello Thomas,
thank you for the snippet but...where did u take it from? i was
looking for the documentation but i could not find it. Could u pass me
the pointer for the future?
thanks
Riccardo
On Mon, 2011-02-07 at 17:51 -0800, Sunil Thomas wrote:
> Hi Riccardo,
>
> This follows straight from the ublas docs and examples
> therein..here's a snippet that may help:
>
>
> for(itm1 i1 = A.begin1(); i1 != A.end1(); ++i1) {
> int nnz = 0;
> itm2 i2 = i1.begin();
> irow = (int) i2.index1();
> //Loop over each row's non-zero elements
> for(; i2 != i1.end(); ++i2) {
> (m_cols)[nnz] = (int) i2.index2();
> (m_vals)[nnz] = *i2;
> ++nnz;
> }
> //-Some treatment of zero rows...
> if( nnz == 0 ) {
> (m_cols)[nnz] = irow;
> (m_vals)[nnz] = -1.0;
> ++nnz;
> }
> //-Do other stuff...blah blah
> }
>
> --Thomas.
>
>
>
> On Mon, Feb 7, 2011 at 10:13 AM, <rrossi_at_[hidden]> wrote:
> Dear list,
>
> i created a mapped_matrix and now i need to
> iterate over the non_zero elements of SOME rows.
>
> say i need all of the elements of row 123... how should i get
> them?
>
>
>
> thanks in advance
>
> Riccardo
>
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: sgthomas27_at_[hidden]
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
> Sent to: rrossi_at_[hidden]