getfem-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Getfem-users] gmm++ sparse matrices


From: Yves Renard
Subject: Re: [Getfem-users] gmm++ sparse matrices
Date: Wed, 31 Oct 2012 09:49:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2



Dear Laura Cattaneo,

Your code indeed should work and modify the Mbar matrix.
To be a liitle bit mor efficient, you could take non const iterators and replace the last line by

*it_nz /= sum_row;

Of course, when you iterate on a sparse vector and modify it, you have to care that the structure of the sparse vector is not modified (add or delete nonzero elements). Because in that case, the iterators are nolonger valid. In you case, this is ok.


Yves.


Le 31/10/2012 09:06, laura cattaneo a écrit :
Dear all,
I want to modify some values stored into a matrix, but I can't do it.

If I try to excute these lines of code:


      typename gmm::linalg_traits<MAT>::const_sub_row_type
    row = mat_const_row(Mbar,i);
      gmm::linalg_traits< gmm::rsvector<scalar_type> >::const_iterator
    it_nz = vect_const_begin(row);
      gmm::linalg_traits< gmm::rsvector<scalar_type> >::const_iterator
    ite_nz = vect_const_end(row);
      for (; it_nz != ite_nz ; ++it_nz) {
    Mbar(i, it_nz.index()) = (*it_nz)/sum_row;
    }

the values inside the Mbar matrix don't change and I don't understand why.

Some one can help me??

The MAT type is

typedef gmm::rsvector<scalar_type> sparse_vector_type;
typedef gmm::row_matrix<sparse_vector_type> sparse_matrix_type;


Thanks

Laura Cattaneo




_______________________________________________
Getfem-users mailing list
address@hidden
https://mail.gna.org/listinfo/getfem-users


-- 

  Yves Renard (address@hidden)       tel : (33) 04.72.43.87.08
  Pole de Mathematiques, INSA-Lyon             fax : (33) 04.72.43.85.29
  20, rue Albert Einstein
  69621 Villeurbanne Cedex, FRANCE
  http://math.univ-lyon1.fr/~renard

---------

reply via email to

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