|
Ublas : |
From: Michael Stevens (mail_at_[hidden])
Date: 2005-10-06 13:20:32
On Thursday 06 Oct 2005 16:26, Neal Becker wrote:
> I noticed that creating a zero_vector with some size, and then iterating
> over it produced strange results. Then I noticed this:
> BOOST_UBLAS_INLINE
> const_iterator begin () const {
> return const_iterator (*this);
> }
> BOOST_UBLAS_INLINE
> const_iterator end () const {
> return const_iterator (*this);
> }
Funny coincidence, I was looking at the same code today.
> Excuse me? Doesn't this mean begin() == end() and effectively size is
> always zero?
The iterators in zero_vector work fine. They do this by defining themselves as
Sparse Bidirectional Iterators.
This allows uBLAS to choose more effecient algorithms when zero_matrix is
assigned to a target. The target will be simply 'clear'ed and then nothing
copied.
identiy_vector uses the same mechanism. It iterates over the single element
which is 1.
Michael
-- ___________________________________ Michael Stevens Systems Engineering 34128 Kassel, Germany Phone/Fax: +49 561 5218038 Navigation Systems, Estimation and Bayesian Filtering http://bayesclasses.sf.net ___________________________________