mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix annoying warnings
This commit is contained in:
@@ -72,8 +72,9 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
|
||||
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
|
||||
#if !(defined(EIGEN_NO_STATIC_ASSERT) && defined(EIGEN_NO_DEBUG))
|
||||
typedef internal::scalar_conj_product_op<Scalar,typename OtherDerived::Scalar> func;
|
||||
EIGEN_CHECK_BINARY_COMPATIBILIY(func,Scalar,typename OtherDerived::Scalar);
|
||||
EIGEN_CHECK_BINARY_COMPATIBILIY(
|
||||
Eigen::internal::scalar_conj_product_op<Scalar EIGEN_COMMA typename OtherDerived::Scalar>,
|
||||
Scalar, typename OtherDerived::Scalar);
|
||||
#endif
|
||||
|
||||
eigen_assert(size() == other.size());
|
||||
|
||||
@@ -1366,8 +1366,7 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet pcarg(const Packet& a) {
|
||||
/** \internal \returns the argument of \a a as a complex number */
|
||||
template <typename Packet, std::enable_if_t<!is_scalar<Packet>::value, int> = 0>
|
||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Packet pcarg(const Packet& a) {
|
||||
using Scalar = typename unpacket_traits<Packet>::type;
|
||||
EIGEN_STATIC_ASSERT(NumTraits<Scalar>::IsComplex, THIS METHOD IS FOR COMPLEX TYPES ONLY)
|
||||
EIGEN_STATIC_ASSERT(NumTraits<typename unpacket_traits<Packet>::type>::IsComplex, THIS METHOD IS FOR COMPLEX TYPES ONLY)
|
||||
using RealPacket = typename unpacket_traits<Packet>::as_real;
|
||||
// a // r i r i ...
|
||||
RealPacket aflip = pcplxflip(a).v; // i r i r ...
|
||||
|
||||
@@ -775,11 +775,9 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
EIGEN_DEVICE_FUNC
|
||||
EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, std::enable_if_t<Base::SizeAtCompileTime!=2,T0>* = 0)
|
||||
{
|
||||
const bool t0_is_integer_alike = internal::is_valid_index_type<T0>::value;
|
||||
const bool t1_is_integer_alike = internal::is_valid_index_type<T1>::value;
|
||||
EIGEN_STATIC_ASSERT(t0_is_integer_alike &&
|
||||
t1_is_integer_alike,
|
||||
FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED)
|
||||
EIGEN_STATIC_ASSERT(internal::is_valid_index_type<T0>::value &&
|
||||
internal::is_valid_index_type<T1>::value,
|
||||
T0 AND T1 MUST BE INTEGER TYPES)
|
||||
resize(rows,cols);
|
||||
}
|
||||
|
||||
|
||||
@@ -334,14 +334,14 @@ template<typename TPlainObjectType, int Options, typename StrideType> class Ref<
|
||||
typedef internal::traits<Ref> Traits;
|
||||
|
||||
static constexpr bool may_map_m_object_successfully =
|
||||
(StrideType::InnerStrideAtCompileTime == 0 ||
|
||||
StrideType::InnerStrideAtCompileTime == 1 ||
|
||||
StrideType::InnerStrideAtCompileTime == Dynamic) &&
|
||||
(static_cast<int>(StrideType::InnerStrideAtCompileTime) == 0 ||
|
||||
static_cast<int>(StrideType::InnerStrideAtCompileTime) == 1 ||
|
||||
static_cast<int>(StrideType::InnerStrideAtCompileTime) == Dynamic) &&
|
||||
(TPlainObjectType::IsVectorAtCompileTime ||
|
||||
StrideType::OuterStrideAtCompileTime == 0 ||
|
||||
StrideType::OuterStrideAtCompileTime == Dynamic ||
|
||||
StrideType::OuterStrideAtCompileTime == TPlainObjectType::InnerSizeAtCompileTime ||
|
||||
TPlainObjectType::InnerSizeAtCompileTime == Dynamic);
|
||||
static_cast<int>(StrideType::OuterStrideAtCompileTime) == 0 ||
|
||||
static_cast<int>(StrideType::OuterStrideAtCompileTime) == Dynamic ||
|
||||
static_cast<int>(StrideType::OuterStrideAtCompileTime) == static_cast<int>(TPlainObjectType::InnerSizeAtCompileTime) ||
|
||||
static_cast<int>(TPlainObjectType::InnerSizeAtCompileTime) == Dynamic);
|
||||
public:
|
||||
|
||||
typedef RefBase<Ref> Base;
|
||||
|
||||
@@ -430,10 +430,34 @@ T div_ceil(const T &a, const T &b)
|
||||
return (a+b-1) / b;
|
||||
}
|
||||
|
||||
// Handle integer comparisons of different signedness.
|
||||
template <typename X, typename Y, bool XIsInteger = NumTraits<X>::IsInteger, bool XIsSigned = NumTraits<X>::IsSigned,
|
||||
bool YIsInteger = NumTraits<Y>::IsInteger, bool YIsSigned = NumTraits<Y>::IsSigned>
|
||||
struct equal_strict_impl {
|
||||
static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) { return x == y; }
|
||||
};
|
||||
template <typename X, typename Y>
|
||||
struct equal_strict_impl<X, Y, true, false, true, true> {
|
||||
// X is an unsigned integer
|
||||
// Y is a signed integer
|
||||
// if Y is non-negative, it may be represented exactly as its unsigned counterpart.
|
||||
using UnsignedY = typename internal::make_unsigned<Y>::type;
|
||||
static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) {
|
||||
return y < Y(0) ? false : (x == static_cast<UnsignedY>(y));
|
||||
}
|
||||
};
|
||||
template <typename X, typename Y>
|
||||
struct equal_strict_impl<X, Y, true, true, true, false> {
|
||||
// X is a signed integer
|
||||
// Y is an unsigned integer
|
||||
static EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool run(const X& x, const Y& y) {
|
||||
return equal_strict_impl<Y, X>::run(y, x);
|
||||
}
|
||||
};
|
||||
|
||||
// The aim of the following functions is to bypass -Wfloat-equal warnings
|
||||
// when we really want a strict equality comparison on floating points.
|
||||
template<typename X, typename Y> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
|
||||
bool equal_strict(const X& x,const Y& y) { return x == y; }
|
||||
template<typename X, typename Y> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const X& x, const Y& y) { return equal_strict_impl<X, Y>::run(x, y); }
|
||||
|
||||
#if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
|
||||
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
|
||||
@@ -458,7 +482,7 @@ template<typename X> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
|
||||
bool is_exactly_one(const X& x) { return equal_strict(x, typename NumTraits<X>::Literal{1}); }
|
||||
|
||||
template<typename X, typename Y> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
|
||||
bool not_equal_strict(const X& x,const Y& y) { return x != y; }
|
||||
bool not_equal_strict(const X& x,const Y& y) { return !equal_strict_impl<X, Y>::run(x, y); }
|
||||
|
||||
#if !defined(EIGEN_GPU_COMPILE_PHASE) || (!defined(EIGEN_CUDA_ARCH) && defined(EIGEN_CONSTEXPR_ARE_DEVICE_FUNC))
|
||||
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
|
||||
|
||||
@@ -17,12 +17,52 @@ namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename IndexDest, typename IndexSrc>
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline IndexDest convert_index(const IndexSrc& idx) {
|
||||
// for sizeof(IndexDest)>=sizeof(IndexSrc) compilers should be able to optimize this away:
|
||||
eigen_internal_assert(idx <= NumTraits<IndexDest>::highest() && "Index value to big for target type");
|
||||
return IndexDest(idx);
|
||||
|
||||
// useful for unsigned / signed integer comparisons when idx is intended to be non-negative
|
||||
template <typename IndexType>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename make_unsigned<IndexType>::type returnUnsignedIndexValue(
|
||||
const IndexType& idx) {
|
||||
EIGEN_STATIC_ASSERT((NumTraits<IndexType>::IsInteger), THIS FUNCTION IS FOR INTEGER TYPES)
|
||||
eigen_internal_assert(idx >= 0 && "Index value is negative and target type is unsigned");
|
||||
using UnsignedType = typename make_unsigned<IndexType>::type;
|
||||
return static_cast<UnsignedType>(idx);
|
||||
}
|
||||
|
||||
template <typename IndexDest, typename IndexSrc,
|
||||
bool IndexDestIsInteger = NumTraits<IndexDest>::IsInteger,
|
||||
bool IndexDestIsSigned = NumTraits<IndexDest>::IsSigned,
|
||||
bool IndexSrcIsInteger = NumTraits<IndexSrc>::IsInteger,
|
||||
bool IndexSrcIsSigned = NumTraits<IndexSrc>::IsSigned>
|
||||
struct convert_index_impl {
|
||||
static inline EIGEN_DEVICE_FUNC IndexDest run(const IndexSrc& idx) {
|
||||
eigen_internal_assert(idx <= NumTraits<IndexDest>::highest() && "Index value is too big for target type");
|
||||
return static_cast<IndexDest>(idx);
|
||||
}
|
||||
};
|
||||
template <typename IndexDest, typename IndexSrc>
|
||||
struct convert_index_impl<IndexDest, IndexSrc, true, true, true, false> {
|
||||
// IndexDest is a signed integer
|
||||
// IndexSrc is an unsigned integer
|
||||
static inline EIGEN_DEVICE_FUNC IndexDest run(const IndexSrc& idx) {
|
||||
eigen_internal_assert(idx <= returnUnsignedIndexValue(NumTraits<IndexDest>::highest()) &&
|
||||
"Index value is too big for target type");
|
||||
return static_cast<IndexDest>(idx);
|
||||
}
|
||||
};
|
||||
template <typename IndexDest, typename IndexSrc>
|
||||
struct convert_index_impl<IndexDest, IndexSrc, true, false, true, true> {
|
||||
// IndexDest is an unsigned integer
|
||||
// IndexSrc is a signed integer
|
||||
static inline EIGEN_DEVICE_FUNC IndexDest run(const IndexSrc& idx) {
|
||||
eigen_internal_assert(returnUnsignedIndexValue(idx) <= NumTraits<IndexDest>::highest() &&
|
||||
"Index value is too big for target type");
|
||||
return static_cast<IndexDest>(idx);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename IndexDest, typename IndexSrc>
|
||||
EIGEN_DEVICE_FUNC inline IndexDest convert_index(const IndexSrc& idx) {
|
||||
return convert_index_impl<IndexDest, IndexSrc>::run(idx);
|
||||
}
|
||||
|
||||
// true if T can be considered as an integral index (i.e., and integral type or enum)
|
||||
|
||||
@@ -368,9 +368,11 @@ protected:
|
||||
m_computeFullV(false),
|
||||
m_computeThinV(false),
|
||||
m_computationOptions(0),
|
||||
m_nonzeroSingularValues(0),
|
||||
m_rows(-1),
|
||||
m_cols(-1),
|
||||
m_diagSize(0) {}
|
||||
m_diagSize(0),
|
||||
m_prescribedThreshold(0) {}
|
||||
};
|
||||
|
||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||
|
||||
@@ -230,7 +230,7 @@ class EventCount {
|
||||
void Unpark(Waiter* w) {
|
||||
for (Waiter* next; w; w = next) {
|
||||
uint64_t wnext = w->next.load(std::memory_order_relaxed) & kStackMask;
|
||||
next = wnext == kStackMask ? nullptr : &waiters_[wnext];
|
||||
next = wnext == kStackMask ? nullptr : &waiters_[internal::convert_index<size_t>(wnext)];
|
||||
unsigned state;
|
||||
{
|
||||
EIGEN_MUTEX_LOCK lock(w->mu);
|
||||
|
||||
Reference in New Issue
Block a user