|
|
@ -216,7 +216,7 @@ public:
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename other_t_abs = T,
|
|
|
|
template <typename other_t_abs = T,
|
|
|
|
typename std::enable_if<!is_floating_point<other_t_abs>::value && !c10::is_complex_t<other_t_abs>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!is_floating_point<other_t_abs>::value && !c10::is_complex<other_t_abs>::value, int>::type = 0>
|
|
|
|
Vec256<T> abs() const {
|
|
|
|
Vec256<T> abs() const {
|
|
|
|
// other_t_abs is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// other_t_abs is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<other_t_abs, T>::value, "other_t_abs must be T");
|
|
|
|
static_assert(std::is_same<other_t_abs, T>::value, "other_t_abs must be T");
|
|
|
@ -232,7 +232,7 @@ public:
|
|
|
|
return map([](T x) -> T { return std::abs(x); });
|
|
|
|
return map([](T x) -> T { return std::abs(x); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename complex_t_abs = T,
|
|
|
|
template <typename complex_t_abs = T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<complex_t_abs>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<complex_t_abs>::value, int>::type = 0>
|
|
|
|
Vec256<T> abs() const {
|
|
|
|
Vec256<T> abs() const {
|
|
|
|
// complex_t_abs is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// complex_t_abs is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<complex_t_abs, T>::value, "complex_t_abs must be T");
|
|
|
|
static_assert(std::is_same<complex_t_abs, T>::value, "complex_t_abs must be T");
|
|
|
@ -240,56 +240,56 @@ public:
|
|
|
|
return map([](T x) { return static_cast<T>(std::abs(x)); });
|
|
|
|
return map([](T x) { return static_cast<T>(std::abs(x)); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename other_t_angle = T,
|
|
|
|
template <typename other_t_angle = T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<other_t_angle>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<other_t_angle>::value, int>::type = 0>
|
|
|
|
Vec256<T> angle() const {
|
|
|
|
Vec256<T> angle() const {
|
|
|
|
// other_t_angle is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// other_t_angle is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<other_t_angle, T>::value, "other_t_angle must be T");
|
|
|
|
static_assert(std::is_same<other_t_angle, T>::value, "other_t_angle must be T");
|
|
|
|
return Vec256(0);
|
|
|
|
return Vec256(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename complex_t_angle = T,
|
|
|
|
template <typename complex_t_angle = T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<complex_t_angle>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<complex_t_angle>::value, int>::type = 0>
|
|
|
|
Vec256<T> angle() const {
|
|
|
|
Vec256<T> angle() const {
|
|
|
|
// complex_t_angle is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// complex_t_angle is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<complex_t_angle, T>::value, "complex_t_angle must be T");
|
|
|
|
static_assert(std::is_same<complex_t_angle, T>::value, "complex_t_angle must be T");
|
|
|
|
return map([](T x) { return static_cast<T>(std::arg(x)); });
|
|
|
|
return map([](T x) { return static_cast<T>(std::arg(x)); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename other_t_real = T,
|
|
|
|
template <typename other_t_real = T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<other_t_real>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<other_t_real>::value, int>::type = 0>
|
|
|
|
Vec256<T> real() const {
|
|
|
|
Vec256<T> real() const {
|
|
|
|
// other_t_real is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// other_t_real is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<other_t_real, T>::value, "other_t_real must be T");
|
|
|
|
static_assert(std::is_same<other_t_real, T>::value, "other_t_real must be T");
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename complex_t_real = T,
|
|
|
|
template <typename complex_t_real = T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<complex_t_real>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<complex_t_real>::value, int>::type = 0>
|
|
|
|
Vec256<T> real() const {
|
|
|
|
Vec256<T> real() const {
|
|
|
|
// complex_t_real is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// complex_t_real is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<complex_t_real, T>::value, "complex_t_real must be T");
|
|
|
|
static_assert(std::is_same<complex_t_real, T>::value, "complex_t_real must be T");
|
|
|
|
return map([](T x) { return static_cast<T>(x.real()); });
|
|
|
|
return map([](T x) { return static_cast<T>(x.real()); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename other_t_imag = T,
|
|
|
|
template <typename other_t_imag = T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<other_t_imag>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<other_t_imag>::value, int>::type = 0>
|
|
|
|
Vec256<T> imag() const {
|
|
|
|
Vec256<T> imag() const {
|
|
|
|
// other_t_imag is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// other_t_imag is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<other_t_imag, T>::value, "other_t_imag must be T");
|
|
|
|
static_assert(std::is_same<other_t_imag, T>::value, "other_t_imag must be T");
|
|
|
|
return Vec256(0);
|
|
|
|
return Vec256(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename complex_t_imag = T,
|
|
|
|
template <typename complex_t_imag = T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<complex_t_imag>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<complex_t_imag>::value, int>::type = 0>
|
|
|
|
Vec256<T> imag() const {
|
|
|
|
Vec256<T> imag() const {
|
|
|
|
// complex_t_imag is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// complex_t_imag is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<complex_t_imag, T>::value, "complex_t_imag must be T");
|
|
|
|
static_assert(std::is_same<complex_t_imag, T>::value, "complex_t_imag must be T");
|
|
|
|
return map([](T x) { return static_cast<T>(x.imag()); });
|
|
|
|
return map([](T x) { return static_cast<T>(x.imag()); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename other_t_conj = T,
|
|
|
|
template <typename other_t_conj = T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<other_t_conj>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<other_t_conj>::value, int>::type = 0>
|
|
|
|
Vec256<T> conj() const {
|
|
|
|
Vec256<T> conj() const {
|
|
|
|
// other_t_conj is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// other_t_conj is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<other_t_conj, T>::value, "other_t_conj must be T");
|
|
|
|
static_assert(std::is_same<other_t_conj, T>::value, "other_t_conj must be T");
|
|
|
|
return *this;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename complex_t_conj = T,
|
|
|
|
template <typename complex_t_conj = T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<complex_t_conj>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<complex_t_conj>::value, int>::type = 0>
|
|
|
|
Vec256<T> conj() const {
|
|
|
|
Vec256<T> conj() const {
|
|
|
|
// complex_t_conj is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// complex_t_conj is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<complex_t_conj, T>::value, "complex_t_conj must be T");
|
|
|
|
static_assert(std::is_same<complex_t_conj, T>::value, "complex_t_conj must be T");
|
|
|
@ -351,14 +351,14 @@ public:
|
|
|
|
return map(std::log1p);
|
|
|
|
return map(std::log1p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename other_t_log2 = T,
|
|
|
|
template <typename other_t_log2 = T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<other_t_log2>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<other_t_log2>::value, int>::type = 0>
|
|
|
|
Vec256<T> log2() const {
|
|
|
|
Vec256<T> log2() const {
|
|
|
|
// other_t_log2 is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// other_t_log2 is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<other_t_log2, T>::value, "other_t_log2 must be T");
|
|
|
|
static_assert(std::is_same<other_t_log2, T>::value, "other_t_log2 must be T");
|
|
|
|
return map(std::log2);
|
|
|
|
return map(std::log2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename complex_t_log2 = T,
|
|
|
|
template <typename complex_t_log2 = T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<complex_t_log2>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<complex_t_log2>::value, int>::type = 0>
|
|
|
|
Vec256<T> log2() const {
|
|
|
|
Vec256<T> log2() const {
|
|
|
|
// complex_t_log2 is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
// complex_t_log2 is for SFINAE and clarity. Make sure it is not changed.
|
|
|
|
static_assert(std::is_same<complex_t_log2, T>::value, "complex_t_log2 must be T");
|
|
|
|
static_assert(std::is_same<complex_t_log2, T>::value, "complex_t_log2 must be T");
|
|
|
@ -522,7 +522,7 @@ template <class T> Vec256<T> inline operator||(
|
|
|
|
// Implements the IEEE 754 201X `maximum` operation, which propagates NaN if
|
|
|
|
// Implements the IEEE 754 201X `maximum` operation, which propagates NaN if
|
|
|
|
// either input is a NaN.
|
|
|
|
// either input is a NaN.
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline maximum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> inline maximum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -538,7 +538,7 @@ Vec256<T> inline maximum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline maximum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> inline maximum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -565,7 +565,7 @@ inline T maximum(const T& a, const T& b) {
|
|
|
|
// Implements the IEEE 754 201X `minimum` operation, which propagates NaN if
|
|
|
|
// Implements the IEEE 754 201X `minimum` operation, which propagates NaN if
|
|
|
|
// either input is a NaN.
|
|
|
|
// either input is a NaN.
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline minimum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> inline minimum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -581,7 +581,7 @@ Vec256<T> inline minimum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline minimum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> inline minimum(const Vec256<T> &a, const Vec256<T> &b) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -607,7 +607,7 @@ inline T minimum(const T& a, const T& b) {
|
|
|
|
|
|
|
|
|
|
|
|
// To save BC, it will not propagate NaN based on IEEE 754 201X
|
|
|
|
// To save BC, it will not propagate NaN based on IEEE 754 201X
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -617,7 +617,7 @@ Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec25
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -627,7 +627,7 @@ Vec256<T> inline clamp(const Vec256<T> &a, const Vec256<T> &min_vec, const Vec25
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -637,7 +637,7 @@ Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -647,7 +647,7 @@ Vec256<T> inline clamp_max(const Vec256<T> &a, const Vec256<T> &max_vec) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<!c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<!c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline clamp_min(const Vec256<T> &a, const Vec256<T> &min_vec) {
|
|
|
|
Vec256<T> inline clamp_min(const Vec256<T> &a, const Vec256<T> &min_vec) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
@ -657,7 +657,7 @@ Vec256<T> inline clamp_min(const Vec256<T> &a, const Vec256<T> &min_vec) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T,
|
|
|
|
template <class T,
|
|
|
|
typename std::enable_if<c10::is_complex_t<T>::value, int>::type = 0>
|
|
|
|
typename std::enable_if<c10::is_complex<T>::value, int>::type = 0>
|
|
|
|
Vec256<T> inline clamp_min(const Vec256<T> &a, const Vec256<T> &min_vec) {
|
|
|
|
Vec256<T> inline clamp_min(const Vec256<T> &a, const Vec256<T> &min_vec) {
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
Vec256<T> c = Vec256<T>();
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|
for (int i = 0; i != Vec256<T>::size(); i++) {
|
|
|
|