Boost logo

Ublas :

From: Michael Stevens (mail_at_[hidden])
Date: 2005-06-23 12:33:51


On Thursday 23 June 2005 17:04, Marc Duflot wrote:
> Hello.
>
> I see that there is some discussion about the initialization to zero of
> vector elements and I understand that the default behaviour is to left
> them uninitialized (even if the documentation claims that 'Elements are
> zeroed by default' in the overview).
>
> Is there a way to change this behaviour with a macro, a template
> parameter or something else?
>
> I simply want to have this:
>
> typedef boost::numeric::ublas::??? my_vector_type;
> my_vector_type my_vector(1);
> assert (my_vector[0]==0.0);

Two possibilities
        my_vector_type<double> my_vector ( zero_vector<double>(1) );

OR
        my_vector_type my_vector(1); my_vector.clear ();

The latter is more efficient.

Some people like the syntax of zero_vector. To me it seems the additional
<double> is ugly. I think we could easily hide this by making the default
template parameter 'int'. This could apply to all the zero_ scalar_ and unit_
types. What do people think?

Michael

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