[Dune] [Dune-Commit] dune-common r6877 - trunk/dune/common

Markus Blatt markus at dr-blatt.de
Tue Jul 31 14:00:48 CEST 2012


Hi,

frankly, I do not like this patch and I do not see how this improves
the behaviour.

IMHO there is guarantee that a constructor taking an int as an argument
is available.

Concerning multi-index (which was the problem, i guess) I missed
Martin's answer why it is initialized to 1. Isn't the default
constructor supposed to initialize to zero according to the standard?

Meanwhile a static method of the traits class returning a zero value
would probably be the most safe change.

Just my 2 cents.

BTW: This addition would have been perfect example for a branch,
wouldn't it?

Cheers,

Markus

On Tue, Jul 31, 2012 at 12:13:13PM +0200, christi at dune-project.org wrote:
> Author: christi
> Date: 2012-07-31 12:13:12 +0200 (Tue, 31 Jul 2012)
> New Revision: 6877
> 
> Modified:
>    trunk/dune/common/densevector.hh
> Log:
> [densevector]
> initialize result with 0
> (patch by Matthias Wohlmuth)
> 
> Modified: trunk/dune/common/densevector.hh
> ===================================================================
> --- trunk/dune/common/densevector.hh	2012-07-30 07:28:02 UTC (rev 6876)
> +++ trunk/dune/common/densevector.hh	2012-07-31 10:13:12 UTC (rev 6877)
> @@ -464,7 +464,7 @@
>      template<class Other>
>      typename PromotionTraits<field_type,typename DenseVector<Other>::field_type>::PromotedType operator* (const DenseVector<Other>& y) const {
>        typedef typename PromotionTraits<field_type, typename DenseVector<Other>::field_type>::PromotedType PromotedType;
> -      PromotedType result = PromotedType();
> +      PromotedType result(0);
>        assert(y.size() == size());
>        for (size_type i=0; i<size(); i++) {
>          result += PromotedType((*this)[i]*y[i]);
> @@ -482,7 +482,7 @@
>      template<class Other>
>      typename PromotionTraits<field_type,typename DenseVector<Other>::field_type>::PromotedType dot(const DenseVector<Other>& y) const {
>        typedef typename PromotionTraits<field_type, typename DenseVector<Other>::field_type>::PromotedType PromotedType;
> -      PromotedType result = PromotedType();
> +      PromotedType result(0);
>        assert(y.size() == size());
>        for (size_type i=0; i<size(); i++) {
>          result += Dune::dot((*this)[i],y[i]);
> 
> 
> _______________________________________________
> Dune-Commit mailing list
> Dune-Commit at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-commit
> 

-- 
Do you need more support with DUNE or HPC in general? 

Dr. Markus Blatt - HPC-Simulation-Software & Services http://www.dr-blatt.de
Hans-Bunte-Str. 8-10, 69123 Heidelberg, Germany
Tel.: +49 (0) 160 97590858  Fax: +49 (0)322 1108991658 




More information about the Dune mailing list