Skip to content

#1011 operator* in densevector used as dot product in dune-istl is not suitable for complex vectors

Metadata

Property Value
Reported by Matthias Wohlmuth (matthias.wohlmuth@ma.tum.de)
Reported at Jan 4, 2012 12:57
Type Bug Report
Version Git (pre2.4) [autotools]
Operating System Unspecified / All
Last edited by Christian Engwer (christi@conan.iwr.uni-heidelberg.de)
Last edited at Jul 11, 2012 16:08
Closed by Christian Engwer (christi@conan.iwr.uni-heidelberg.de)
Closed at Jul 11, 2012 16:08
Closed in version Unknown
Resolution Fixed
Comment

Description

operator* in densevector is documented (and implemented) as follows:

//! scalar product (x^T y) template value_type operator* (const DenseVector< Other > &y) const

For example in <dune/istl/scalarproducts.hh>, it is used as dot product for the solver classes in

virtual field_type dot (const X &x, const X &y)

Obviously, this is not the desired scalar product in the case of complex numbers.

So, how to resolve this issue.... I could provide a patch which takes the conjugate of one of the vectors and adds a type promotion for the case, that one vector is real and one is complex.

However, this patch has some unfortunate side effects.... For example, if you assemble boundary integrals, you might have to multiply a complex coefficient vector with the boundary normal. The most intuitive way seems to also you use operator*, which then leads to a hidden and probably unwanted complex conjugation. In particular, it depends on wether the implementation of operator* conjugates the first or the second argument. Therefore, this might introduce some trouble which is difficult to trace back....

So, perhaps it would be better to have the functionality of the present operator* together with a second operator (for example x.dot(y)) which is used for the scalar products. Of course, this would be an interface change and istl had to be adapted.

I'd appreciate your thoughts on that.

Thanks, Matthias