Boost logo

Ublas :

From: James Sutherland (James.Sutherland_at_[hidden])
Date: 2008-08-13 14:17:28


On Aug 13, 2008, at 11:26 AM, Nizar Khalifa Sallem wrote:
>
> Second, the easy dirty way is to do something like :
> ublas::vector tmpRow = matrix_row<MatType> row( m, 1 );
> matrix_row<MatType> row( m, 1 ) = matrix_row<MatType> row( m, 3 );
> matrix_row<MatType> row( m, 3 ) = tmpRow;
>
> Finally, you may use iterators (you need to check for consistency):
> ublas::compressed_matrix<double>::iterator1 srcRowIt, dstRowIt
> ublas::compressed_matrix<double>::iterator2 src_ij, dst_ij, tmp_ij;
> dstRowIt = srcRowIt = m.begin1();//iterator over row 0
> ++srcRowIt;//here will iterate over row 1;
> dstRowIt+=3;//iterate over row 3;
> for (src_ij = srcRowIt.begin(), dst_ij = dstRowIt.begin();
> src_ij != srcRowIt.end();
> ++src_ij,++dst_ij) {
> tmp_ij = src_ij;
> src_ij = dst_ij;
> dst_ij = tmp_ij;
> // if you do something like src_ij = dst_ij; you will loose
> your row 1 elements'
> }
>
> I didn't check this code, if you want columns just invert iterator1
> and iterator 2

Thanks for the suggestions.

It seems to me that the examples you provide copy column 3 to column
1. However, I want to *move* it. In other words, I want move
coefficients within a given matrix_row from one column to another.

I don't see how the examples you provide do this. Perhaps I am just
confused???