File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,18 @@ namespace cp_algo {
2727 T abs () const {return std::sqrt (norm ());}
2828 T real () const {return x;}
2929 T imag () const {return y;}
30+ T& real () {return x;}
31+ T& imag () {return y;}
3032 static complex polar (T r, T theta) {return {r * cos (theta), r * sin (theta)};}
3133 auto operator <=> (complex const & t) const = default ;
3234 };
3335 template <typename T>
34- complex <T> operator * (auto x, complex <T> y) {return y * x;}
36+ complex <T> operator * (auto x, complex <T> y) {return y *= x;}
3537 template <typename T> complex <T> conj (complex <T> x) {return x.conj ();}
3638 template <typename T> T norm (complex <T> x) {return x.norm ();}
3739 template <typename T> T abs (complex <T> x) {return x.abs ();}
40+ template <typename T> T& real (complex <T> &x) {return x.real ();}
41+ template <typename T> T& imag (complex <T> &x) {return x.imag ();}
3842 template <typename T> T real (complex <T> x) {return x.real ();}
3943 template <typename T> T imag (complex <T> x) {return x.imag ();}
4044 template <typename T> complex <T> polar (T r, T theta) {return complex <T>::polar (r, theta);}
You can’t perform that action at this time.
0 commit comments