void ComplexTest::construct() { constexpr Complex a = {0.5f, -3.7f}; CORRADE_COMPARE(a, Complex(0.5f, -3.7f)); constexpr Float b = a.real(); constexpr Float c = a.imaginary(); CORRADE_COMPARE(b, 0.5f); CORRADE_COMPARE(c, -3.7f); }
bool operator==(const Complex& a, const Complex& b) { return a.real() == b.real() && a.imaginary() == b.imaginary(); }
Complex Complex::times(Complex x) { return Complex(re * x.real() - im * x.imaginary(), re * x.imaginary() + im * x.real()); }
Complex Complex::minus(Complex x) { return Complex(re - x.real(), im - x.imaginary()); }
Complex Complex::add(const Complex& x) { return Complex(re + x.real(), im + x.imaginary()); }
constexpr static Cmpl to(const Complex<Float>& other) { return {other.real(), other.imaginary()}; }
void show(Complex x, string y) { double v_real = x.real(); double v_img = x.imaginary(); cout << y << " \t" << v_real << " " << v_img << endl; }