|
|
|
@ -36,6 +36,8 @@ class DualComplexTest: public Corrade::TestSuite::Tester { |
|
|
|
void complexConjugated(); |
|
|
|
void complexConjugated(); |
|
|
|
void dualConjugated(); |
|
|
|
void dualConjugated(); |
|
|
|
void conjugated(); |
|
|
|
void conjugated(); |
|
|
|
|
|
|
|
void inverted(); |
|
|
|
|
|
|
|
void invertedNormalized(); |
|
|
|
|
|
|
|
|
|
|
|
void debug(); |
|
|
|
void debug(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -57,6 +59,8 @@ DualComplexTest::DualComplexTest() { |
|
|
|
&DualComplexTest::complexConjugated, |
|
|
|
&DualComplexTest::complexConjugated, |
|
|
|
&DualComplexTest::dualConjugated, |
|
|
|
&DualComplexTest::dualConjugated, |
|
|
|
&DualComplexTest::conjugated, |
|
|
|
&DualComplexTest::conjugated, |
|
|
|
|
|
|
|
&DualComplexTest::inverted, |
|
|
|
|
|
|
|
&DualComplexTest::invertedNormalized, |
|
|
|
|
|
|
|
|
|
|
|
&DualComplexTest::debug); |
|
|
|
&DualComplexTest::debug); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -121,6 +125,30 @@ void DualComplexTest::conjugated() { |
|
|
|
CORRADE_COMPARE(a.conjugated(), b); |
|
|
|
CORRADE_COMPARE(a.conjugated(), b); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DualComplexTest::inverted() { |
|
|
|
|
|
|
|
DualComplex a({-1.0f, 2.5f}, { 3.0f, -7.5f}); |
|
|
|
|
|
|
|
DualComplex b({-1.0f, -2.5f}, { 3.0f, 7.5f}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CORRADE_COMPARE(a*a.inverted(), DualComplex()); |
|
|
|
|
|
|
|
CORRADE_COMPARE(a.inverted(), b/Dual(7.25f, -43.5f)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DualComplexTest::invertedNormalized() { |
|
|
|
|
|
|
|
DualComplex a({-1.0f, 2.5f}, { 3.0f, -7.5f}); |
|
|
|
|
|
|
|
DualComplex b({-1.0f, -2.5f}, { 3.0f, 7.5f}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ostringstream o; |
|
|
|
|
|
|
|
Error::setOutput(&o); |
|
|
|
|
|
|
|
CORRADE_COMPARE(a.invertedNormalized(), DualComplex()); |
|
|
|
|
|
|
|
CORRADE_COMPARE(o.str(), "Math::DualComplex::invertedNormalized(): dual complex number must be normalized\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DualComplex normalized = a.normalized(); |
|
|
|
|
|
|
|
DualComplex inverted = normalized.invertedNormalized(); |
|
|
|
|
|
|
|
CORRADE_COMPARE(normalized*inverted, DualComplex()); |
|
|
|
|
|
|
|
CORRADE_COMPARE(inverted*normalized, DualComplex()); |
|
|
|
|
|
|
|
CORRADE_COMPARE(inverted, b/Math::sqrt(Dual(7.25f, -43.5f))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void DualComplexTest::debug() { |
|
|
|
void DualComplexTest::debug() { |
|
|
|
std::ostringstream o; |
|
|
|
std::ostringstream o; |
|
|
|
|
|
|
|
|
|
|
|
|