diff --git a/src/Math/Complex.h b/src/Math/Complex.h index 603a4a5459..4d46217b18 100644 --- a/src/Math/Complex.h +++ b/src/Math/Complex.h @@ -43,12 +43,12 @@ template class Complex { * @brief Dot product * * @f[ - * c_0 \cdot c_1 = c_0 \overline{c_1} = (a_0 a_1 + b_0 b_1) + i(a_1 b_0 - a_0 b_1) + * c_0 \cdot c_1 = a_0 a_1 + b_0 b_1 * @f] * @see dot() const */ - inline static Complex dot(const Complex& a, const Complex& b) { - return a*b.conjugated(); + inline static T dot(const Complex& a, const Complex& b) { + return a._real*b._real + a._imaginary*b._imaginary; } /** @@ -277,12 +277,12 @@ template class Complex { * * Should be used instead of length() for comparing complex number length * with other values, because it doesn't compute the square root. @f[ - * c \cdot c = c \overline c = a^2 + b^2 + * c \cdot c = a^2 + b^2 * @f] * @see dot(const Complex&, const Complex&) */ inline T dot() const { - return _real*_real + _imaginary*_imaginary; + return dot(*this, *this); } /** @@ -290,7 +290,7 @@ template class Complex { * * See also dot() const which is faster for comparing length with other * values. @f[ - * |c| = \sqrt{c \overline c} = \sqrt{a^2 + b^2} + * |c| = \sqrt{c \cdot c} * @f] */ inline T length() const { @@ -318,7 +318,7 @@ template class Complex { * * See invertedNormalized() which is faster for normalized * complex numbers. @f[ - * c^{-1} = \frac{\overline c}{c \overline c} = \frac{\overline c}{a^2 + b^2} + * c^{-1} = \frac{\overline c}{|c|^2} = \frac{\overline c}{c \cdot c} * @f] */ inline Complex inverted() const { diff --git a/src/Math/Test/ComplexTest.cpp b/src/Math/Test/ComplexTest.cpp index f9dafcaeed..fb169465f6 100644 --- a/src/Math/Test/ComplexTest.cpp +++ b/src/Math/Test/ComplexTest.cpp @@ -183,7 +183,7 @@ void ComplexTest::dot() { Complex a(5.0f, 3.0f); Complex b(6.0f, -7.0f); - CORRADE_COMPARE(Complex::dot(a, b), Complex(9.0f, 53.0f)); + CORRADE_COMPARE(Complex::dot(a, b), 9.0f); } void ComplexTest::dotSelf() {