Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-08-11 14:06:45


Darin,

On Wednesday 10 August 2005 03:44, Darin DeForest wrote:
> I'm trying to use scalar_vector for a r-value in a vector assignment. Such
> as:
>
> vector<int> a;
> a = scalar_vector( 3, 4 ); // 3 elements of the value 4
>
> This is generating a compiler error with the 1.33 rc2 boost code.
> error C2039: 'size' : is not a member of
> 'boost::numeric::ublas::vector_container<C>'

This is a nasty bug, I wish I had found this earlier!

> For this method in class vector:
>
> template<class C> // Container assignment without
> temporary BOOST_UBLAS_INLINE
> vector &operator = (const vector_container<C> &v) {
> resize (v.size (), false); // **<=== size on
> the vector container needed. assign (v);
> return *this;
> }

The correct code should read
        resize (v ().size (), false);

I have committed correct code. I don't think it is possible to fix this for
1.33 however. I have also added code into the tests so this case is checked.

> The work around seems to be
> a.assign( scalar_vector( 3, 4) );
OR
noalias (a) = scalar_vector( 3, 4);

Thanks,
        Michael

-- 
___________________________________
Michael Stevens Systems Engineering
34128 Kassel, Germany
Phone/Fax: +49 561 5218038
Navigation Systems, Estimation  and
                 Bayesian Filtering
    http://bayesclasses.sf.net
___________________________________