mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-07 18:27:40 +08:00
Fix annoying warnings
This commit is contained in:
parent
63dcb429cd
commit
1a2bfca8f0
@ -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);
|
||||
|
@ -267,8 +267,15 @@ void float_pow_test_impl() {
|
||||
#ifdef EIGEN_COMP_MSVC
|
||||
// Work around MSVC return value on underflow.
|
||||
// if std::pow returns 0 and Eigen returns a denormalized value, then skip the test
|
||||
int fpclass = std::fpclassify(a);
|
||||
if (e == Base(0) && fpclass == FP_SUBNORMAL) continue;
|
||||
int eigen_fpclass = std::fpclassify(a);
|
||||
if (e == Base(0) && eigen_fpclass == FP_SUBNORMAL) continue;
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_VECTORIZE_NEON
|
||||
// Work around NEON flush-to-zero mode
|
||||
// if std::pow returns denormalized value and Eigen returns 0, then skip the test
|
||||
int ref_fpclass = std::fpclassify(e);
|
||||
if (a == Base(0) && ref_fpclass == FP_SUBNORMAL) continue;
|
||||
#endif
|
||||
|
||||
bool both_nan = (numext::isnan)(a) && (numext::isnan)(e);
|
||||
@ -330,10 +337,6 @@ void test_exponent(Exponent exponent) {
|
||||
for (Base a : y) {
|
||||
Base e = ref_pow<Base, Exponent>::run(base, exponent);
|
||||
bool pass = (a == e);
|
||||
//if (!NumTraits<Base>::IsInteger) {
|
||||
// pass = pass || (((numext::isfinite)(e) && internal::isApprox(a, e)) ||
|
||||
// ((numext::isnan)(a) && (numext::isnan)(e)));
|
||||
//}
|
||||
all_pass &= pass;
|
||||
if (!pass) {
|
||||
std::cout << "pow(" << base << "," << exponent << ") = " << a << " != " << e << std::endl;
|
||||
@ -442,12 +445,6 @@ void signbit_tests() {
|
||||
signbit_test<double>();
|
||||
signbit_test<Eigen::half>();
|
||||
signbit_test<Eigen::bfloat16>();
|
||||
|
||||
signbit_test<uint8_t>();
|
||||
signbit_test<uint16_t>();
|
||||
signbit_test<uint32_t>();
|
||||
signbit_test<uint64_t>();
|
||||
|
||||
signbit_test<int8_t>();
|
||||
signbit_test<int16_t>();
|
||||
signbit_test<int32_t>();
|
||||
@ -1324,67 +1321,62 @@ EIGEN_DECLARE_TEST(array_cwise)
|
||||
CALL_SUBTEST_2( array_generic(Array22f()) );
|
||||
CALL_SUBTEST_3( array_generic(Array44d()) );
|
||||
CALL_SUBTEST_4( array_generic(ArrayXXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_5( array_generic(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_6( array_generic(ArrayXXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_6( array_generic(Array<Index,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_7( signed_shift_test(ArrayXXi(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_7( signed_shift_test(Array<Index, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_8( array_generic(Array<uint32_t, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_8( array_generic(Array<uint64_t, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_7( array_generic(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_8( array_generic(ArrayXXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_7( array_generic(Array<Index,Dynamic,Dynamic>(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_8( signed_shift_test(ArrayXXi(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_9( signed_shift_test(Array<Index, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_10( array_generic(Array<uint32_t, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_11( array_generic(Array<uint64_t, Dynamic, Dynamic>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE), internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1( comparisons(Array<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( comparisons(Array22f()) );
|
||||
CALL_SUBTEST_3( comparisons(Array44d()) );
|
||||
CALL_SUBTEST_5( comparisons(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_6( comparisons(ArrayXXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_7( comparisons(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_8( comparisons(ArrayXXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1( min_max(Array<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( min_max(Array22f()) );
|
||||
CALL_SUBTEST_3( min_max(Array44d()) );
|
||||
CALL_SUBTEST_5( min_max(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_6( min_max(ArrayXXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_6( min_max(Array<float, 1, 1>()) );
|
||||
CALL_SUBTEST_7( min_max(Array22f()) );
|
||||
CALL_SUBTEST_8( min_max(Array44d()) );
|
||||
CALL_SUBTEST_9( min_max(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_10( min_max(ArrayXXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1( array_real(Array<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( array_real(Array22f()) );
|
||||
CALL_SUBTEST_3( array_real(Array44d()) );
|
||||
CALL_SUBTEST_5( array_real(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_7( array_real(Array<Eigen::half, 32, 32>()) );
|
||||
CALL_SUBTEST_8( array_real(Array<Eigen::bfloat16, 32, 32>()) );
|
||||
CALL_SUBTEST_11( array_real(Array<float, 1, 1>()) );
|
||||
CALL_SUBTEST_12( array_real(Array22f()) );
|
||||
CALL_SUBTEST_13( array_real(Array44d()) );
|
||||
CALL_SUBTEST_14( array_real(ArrayXXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_15( array_real(Array<Eigen::half, 32, 32>()) );
|
||||
CALL_SUBTEST_16( array_real(Array<Eigen::bfloat16, 32, 32>()) );
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_4( array_complex(ArrayXXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_5( array_complex(ArrayXXcd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_17( array_complex(ArrayXXcf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_18( array_complex(ArrayXXcd(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))));
|
||||
}
|
||||
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_5( float_pow_test() );
|
||||
CALL_SUBTEST_6( int_pow_test() );
|
||||
CALL_SUBTEST_7( mixed_pow_test() );
|
||||
CALL_SUBTEST_8( signbit_tests() );
|
||||
CALL_SUBTEST_19( float_pow_test() );
|
||||
CALL_SUBTEST_20( int_pow_test() );
|
||||
CALL_SUBTEST_21( mixed_pow_test() );
|
||||
CALL_SUBTEST_22( signbit_tests() );
|
||||
}
|
||||
for (int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_2( typed_logicals_test(ArrayX<int>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_2( typed_logicals_test(ArrayX<float>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_3( typed_logicals_test(ArrayX<double>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_3( typed_logicals_test(ArrayX<std::complex<float>>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_3( typed_logicals_test(ArrayX<std::complex<double>>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_23( typed_logicals_test(ArrayX<int>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_24( typed_logicals_test(ArrayX<float>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_25( typed_logicals_test(ArrayX<double>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))) );
|
||||
CALL_SUBTEST_26( typed_logicals_test(ArrayX<std::complex<float>>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
CALL_SUBTEST_27( typed_logicals_test(ArrayX<std::complex<double>>(internal::random<int>(1, EIGEN_TEST_MAX_SIZE))));
|
||||
}
|
||||
|
||||
for (int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST_1((cast_test<1, 1>()));
|
||||
CALL_SUBTEST_2((cast_test<3, 1>()));
|
||||
CALL_SUBTEST_2((cast_test<3, 3>()));
|
||||
CALL_SUBTEST_3((cast_test<5, 1>()));
|
||||
CALL_SUBTEST_3((cast_test<5, 5>()));
|
||||
CALL_SUBTEST_4((cast_test<9, 1>()));
|
||||
CALL_SUBTEST_4((cast_test<9, 9>()));
|
||||
CALL_SUBTEST_5((cast_test<17, 1>()));
|
||||
CALL_SUBTEST_5((cast_test<17, 17>()));
|
||||
CALL_SUBTEST_6((cast_test<Dynamic, 1>()));
|
||||
CALL_SUBTEST_6((cast_test<Dynamic, Dynamic>()));
|
||||
CALL_SUBTEST_28( (cast_test<1, 1>()) );
|
||||
CALL_SUBTEST_29( (cast_test<3, 1>()) );
|
||||
CALL_SUBTEST_30( (cast_test<5, 1>()) );
|
||||
CALL_SUBTEST_31( (cast_test<9, 1>()) );
|
||||
CALL_SUBTEST_32( (cast_test<17, 1>()) );
|
||||
CALL_SUBTEST_33( (cast_test<Dynamic, 1>()) );
|
||||
}
|
||||
|
||||
VERIFY((internal::is_same< internal::global_math_functions_filtering_base<int>::type, int >::value));
|
||||
|
@ -69,8 +69,10 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
x = v1(static_cast<unsigned int>(r1));
|
||||
x = v1(static_cast<signed long>(r1));
|
||||
x = v1(static_cast<unsigned long>(r1));
|
||||
x = v1(static_cast<long long int>(r1));
|
||||
x = v1(static_cast<unsigned long long int>(r1));
|
||||
if(sizeof(Index) >= sizeof(long long int))
|
||||
x = v1(static_cast<long long int>(r1));
|
||||
if(sizeof(Index) >= sizeof(unsigned long long int))
|
||||
x = v1(static_cast<unsigned long long int>(r1));
|
||||
|
||||
VERIFY_IS_APPROX( v1, v1);
|
||||
VERIFY_IS_NOT_APPROX( v1, 2*v1);
|
||||
|
@ -23,7 +23,7 @@ struct random_without_cast_overflow {
|
||||
template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
SrcScalar, TgtScalar,
|
||||
std::enable_if_t<NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger &&
|
||||
std::enable_if_t<NumTraits<SrcScalar>::IsInteger && NumTraits<SrcScalar>::IsSigned && NumTraits<TgtScalar>::IsInteger &&
|
||||
!NumTraits<TgtScalar>::IsSigned &&
|
||||
(std::numeric_limits<SrcScalar>::digits < std::numeric_limits<TgtScalar>::digits ||
|
||||
(std::numeric_limits<SrcScalar>::digits == std::numeric_limits<TgtScalar>::digits &&
|
||||
@ -34,12 +34,27 @@ struct random_without_cast_overflow<
|
||||
}
|
||||
};
|
||||
|
||||
// Signed to unsigned integer widening cast.
|
||||
template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
SrcScalar, TgtScalar,
|
||||
std::enable_if_t<NumTraits<SrcScalar>::IsInteger && !NumTraits<SrcScalar>::IsSigned && NumTraits<TgtScalar>::IsInteger &&
|
||||
!NumTraits<TgtScalar>::IsSigned &&
|
||||
(std::numeric_limits<SrcScalar>::digits < std::numeric_limits<TgtScalar>::digits ||
|
||||
(std::numeric_limits<SrcScalar>::digits == std::numeric_limits<TgtScalar>::digits &&
|
||||
NumTraits<SrcScalar>::IsSigned))>> {
|
||||
static SrcScalar value() {
|
||||
SrcScalar a = internal::random<SrcScalar>();
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
// Integer to unsigned narrowing cast.
|
||||
template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
SrcScalar, TgtScalar,
|
||||
std::enable_if_t<
|
||||
NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger && !NumTraits<SrcScalar>::IsSigned &&
|
||||
NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger && NumTraits<TgtScalar>::IsSigned && !NumTraits<SrcScalar>::IsSigned &&
|
||||
(std::numeric_limits<SrcScalar>::digits > std::numeric_limits<TgtScalar>::digits)>> {
|
||||
static SrcScalar value() {
|
||||
TgtScalar b = internal::random<TgtScalar>();
|
||||
@ -47,6 +62,19 @@ struct random_without_cast_overflow<
|
||||
}
|
||||
};
|
||||
|
||||
// Integer to unsigned narrowing cast.
|
||||
template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
SrcScalar, TgtScalar,
|
||||
std::enable_if_t<
|
||||
NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger && !NumTraits<TgtScalar>::IsSigned && !NumTraits<SrcScalar>::IsSigned &&
|
||||
(std::numeric_limits<SrcScalar>::digits > std::numeric_limits<TgtScalar>::digits)>> {
|
||||
static SrcScalar value() {
|
||||
TgtScalar b = internal::random<TgtScalar>();
|
||||
return static_cast<SrcScalar>(b);
|
||||
}
|
||||
};
|
||||
|
||||
// Integer to signed narrowing cast.
|
||||
template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
@ -83,7 +111,7 @@ template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
SrcScalar, TgtScalar,
|
||||
std::enable_if_t<
|
||||
!NumTraits<SrcScalar>::IsInteger && !NumTraits<SrcScalar>::IsComplex && NumTraits<TgtScalar>::IsInteger &&
|
||||
!NumTraits<SrcScalar>::IsInteger && !NumTraits<SrcScalar>::IsComplex && NumTraits<TgtScalar>::IsInteger && NumTraits<TgtScalar>::IsSigned &&
|
||||
(std::numeric_limits<TgtScalar>::digits > std::numeric_limits<SrcScalar>::digits)>> {
|
||||
static SrcScalar value() {
|
||||
// NOTE: internal::random<T>() is limited by RAND_MAX, so random<int64_t> is always within that range.
|
||||
@ -95,6 +123,22 @@ struct random_without_cast_overflow<
|
||||
}
|
||||
};
|
||||
|
||||
template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
SrcScalar, TgtScalar,
|
||||
std::enable_if_t<
|
||||
!NumTraits<SrcScalar>::IsInteger && !NumTraits<SrcScalar>::IsComplex && NumTraits<TgtScalar>::IsInteger && !NumTraits<TgtScalar>::IsSigned &&
|
||||
(std::numeric_limits<TgtScalar>::digits > std::numeric_limits<SrcScalar>::digits)>> {
|
||||
static SrcScalar value() {
|
||||
// NOTE: internal::random<T>() is limited by RAND_MAX, so random<int64_t> is always within that range.
|
||||
// This prevents us from simply shifting bits, which would result in only 0 or -1.
|
||||
// Instead, keep least-significant K bits and sign.
|
||||
static const TgtScalar KeepMask = (static_cast<TgtScalar>(1) << std::numeric_limits<SrcScalar>::digits) - 1;
|
||||
const TgtScalar a = internal::random<TgtScalar>();
|
||||
return static_cast<SrcScalar>(a & KeepMask);
|
||||
}
|
||||
};
|
||||
|
||||
// Integer to floating-point, re-use above logic.
|
||||
template <typename SrcScalar, typename TgtScalar>
|
||||
struct random_without_cast_overflow<
|
||||
|
@ -124,7 +124,7 @@ void std_vector_gcc_warning()
|
||||
{
|
||||
typedef Eigen::Vector3f T;
|
||||
std::vector<T, Eigen::aligned_allocator<T> > v;
|
||||
v.push_back(T());
|
||||
v.push_back(T(1.0f,2.0f,3.0f));
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(stdvector)
|
||||
|
@ -998,8 +998,8 @@ class StridedLinearBufferCopy {
|
||||
enum {
|
||||
Vectorizable = packet_traits<Scalar>::Vectorizable,
|
||||
PacketSize = packet_traits<Scalar>::size,
|
||||
HasHalfPacket = unpacket_traits<HalfPacket>::size < PacketSize,
|
||||
HalfPacketSize = unpacket_traits<HalfPacket>::size,
|
||||
HasHalfPacket = static_cast<int>(HalfPacketSize) < static_cast<int>(PacketSize)
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -181,15 +181,16 @@ class FFT
|
||||
typedef typename impl_type::Scalar Scalar;
|
||||
typedef typename impl_type::Complex Complex;
|
||||
|
||||
enum Flag {
|
||||
Default=0, // goof proof
|
||||
Unscaled=1,
|
||||
HalfSpectrum=2,
|
||||
// SomeOtherSpeedOptimization=4
|
||||
Speedy=32767
|
||||
};
|
||||
using Flag = int;
|
||||
static constexpr Flag Default = 0;
|
||||
static constexpr Flag Unscaled = 1;
|
||||
static constexpr Flag HalfSpectrum = 2;
|
||||
static constexpr Flag Speedy = 32767;
|
||||
|
||||
FFT( const impl_type & impl=impl_type() , Flag flags=Default ) :m_impl(impl),m_flag(flags) { }
|
||||
FFT( const impl_type & impl=impl_type() , Flag flags=Default ) :m_impl(impl),m_flag(flags)
|
||||
{
|
||||
eigen_assert((flags == Default || flags == Unscaled || flags == HalfSpectrum || flags == Speedy) && "invalid flags argument");
|
||||
}
|
||||
|
||||
inline
|
||||
bool HasFlag(Flag f) const { return (m_flag & (int)f) == f;}
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
EIGEN_DISABLE_DEPRECATED_WARNING
|
||||
|
||||
#include <unsupported/Eigen/EulerAngles>
|
||||
|
||||
using namespace Eigen;
|
||||
|
@ -54,7 +54,7 @@ void test_nnls_known_solution(const MatrixType &A, const VectorB &b, const Vecto
|
||||
}
|
||||
|
||||
template <typename MatrixType>
|
||||
void test_nnls_random_problem() {
|
||||
void test_nnls_random_problem(const MatrixType&) {
|
||||
//
|
||||
// SETUP
|
||||
//
|
||||
@ -448,12 +448,9 @@ EIGEN_DECLARE_TEST(NNLS) {
|
||||
|
||||
for (int i = 0; i < g_repeat; i++) {
|
||||
// Essential NNLS properties, across different types.
|
||||
CALL_SUBTEST_2(test_nnls_random_problem<MatrixXf>());
|
||||
CALL_SUBTEST_3(test_nnls_random_problem<MatrixXd>());
|
||||
{
|
||||
using MatFixed = Matrix<double, 12, 5>;
|
||||
CALL_SUBTEST_4(test_nnls_random_problem<MatFixed>());
|
||||
}
|
||||
CALL_SUBTEST_2(test_nnls_random_problem(MatrixXf()));
|
||||
CALL_SUBTEST_3(test_nnls_random_problem(MatrixXd()));
|
||||
CALL_SUBTEST_4(test_nnls_random_problem(Matrix<double, 12, 5>()));
|
||||
CALL_SUBTEST_5(test_nnls_with_half_precision());
|
||||
|
||||
// Robustness tests:
|
||||
|
@ -30,7 +30,7 @@ static void test_type_cast() {
|
||||
|
||||
for (int i = 0; i < 101; ++i) {
|
||||
for (int j = 0; j < 201; ++j) {
|
||||
const ToType ref = static_cast<ToType>(ftensor(i, j));
|
||||
const ToType ref = internal::cast<FromType, ToType>(ftensor(i, j));
|
||||
VERIFY_IS_EQUAL(ttensor(i, j), ref);
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ void test_sum_accuracy() {
|
||||
// Test against probabilistic forward error bound. In reality, the error is much smaller
|
||||
// when we use tree summation.
|
||||
double err = Eigen::numext::abs(static_cast<double>(sum()) - expected_sum);
|
||||
double tol = numext::sqrt(static_cast<double>(num_elements)) * NumTraits<ScalarType>::epsilon() * static_cast<ScalarType>(abs_sum);
|
||||
double tol = numext::sqrt(static_cast<double>(num_elements)) * static_cast<double>(NumTraits<ScalarType>::epsilon()) * abs_sum;
|
||||
VERIFY_LE(err, tol);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user