@@ -12,38 +12,38 @@ namespace cp_algo {
1212 constexpr complex (): x(), y() {}
1313 constexpr complex (T const & x): x(x), y() {}
1414 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;}
27- complex operator - () const {return {-x, -y};}
28- complex conj () const {return {x, -y};}
29- T norm () const {return x * x + y * y;}
30- T abs () const {return std::sqrt (norm ());}
15+ [[gnu::target( " avx2 " )]] complex & operator *= (T const & t) {x *= t; y *= t; return *this ;}
16+ [[gnu::target( " avx2 " )]] complex & operator /= (T const & t) {x /= t; y /= t; return *this ;}
17+ [[gnu::target( " avx2 " )]] complex operator * (T const & t) const {return complex (*this ) *= t;}
18+ [[gnu::target( " avx2 " )]] complex operator / (T const & t) const {return complex (*this ) /= t;}
19+ [[gnu::target( " avx2 " )]] complex & operator += (complex const & t) {x += t.x ; y += t.y ; return *this ;}
20+ [[gnu::target( " avx2 " )]] complex & operator -= (complex const & t) {x -= t.x ; y -= t.y ; return *this ;}
21+ [[gnu::target( " avx2 " )]] complex operator * (complex const & t) const {return {x * t.x - y * t.y , x * t.y + y * t.x };}
22+ [[gnu::target( " avx2 " )]] complex operator / (complex const & t) const {return *this * t.conj () / t.norm ();}
23+ [[gnu::target( " avx2 " )]] complex operator + (complex const & t) const {return complex (*this ) += t;}
24+ [[gnu::target( " avx2 " )]] complex operator - (complex const & t) const {return complex (*this ) -= t;}
25+ [[gnu::target( " avx2 " )]] complex & operator *= (complex const & t) {return *this = *this * t;}
26+ [[gnu::target( " avx2 " )]] complex & operator /= (complex const & t) {return *this = *this / t;}
27+ [[gnu::target( " avx2 " )]] complex operator - () const {return {-x, -y};}
28+ [[gnu::target( " avx2 " )]] complex conj () const {return {x, -y};}
29+ [[gnu::target( " avx2 " )]] T norm () const {return x * x + y * y;}
30+ [[gnu::target( " avx2 " )]] T abs () const {return std::sqrt (norm ());}
3131 [[gnu::target(" avx2" )]] T const real () const {return x;}
3232 [[gnu::target(" avx2" )]] T const imag () const {return y;}
33- T& real () {return x;}
34- T& imag () {return y;}
35- static constexpr complex polar (T r, T theta) {return {T (r * cos (theta)), T (r * sin (theta))};}
36- auto operator <=> (complex const & t) const = default ;
33+ [[gnu::target( " avx2 " )]] T& real () {return x;}
34+ [[gnu::target( " avx2 " )]] T& imag () {return y;}
35+ [[gnu::target( " avx2 " )]] static constexpr complex polar (T r, T theta) {return {T (r * cos (theta)), T (r * sin (theta))};}
36+ [[gnu::target( " avx2 " )]] auto operator <=> (complex const & t) const = default ;
3737 };
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 ();}
41- template <typename T> T& real (complex <T> &x) {return x.real ();}
42- template <typename T> T& imag (complex <T> &x) {return x.imag ();}
38+ template <typename T> [[gnu::target( " avx2 " )]] complex <T> conj (complex <T> const & x) {return x.conj ();}
39+ template <typename T> [[gnu::target( " avx2 " )]] T norm (complex <T> const & x) {return x.norm ();}
40+ template <typename T> [[gnu::target( " avx2 " )]] T abs (complex <T> const & x) {return x.abs ();}
41+ template <typename T> [[gnu::target( " avx2 " )]] T& real (complex <T> &x) {return x.real ();}
42+ template <typename T> [[gnu::target( " avx2 " )]] 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 ();}
4444 template <typename T> [[gnu::target(" avx2" )]] T const imag (complex <T> const & x) {return x.imag ();}
4545 template <typename T>
46- constexpr complex <T> polar (T r, T theta) {
46+ [[gnu::target( " avx2 " )]] constexpr complex <T> polar (T r, T theta) {
4747 return complex <T>::polar (r, theta);
4848 }
4949 template <typename T>
0 commit comments