mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-13 09:53:13 +08:00
fix pow for uint32_t, disable pmul<Packet4ul>
This commit is contained in:
parent
7f06bcae2c
commit
29c8e3c754
@ -276,7 +276,7 @@ template<> struct packet_traits<uint64_t> : default_packet_traits
|
|||||||
HasTranspose = 0,
|
HasTranspose = 0,
|
||||||
HasNegate = 0,
|
HasNegate = 0,
|
||||||
HasSqrt = 0,
|
HasSqrt = 0,
|
||||||
|
HasMul = 0,
|
||||||
HasCmp = 1,
|
HasCmp = 1,
|
||||||
HasShift = 1
|
HasShift = 1
|
||||||
};
|
};
|
||||||
|
@ -2152,15 +2152,15 @@ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet handle_nonint_nonint_errors(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Packet, typename ScalarExponent>
|
template <typename Packet, typename ScalarExponent, std::enable_if_t<NumTraits<typename unpacket_traits<Packet>::type>::IsSigned, bool> = true>
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet handle_int_int(const Packet& x, const ScalarExponent& exponent) {
|
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet handle_int_int(const Packet& x, const ScalarExponent& exponent) {
|
||||||
typedef typename unpacket_traits<Packet>::type Scalar;
|
typedef typename unpacket_traits<Packet>::type Scalar;
|
||||||
|
|
||||||
// integer base, integer exponent case
|
// signed integer base, integer exponent case
|
||||||
|
|
||||||
// This routine handles negative and very large positive exponents
|
// This routine handles negative and very large positive exponents
|
||||||
// Signed integer overflow and divide by zero is undefined behavior
|
// Signed integer overflow and divide by zero is undefined behavior
|
||||||
// Unsigned intgers do not overflow
|
// Unsigned integers do not overflow
|
||||||
|
|
||||||
const bool exponent_is_odd = unary_pow::is_odd<ScalarExponent>::run(exponent);
|
const bool exponent_is_odd = unary_pow::is_odd<ScalarExponent>::run(exponent);
|
||||||
|
|
||||||
@ -2181,6 +2181,31 @@ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet handle_int_int(const Packet&
|
|||||||
result = pselect(pand(pow_is_one, pow_is_neg), pnegate(cst_pos_one), result);
|
result = pselect(pand(pow_is_one, pow_is_neg), pnegate(cst_pos_one), result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Packet, typename ScalarExponent, std::enable_if_t<!NumTraits<typename unpacket_traits<Packet>::type>::IsSigned, bool> = true>
|
||||||
|
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet handle_int_int(const Packet& x, const ScalarExponent& exponent) {
|
||||||
|
typedef typename unpacket_traits<Packet>::type Scalar;
|
||||||
|
|
||||||
|
// unsigned integer base, integer exponent case
|
||||||
|
|
||||||
|
// This routine handles negative and very large positive exponents
|
||||||
|
// Signed integer overflow and divide by zero is undefined behavior
|
||||||
|
// Unsigned integers do not overflow
|
||||||
|
|
||||||
|
const Scalar zero = Scalar(0);
|
||||||
|
const Scalar pos_one = Scalar(1);
|
||||||
|
|
||||||
|
const Packet cst_zero = pset1<Packet>(zero);
|
||||||
|
const Packet cst_pos_one = pset1<Packet>(pos_one);
|
||||||
|
|
||||||
|
const Packet pow_is_zero = exponent < 0 ? pcmp_lt(cst_pos_one, x) : pzero(x);
|
||||||
|
const Packet pow_is_one = pcmp_eq(cst_pos_one, x);
|
||||||
|
|
||||||
|
Packet result = pselect(pow_is_zero, cst_zero, x);
|
||||||
|
result = pselect(pow_is_one, cst_pos_one, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace unary_pow
|
} // end namespace unary_pow
|
||||||
|
|
||||||
template <typename Packet, typename ScalarExponent,
|
template <typename Packet, typename ScalarExponent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user