mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-20 08:39:37 +08:00
Fix PPC rand and other failures.
This commit is contained in:
parent
ebd13c3b14
commit
3ebaab8a63
@ -105,6 +105,7 @@ static const Packet16uc p16uc_DUPLICATE16_EVEN = {0, 1, 0, 1, 4, 5, 4, 5, 8, 9,
|
|||||||
static const Packet16uc p16uc_DUPLICATE16_ODD = {2, 3, 2, 3, 6, 7, 6, 7, 10, 11, 10, 11, 14, 15, 14, 15};
|
static const Packet16uc p16uc_DUPLICATE16_ODD = {2, 3, 2, 3, 6, 7, 6, 7, 10, 11, 10, 11, 14, 15, 14, 15};
|
||||||
|
|
||||||
static Packet16uc p16uc_QUADRUPLICATE16_HI = {0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3};
|
static Packet16uc p16uc_QUADRUPLICATE16_HI = {0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3};
|
||||||
|
static Packet16uc p16uc_QUADRUPLICATE16 = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3};
|
||||||
|
|
||||||
static Packet16uc p16uc_MERGEE16 = {0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29};
|
static Packet16uc p16uc_MERGEE16 = {0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29};
|
||||||
static Packet16uc p16uc_MERGEO16 = {2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31};
|
static Packet16uc p16uc_MERGEO16 = {2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31};
|
||||||
@ -1716,6 +1717,26 @@ EIGEN_STRONG_INLINE Packet16uc ploaddup<Packet16uc>(const unsigned char* from) {
|
|||||||
return vec_mergeh(p, p);
|
return vec_mergeh(p, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
EIGEN_STRONG_INLINE Packet16c ploadquad<Packet16c>(const signed char* from) {
|
||||||
|
Packet16c p;
|
||||||
|
if ((std::ptrdiff_t(from) % 16) == 0)
|
||||||
|
p = pload<Packet16c>(from);
|
||||||
|
else
|
||||||
|
p = ploadu<Packet16c>(from);
|
||||||
|
return vec_perm(p, p, p16uc_QUADRUPLICATE16);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
EIGEN_STRONG_INLINE Packet16uc ploadquad<Packet16uc>(const unsigned char* from) {
|
||||||
|
Packet16uc p;
|
||||||
|
if ((std::ptrdiff_t(from) % 16) == 0)
|
||||||
|
p = pload<Packet16uc>(from);
|
||||||
|
else
|
||||||
|
p = ploadu<Packet16uc>(from);
|
||||||
|
return vec_perm(p, p, p16uc_QUADRUPLICATE16);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Packet>
|
template <typename Packet>
|
||||||
EIGEN_STRONG_INLINE void pstoreu_common(__UNPACK_TYPE__(Packet) * to, const Packet& from) {
|
EIGEN_STRONG_INLINE void pstoreu_common(__UNPACK_TYPE__(Packet) * to, const Packet& from) {
|
||||||
EIGEN_DEBUG_UNALIGNED_STORE
|
EIGEN_DEBUG_UNALIGNED_STORE
|
||||||
|
@ -19,12 +19,18 @@ void array_for_matrix(const MatrixType& m) {
|
|||||||
Index cols = m.cols();
|
Index cols = m.cols();
|
||||||
|
|
||||||
MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3(rows, cols);
|
MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3(rows, cols);
|
||||||
|
|
||||||
ColVectorType cv1 = ColVectorType::Random(rows);
|
ColVectorType cv1 = ColVectorType::Random(rows);
|
||||||
RowVectorType rv1 = RowVectorType::Random(cols);
|
RowVectorType rv1 = RowVectorType::Random(cols);
|
||||||
|
|
||||||
Scalar s1 = internal::random<Scalar>(), s2 = internal::random<Scalar>();
|
Scalar s1 = internal::random<Scalar>(), s2 = internal::random<Scalar>();
|
||||||
|
|
||||||
|
// Prevent overflows for integer types.
|
||||||
|
if (Eigen::NumTraits<Scalar>::IsInteger) {
|
||||||
|
constexpr Scalar kMaxVal = Scalar(10000);
|
||||||
|
m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
|
||||||
|
m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
|
||||||
|
}
|
||||||
|
|
||||||
// scalar addition
|
// scalar addition
|
||||||
VERIFY_IS_APPROX(m1.array() + s1, s1 + m1.array());
|
VERIFY_IS_APPROX(m1.array() + s1, s1 + m1.array());
|
||||||
VERIFY_IS_APPROX((m1.array() + s1).matrix(), MatrixType::Constant(rows, cols, s1) + m1);
|
VERIFY_IS_APPROX((m1.array() + s1).matrix(), MatrixType::Constant(rows, cols, s1) + m1);
|
||||||
|
@ -176,11 +176,6 @@ inline void on_temporary_creation(long int size) {
|
|||||||
#define DEBUG
|
#define DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// bounds integer values for AltiVec
|
|
||||||
#if defined(__ALTIVEC__) || defined(__VSX__)
|
|
||||||
#define EIGEN_MAKING_DOCS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEFAULT_REPEAT 10
|
#define DEFAULT_REPEAT 10
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
@ -53,7 +53,7 @@ void product(const MatrixType& m) {
|
|||||||
MatrixType::Flags & RowMajorBit ? ColMajor : RowMajor>
|
MatrixType::Flags & RowMajorBit ? ColMajor : RowMajor>
|
||||||
OtherMajorMatrixType;
|
OtherMajorMatrixType;
|
||||||
|
|
||||||
// Wwe want a tighter epsilon for not-approx tests. Otherwise, for certain
|
// We want a tighter epsilon for not-approx tests. Otherwise, for certain
|
||||||
// low-precision types (e.g. bfloat16), the bound ends up being relatively large
|
// low-precision types (e.g. bfloat16), the bound ends up being relatively large
|
||||||
// (e.g. 0.12), causing flaky tests.
|
// (e.g. 0.12), causing flaky tests.
|
||||||
RealScalar not_approx_epsilon = RealScalar(0.1) * NumTraits<RealScalar>::dummy_precision();
|
RealScalar not_approx_epsilon = RealScalar(0.1) * NumTraits<RealScalar>::dummy_precision();
|
||||||
@ -69,6 +69,15 @@ void product(const MatrixType& m) {
|
|||||||
ColSquareMatrixType square2 = ColSquareMatrixType::Random(cols, cols), res2 = ColSquareMatrixType::Random(cols, cols);
|
ColSquareMatrixType square2 = ColSquareMatrixType::Random(cols, cols), res2 = ColSquareMatrixType::Random(cols, cols);
|
||||||
RowVectorType v1 = RowVectorType::Random(rows);
|
RowVectorType v1 = RowVectorType::Random(rows);
|
||||||
ColVectorType vc2 = ColVectorType::Random(cols), vcres(cols);
|
ColVectorType vc2 = ColVectorType::Random(cols), vcres(cols);
|
||||||
|
|
||||||
|
// Prevent overflows for integer types.
|
||||||
|
if (Eigen::NumTraits<Scalar>::IsInteger) {
|
||||||
|
constexpr Scalar kMaxVal = Scalar(10000);
|
||||||
|
m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
|
||||||
|
m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
|
||||||
|
v1.array() = v1.array() - kMaxVal * (v1.array() / kMaxVal);
|
||||||
|
}
|
||||||
|
|
||||||
OtherMajorMatrixType tm1 = m1;
|
OtherMajorMatrixType tm1 = m1;
|
||||||
|
|
||||||
Scalar s1 = internal::random<Scalar>();
|
Scalar s1 = internal::random<Scalar>();
|
||||||
|
@ -30,6 +30,12 @@ void matrixRedux(const MatrixType& m) {
|
|||||||
|
|
||||||
Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> m2(rows, rows);
|
Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> m2(rows, rows);
|
||||||
m2.setRandom();
|
m2.setRandom();
|
||||||
|
// Prevent overflows for integer types.
|
||||||
|
if (Eigen::NumTraits<Scalar>::IsInteger) {
|
||||||
|
constexpr Scalar kMaxVal = Scalar(10000);
|
||||||
|
m1.array() = m1.array() - kMaxVal * (m1.array() / kMaxVal);
|
||||||
|
m2.array() = m2.array() - kMaxVal * (m2.array() / kMaxVal);
|
||||||
|
}
|
||||||
|
|
||||||
VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows, cols).sum(), Scalar(1));
|
VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows, cols).sum(), Scalar(1));
|
||||||
VERIFY_IS_APPROX(
|
VERIFY_IS_APPROX(
|
||||||
|
@ -463,6 +463,13 @@ void test_stl_iterators(int rows = Rows, int cols = Cols) {
|
|||||||
// check rows/cols iterators with STL algorithms
|
// check rows/cols iterators with STL algorithms
|
||||||
{
|
{
|
||||||
RowVectorType row = RowVectorType::Random(cols);
|
RowVectorType row = RowVectorType::Random(cols);
|
||||||
|
VectorType col = VectorType::Random(rows);
|
||||||
|
// Prevent overflows for integer types.
|
||||||
|
if (Eigen::NumTraits<Scalar>::IsInteger) {
|
||||||
|
constexpr Scalar kMaxVal = Scalar(1000);
|
||||||
|
row.array() = row.array() - kMaxVal * (row.array() / kMaxVal);
|
||||||
|
col.array() = col.array() - kMaxVal * (col.array() / kMaxVal);
|
||||||
|
}
|
||||||
A.rowwise() = row;
|
A.rowwise() = row;
|
||||||
VERIFY(std::all_of(A.rowwise().begin(), A.rowwise().end(), [&row](typename ColMatrixType::RowXpr x) {
|
VERIFY(std::all_of(A.rowwise().begin(), A.rowwise().end(), [&row](typename ColMatrixType::RowXpr x) {
|
||||||
return internal::isApprox(x.squaredNorm(), row.squaredNorm());
|
return internal::isApprox(x.squaredNorm(), row.squaredNorm());
|
||||||
@ -471,7 +478,6 @@ void test_stl_iterators(int rows = Rows, int cols = Cols) {
|
|||||||
return internal::isApprox(x.squaredNorm(), row.squaredNorm());
|
return internal::isApprox(x.squaredNorm(), row.squaredNorm());
|
||||||
}));
|
}));
|
||||||
|
|
||||||
VectorType col = VectorType::Random(rows);
|
|
||||||
A.colwise() = col;
|
A.colwise() = col;
|
||||||
VERIFY(std::all_of(A.colwise().begin(), A.colwise().end(), [&col](typename ColMatrixType::ColXpr x) {
|
VERIFY(std::all_of(A.colwise().begin(), A.colwise().end(), [&col](typename ColMatrixType::ColXpr x) {
|
||||||
return internal::isApprox(x.squaredNorm(), col.squaredNorm());
|
return internal::isApprox(x.squaredNorm(), col.squaredNorm());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user