@@ -10,20 +10,20 @@ namespace cp_algo {
1010 using value_type = T;
1111 T x, y;
1212 constexpr complex (): x(), y() {}
13- constexpr complex (T x): x(x), y() {}
14- constexpr complex (T x, T y): x(x), y(y) {}
15- complex & operator *= (T t) {x *= t; y *= t; return *this ;}
16- complex & operator /= (T t) {x /= t; y /= t; return *this ;}
17- complex operator * (T t) const {return complex (*this ) *= t;}
18- complex operator / (T t) const {return complex (*this ) /= t;}
19- complex & operator += (complex t) {x += t.x ; y += t.y ; return *this ;}
20- complex & operator -= (complex t) {x -= t.x ; y -= t.y ; return *this ;}
21- complex operator * (complex t) const {return {x * t.x - y * t.y , x * t.y + y * t.x };}
22- complex operator / (complex t) const {return *this * t.conj () / t.norm ();}
23- complex operator + (complex t) const {return complex (*this ) += t;}
24- complex operator - (complex t) const {return complex (*this ) -= t;}
25- complex & operator *= (complex t) {return *this = *this * t;}
26- complex & operator /= (complex t) {return *this = *this / t;}
13+ constexpr complex (T const & x): x(x), y() {}
14+ constexpr complex (T const & x, T const & y): x(x), y(y) {}
15+ complex & operator *= (T const & t) {x *= t; y *= t; return *this ;}
16+ complex & operator /= (T const & t) {x /= t; y /= t; return *this ;}
17+ complex operator * (T const & t) const {return complex (*this ) *= t;}
18+ complex operator / (T const & t) const {return complex (*this ) /= t;}
19+ complex & operator += (complex const & t) {x += t.x ; y += t.y ; return *this ;}
20+ complex & operator -= (complex const & t) {x -= t.x ; y -= t.y ; return *this ;}
21+ complex operator * (complex const & t) const {return {x * t.x - y * t.y , x * t.y + y * t.x };}
22+ complex operator / (complex const & t) const {return *this * t.conj () / t.norm ();}
23+ complex operator + (complex const & t) const {return complex (*this ) += t;}
24+ complex operator - (complex const & t) const {return complex (*this ) -= t;}
25+ complex & operator *= (complex const & t) {return *this = *this * t;}
26+ complex & operator /= (complex const & t) {return *this = *this / t;}
2727 complex operator - () const {return {-x, -y};}
2828 complex conj () const {return {x, -y};}
2929 T norm () const {return x * x + y * y;}
@@ -35,9 +35,9 @@ namespace cp_algo {
3535 static constexpr complex polar (T r, T theta) {return {T (r * cos (theta)), T (r * sin (theta))};}
3636 auto operator <=> (complex const & t) const = default ;
3737 };
38- template <typename T> complex <T> conj (complex <T> x) {return x.conj ();}
39- template <typename T> T norm (complex <T> x) {return x.norm ();}
40- template <typename T> T abs (complex <T> x) {return x.abs ();}
38+ template <typename T> complex <T> conj (complex <T> const & x) {return x.conj ();}
39+ template <typename T> T norm (complex <T> const & x) {return x.norm ();}
40+ template <typename T> T abs (complex <T> const & x) {return x.abs ();}
4141 template <typename T> T& real (complex <T> &x) {return x.real ();}
4242 template <typename T> T& imag (complex <T> &x) {return x.imag ();}
4343 template <typename T> [[gnu::target(" avx2" )]] T const real (complex <T> const & x) {return x.real ();}
@@ -47,7 +47,7 @@ namespace cp_algo {
4747 return complex <T>::polar (r, theta);
4848 }
4949 template <typename T>
50- std::ostream& operator << (std::ostream &out, complex <T> x) {
50+ std::ostream& operator << (std::ostream &out, complex <T> const & x) {
5151 return out << x.real () << ' ' << x.imag ();
5252 }
5353}
0 commit comments