@@ -179,42 +179,86 @@ struct Vec256 {
179
179
}
180
180
return ret;
181
181
}
182
- template <typename other_t = T,
183
- typename std::enable_if<!std::is_floating_point<other_t >::value && !std ::is_complex_t <other_t >::value, int >::type = 0 >
182
+ template <typename other_t_abs = T,
183
+ typename std::enable_if<!std::is_floating_point<other_t_abs >::value && !c10 ::is_complex_t <other_t_abs >::value, int >::type = 0 >
184
184
Vec256<T> abs () const {
185
- // other_t is for SFINAE and clarity. Make sure it is not changed.
186
- static_assert (std::is_same<other_t , T>::value, " other_t must be T" );
187
- return map ([](T x) -> T { return x < static_cast <other_t >(0 ) ? -x : x; });
185
+ // other_t_abs is for SFINAE and clarity. Make sure it is not changed.
186
+ static_assert (std::is_same<other_t_abs , T>::value, " other_t_abs must be T" );
187
+ return map ([](T x) -> T { return x < static_cast <T >(0 ) ? -x : x; });
188
188
}
189
- template <typename float_t = T,
190
- typename std::enable_if<std::is_floating_point<float_t >::value, int >::type = 0 >
189
+ template <typename float_t_abs = T,
190
+ typename std::enable_if<std::is_floating_point<float_t_abs >::value, int >::type = 0 >
191
191
Vec256<T> abs () const {
192
- // float_t is for SFINAE and clarity. Make sure it is not changed.
193
- static_assert (std::is_same<float_t , T>::value, " float_t must be T" );
192
+ // float_t_abs is for SFINAE and clarity. Make sure it is not changed.
193
+ static_assert (std::is_same<float_t_abs , T>::value, " float_t_abs must be T" );
194
194
// Specifically deal with floating-point because the generic code above won't handle -0.0 (which should result in
195
195
// 0.0) properly.
196
196
return map (std::abs );
197
197
}
198
- template <typename complex_t = T,
199
- typename std::enable_if<std ::is_complex_t <complex_t >::value, int >::type = 0 >
198
+ template <typename complex_t_abs = T,
199
+ typename std::enable_if<c10 ::is_complex_t <complex_t_abs >::value, int >::type = 0 >
200
200
Vec256<T> abs () const {
201
- // complex_t is for SFINAE and clarity. Make sure it is not changed.
202
- static_assert (std::is_same<complex_t , T>::value, " complex_t must be T" );
201
+ // complex_t_abs is for SFINAE and clarity. Make sure it is not changed.
202
+ static_assert (std::is_same<complex_t_abs , T>::value, " complex_t_abs must be T" );
203
203
// Specifically map() does not perform the type conversion needed by abs.
204
- return map ([](T x) { return (T) std::abs (x); });
204
+ return map ([](T x) { return static_cast <T>( std::abs (x) ); });
205
205
}
206
+ template <typename other_t_angle = T,
207
+ typename std::enable_if<!c10::is_complex_t <other_t_angle>::value, int >::type = 0 >
206
208
Vec256<T> angle () const {
207
- return *this ;
209
+ // other_t_angle is for SFINAE and clarity. Make sure it is not changed.
210
+ static_assert (std::is_same<other_t_angle, T>::value, " other_t_angle must be T" );
211
+ return Vec256 (0 );
212
+ }
213
+ template <typename complex_t_angle = T,
214
+ typename std::enable_if<c10::is_complex_t <complex_t_angle>::value, int >::type = 0 >
215
+ Vec256<T> angle () const {
216
+ // complex_t_angle is for SFINAE and clarity. Make sure it is not changed.
217
+ static_assert (std::is_same<complex_t_angle, T>::value, " complex_t_angle must be T" );
218
+ return map ([](T x) { return static_cast <T>(std::arg (x)); });
208
219
}
220
+ template <typename other_t_real = T,
221
+ typename std::enable_if<!c10::is_complex_t <other_t_real>::value, int >::type = 0 >
209
222
Vec256<T> real () const {
223
+ // other_t_real is for SFINAE and clarity. Make sure it is not changed.
224
+ static_assert (std::is_same<other_t_real, T>::value, " other_t_real must be T" );
210
225
return *this ;
211
226
}
227
+ template <typename complex_t_real = T,
228
+ typename std::enable_if<c10::is_complex_t <complex_t_real>::value, int >::type = 0 >
229
+ Vec256<T> real () const {
230
+ // complex_t_real is for SFINAE and clarity. Make sure it is not changed.
231
+ static_assert (std::is_same<complex_t_real, T>::value, " complex_t_real must be T" );
232
+ return map ([](T x) { return static_cast <T>(x.real ()); });
233
+ }
234
+ template <typename other_t_imag = T,
235
+ typename std::enable_if<!c10::is_complex_t <other_t_imag>::value, int >::type = 0 >
212
236
Vec256<T> imag () const {
213
- return *this ;
237
+ // other_t_imag is for SFINAE and clarity. Make sure it is not changed.
238
+ static_assert (std::is_same<other_t_imag, T>::value, " other_t_imag must be T" );
239
+ return Vec256 (0 );
240
+ }
241
+ template <typename complex_t_imag = T,
242
+ typename std::enable_if<c10::is_complex_t <complex_t_imag>::value, int >::type = 0 >
243
+ Vec256<T> imag () const {
244
+ // complex_t_imag is for SFINAE and clarity. Make sure it is not changed.
245
+ static_assert (std::is_same<complex_t_imag, T>::value, " complex_t_imag must be T" );
246
+ return map ([](T x) { return static_cast <T>(x.imag ()); });
214
247
}
248
+ template <typename other_t_conj = T,
249
+ typename std::enable_if<!c10::is_complex_t <other_t_conj>::value, int >::type = 0 >
215
250
Vec256<T> conj () const {
251
+ // other_t_conj is for SFINAE and clarity. Make sure it is not changed.
252
+ static_assert (std::is_same<other_t_conj, T>::value, " other_t_conj must be T" );
216
253
return *this ;
217
254
}
255
+ template <typename complex_t_conj = T,
256
+ typename std::enable_if<c10::is_complex_t <complex_t_conj>::value, int >::type = 0 >
257
+ Vec256<T> conj () const {
258
+ // complex_t_conj is for SFINAE and clarity. Make sure it is not changed.
259
+ static_assert (std::is_same<complex_t_conj, T>::value, " complex_t_conj must be T" );
260
+ return map ([](T x) { return static_cast <T>(std::conj (x)); });
261
+ }
218
262
Vec256<T> acos () const {
219
263
return map (std::acos );
220
264
}
@@ -259,14 +303,14 @@ struct Vec256 {
259
303
return map (std::log1p );
260
304
}
261
305
template <typename other_t_log2 = T,
262
- typename std::enable_if<!std ::is_complex_t <other_t_log2>::value, int >::type = 0 >
306
+ typename std::enable_if<!c10 ::is_complex_t <other_t_log2>::value, int >::type = 0 >
263
307
Vec256<T> log2 () const {
264
308
// other_t_log2 is for SFINAE and clarity. Make sure it is not changed.
265
309
static_assert (std::is_same<other_t_log2, T>::value, " other_t_log2 must be T" );
266
310
return map (std::log2 );
267
311
}
268
312
template <typename complex_t_log2 = T,
269
- typename std::enable_if<std ::is_complex_t <complex_t_log2>::value, int >::type = 0 >
313
+ typename std::enable_if<c10 ::is_complex_t <complex_t_log2>::value, int >::type = 0 >
270
314
Vec256<T> log2 () const {
271
315
// complex_t_log2 is for SFINAE and clarity. Make sure it is not changed.
272
316
static_assert (std::is_same<complex_t_log2, T>::value, " complex_t_log2 must be T" );
@@ -395,7 +439,7 @@ template <class T> Vec256<T> inline operator||(
395
439
// Implements the IEEE 754 201X `maximum` operation, which propagates NaN if
396
440
// either input is a NaN.
397
441
template <class T ,
398
- typename std::enable_if<!std ::is_complex_t <T>::value, int >::type = 0 >
442
+ typename std::enable_if<!c10 ::is_complex_t <T>::value, int >::type = 0 >
399
443
Vec256<T> inline maximum (const Vec256<T> &a, const Vec256<T> &b) {
400
444
Vec256<T> c = Vec256<T>();
401
445
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -411,7 +455,7 @@ Vec256<T> inline maximum(const Vec256<T> &a, const Vec256<T> &b) {
411
455
}
412
456
413
457
template <class T ,
414
- typename std::enable_if<std ::is_complex_t <T>::value, int >::type = 0 >
458
+ typename std::enable_if<c10 ::is_complex_t <T>::value, int >::type = 0 >
415
459
Vec256<T> inline maximum (const Vec256<T> &a, const Vec256<T> &b) {
416
460
Vec256<T> c = Vec256<T>();
417
461
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -438,7 +482,7 @@ inline T maximum(const T& a, const T& b) {
438
482
// Implements the IEEE 754 201X `minimum` operation, which propagates NaN if
439
483
// either input is a NaN.
440
484
template <class T ,
441
- typename std::enable_if<!std ::is_complex_t <T>::value, int >::type = 0 >
485
+ typename std::enable_if<!c10 ::is_complex_t <T>::value, int >::type = 0 >
442
486
Vec256<T> inline minimum (const Vec256<T> &a, const Vec256<T> &b) {
443
487
Vec256<T> c = Vec256<T>();
444
488
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -454,7 +498,7 @@ Vec256<T> inline minimum(const Vec256<T> &a, const Vec256<T> &b) {
454
498
}
455
499
456
500
template <class T ,
457
- typename std::enable_if<std ::is_complex_t <T>::value, int >::type = 0 >
501
+ typename std::enable_if<c10 ::is_complex_t <T>::value, int >::type = 0 >
458
502
Vec256<T> inline minimum (const Vec256<T> &a, const Vec256<T> &b) {
459
503
Vec256<T> c = Vec256<T>();
460
504
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -480,7 +524,7 @@ inline T minimum(const T& a, const T& b) {
480
524
481
525
// To save BC, it will not propagate NaN based on IEEE 754 201X
482
526
template <class T ,
483
- typename std::enable_if<!std ::is_complex_t <T>::value, int >::type = 0 >
527
+ typename std::enable_if<!c10 ::is_complex_t <T>::value, int >::type = 0 >
484
528
Vec256<T> inline clamp (const Vec256<T> &a, const Vec256<T> &min_vec, const Vec256<T> &max_vec) {
485
529
Vec256<T> c = Vec256<T>();
486
530
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -490,7 +534,7 @@ Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec25
490
534
}
491
535
492
536
template <class T ,
493
- typename std::enable_if<std ::is_complex_t <T>::value, int >::type = 0 >
537
+ typename std::enable_if<c10 ::is_complex_t <T>::value, int >::type = 0 >
494
538
Vec256<T> inline clamp (const Vec256<T> &a, const Vec256<T> &min_vec, const Vec256<T> &max_vec) {
495
539
Vec256<T> c = Vec256<T>();
496
540
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -500,7 +544,7 @@ Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec25
500
544
}
501
545
502
546
template <class T ,
503
- typename std::enable_if<!std ::is_complex_t <T>::value, int >::type = 0 >
547
+ typename std::enable_if<!c10 ::is_complex_t <T>::value, int >::type = 0 >
504
548
Vec256<T> inline clamp_max (const Vec256<T> &a, const Vec256<T> &max_vec) {
505
549
Vec256<T> c = Vec256<T>();
506
550
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -510,7 +554,7 @@ Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
510
554
}
511
555
512
556
template <class T ,
513
- typename std::enable_if<std ::is_complex_t <T>::value, int >::type = 0 >
557
+ typename std::enable_if<c10 ::is_complex_t <T>::value, int >::type = 0 >
514
558
Vec256<T> inline clamp_max (const Vec256<T> &a, const Vec256<T> &max_vec) {
515
559
Vec256<T> c = Vec256<T>();
516
560
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -520,7 +564,7 @@ Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
520
564
}
521
565
522
566
template <class T ,
523
- typename std::enable_if<!std ::is_complex_t <T>::value, int >::type = 0 >
567
+ typename std::enable_if<!c10 ::is_complex_t <T>::value, int >::type = 0 >
524
568
Vec256<T> inline clamp_min (const Vec256<T> &a, const Vec256<T> &min_vec) {
525
569
Vec256<T> c = Vec256<T>();
526
570
for (int i = 0 ; i != Vec256<T>::size (); i++) {
@@ -530,7 +574,7 @@ Vec256<T> inline clamp_min(const Vec256<T> &a, const Vec256<T> &min_vec) {
530
574
}
531
575
532
576
template <class T ,
533
- typename std::enable_if<std ::is_complex_t <T>::value, int >::type = 0 >
577
+ typename std::enable_if<c10 ::is_complex_t <T>::value, int >::type = 0 >
534
578
Vec256<T> inline clamp_min (const Vec256<T> &a, const Vec256<T> &min_vec) {
535
579
Vec256<T> c = Vec256<T>();
536
580
for (int i = 0 ; i != Vec256<T>::size (); i++) {
0 commit comments