Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-11-09 03:50:41


On Wednesday 08 November 2006 21:16, Fred wrote:
> I got an execution error pointing to the iterators. I think I can't explain
> what is happening without post the code, so I copy it below.
> Could you tell me if there's any problem with iteration in sparse
> matrix/vector?

1) You should not mix iterators and indices. You can always use it.index1()
and it.index2() to find the current position. Otherwise it may happen that
iterators skip some indices and reach their end() earlier than your counter.
2) You should prefer ++it over it++, because the latter is essentially
(tmp=it; ++it; return tmp;)
3) You can completely avoid using iterators if you use project()
  project( row(A, j), range(k,n) ) -= m * project( row(A, k), range(k,n) );
which is similar to the Matlab expression
  A(j,k:n) = A(j,k:n) - m * A(k,k:n);

Here the internal ublas mechanism automatically exploits the sparseness of
these vectors.

mfg
Gunter