[Dune] arithmetic operators for FieldVector<K,1> (fwd)

Christian Engwer christi at uni-hd.de
Mon Dec 11 16:02:24 CET 2006


Hi all!

> I have found a problem when removing operator+ after all.  If you
> remove it from FieldVector<K,1>, you can still compile
> 
> FieldVector<K,N> a, b;
> double norm = (a+b).two_norm();
> 
> when N>=2, but not for N==1.
> We may want to consider this before removing the operators.

We can fix this issue by adding a lot of new operators.

The problem is the following:
* FieldVector<K,1> + K
  is ambiguous, will be fixed by removing operator+
* FieldVector<K,1> + FieldVector<K,1>
  works, but will be broken after removal of additional operators
* K + FieldVector<K,1>
  does not work, but would work after removal of operator+

We can add operator+(X,Y) for all these tree situations. After that
change will not have any ambiguities and all conversion will work.

When changing this, do we want operator*(FV<K,1>, K) and operator/ aswell?

I will already commit the first fix.

CU Christian




More information about the Dune mailing list