[eigen] Calculation of weighted norm

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi!

I was wondering about the best way to calculate the weighted square norm of a complex vector, i.e.

x^t A x

where x is a complex vector and A is a real diagonal matrix. I tried

norm2=x.dot( A.asDiagonal() * x)

but this causes a compilation error when norm2 is real, since eigen assumes the result to be complex.
So I ended up writing

norm2=std::real(x.dot( A.asDiagonal() * x)).

Am I missing a more elegant solution or is this the recommended way of calculating a weighted norm?

Regards
Claas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/