diff --git a/cp-algo/util/complex.hpp b/cp-algo/util/complex.hpp index 73f0ba1..a0f8b82 100644 --- a/cp-algo/util/complex.hpp +++ b/cp-algo/util/complex.hpp @@ -27,14 +27,18 @@ namespace cp_algo { T abs() const {return std::sqrt(norm());} T real() const {return x;} T imag() const {return y;} + T& real() {return x;} + T& imag() {return y;} static complex polar(T r, T theta) {return {r * cos(theta), r * sin(theta)};} auto operator <=> (complex const& t) const = default; }; template - complex operator * (auto x, complex y) {return y * x;} + complex operator * (auto x, complex y) {return y *= x;} template complex conj(complex x) {return x.conj();} template T norm(complex x) {return x.norm();} template T abs(complex x) {return x.abs();} + template T& real(complex &x) {return x.real();} + template T& imag(complex &x) {return x.imag();} template T real(complex x) {return x.real();} template T imag(complex x) {return x.imag();} template complex polar(T r, T theta) {return complex::polar(r, theta);}