File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,18 @@ namespace cp_algo {
27
27
T abs () const {return std::sqrt (norm ());}
28
28
T real () const {return x;}
29
29
T imag () const {return y;}
30
+ T& real () {return x;}
31
+ T& imag () {return y;}
30
32
static complex polar (T r, T theta) {return {r * cos (theta), r * sin (theta)};}
31
33
auto operator <=> (complex const & t) const = default ;
32
34
};
33
35
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;}
35
37
template <typename T> complex<T> conj (complex<T> x) {return x.conj ();}
36
38
template <typename T> T norm (complex<T> x) {return x.norm ();}
37
39
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 ();}
38
42
template <typename T> T real (complex<T> x) {return x.real ();}
39
43
template <typename T> T imag (complex<T> x) {return x.imag ();}
40
44
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