summaryrefslogtreecommitdiffhomepage
path: root/eigen/test
diff options
context:
space:
mode:
Diffstat (limited to 'eigen/test')
-rw-r--r--eigen/test/CMakeLists.txt32
-rw-r--r--eigen/test/array.cpp25
-rw-r--r--eigen/test/array_for_matrix.cpp22
-rw-r--r--eigen/test/basicstuff.cpp16
-rw-r--r--eigen/test/block.cpp19
-rw-r--r--eigen/test/cholmod_support.cpp42
-rw-r--r--eigen/test/geo_alignedbox.cpp11
-rw-r--r--eigen/test/geo_parametrizedline.cpp27
-rw-r--r--eigen/test/half_float.cpp29
-rw-r--r--eigen/test/indexed_view.cpp378
-rw-r--r--eigen/test/lscg.cpp8
-rw-r--r--eigen/test/main.h11
-rw-r--r--eigen/test/mixingtypes.cpp2
-rw-r--r--eigen/test/numext.cpp53
-rw-r--r--eigen/test/packetmath.cpp1
-rw-r--r--eigen/test/product_mmtr.cpp11
-rw-r--r--eigen/test/product_notemporary.cpp1
-rw-r--r--eigen/test/sparse_product.cpp4
-rw-r--r--eigen/test/symbolic_index.cpp104
19 files changed, 176 insertions, 620 deletions
diff --git a/eigen/test/CMakeLists.txt b/eigen/test/CMakeLists.txt
index d337594..0747aa6 100644
--- a/eigen/test/CMakeLists.txt
+++ b/eigen/test/CMakeLists.txt
@@ -27,7 +27,7 @@ endif()
if(NOT EIGEN_Fortran_COMPILER_WORKS)
# search for a default Lapack library to complete Eigen's one
- find_package(LAPACK)
+ find_package(LAPACK QUIET)
endif()
# configure blas/lapack (use Eigen's ones)
@@ -80,23 +80,30 @@ else()
endif()
-find_package(Pastix)
-find_package(Scotch)
-find_package(Metis 5.0 REQUIRED)
-if(PASTIX_FOUND)
+find_package(PASTIX QUIET COMPONENTS METIS SCOTCH)
+# check that the PASTIX found is a version without MPI
+find_path(PASTIX_pastix_nompi.h_INCLUDE_DIRS
+ NAMES pastix_nompi.h
+ HINTS ${PASTIX_INCLUDE_DIRS}
+)
+if (NOT PASTIX_pastix_nompi.h_INCLUDE_DIRS)
+ message(STATUS "A version of Pastix has been found but pastix_nompi.h does not exist in the include directory."
+ " Because Eigen tests require a version without MPI, we disable the Pastix backend.")
+endif()
+if(PASTIX_FOUND AND PASTIX_pastix_nompi.h_INCLUDE_DIRS)
add_definitions("-DEIGEN_PASTIX_SUPPORT")
- include_directories(${PASTIX_INCLUDES})
+ include_directories(${PASTIX_INCLUDE_DIRS_DEP})
if(SCOTCH_FOUND)
- include_directories(${SCOTCH_INCLUDES})
+ include_directories(${SCOTCH_INCLUDE_DIRS})
set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${SCOTCH_LIBRARIES})
elseif(METIS_FOUND)
- include_directories(${METIS_INCLUDES})
+ include_directories(${METIS_INCLUDE_DIRS})
set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${METIS_LIBRARIES})
else(SCOTCH_FOUND)
ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
endif(SCOTCH_FOUND)
- set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES} ${ORDERING_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
- set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
+ set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES_DEP} ${ORDERING_LIBRARIES})
+ set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES_DEP})
ei_add_property(EIGEN_TESTED_BACKENDS "PaStiX, ")
else()
ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
@@ -104,7 +111,7 @@ endif()
if(METIS_FOUND)
add_definitions("-DEIGEN_METIS_SUPPORT")
- include_directories(${METIS_INCLUDES})
+ include_directories(${METIS_INCLUDE_DIRS})
ei_add_property(EIGEN_TESTED_BACKENDS "METIS, ")
else()
ei_add_property(EIGEN_MISSING_BACKENDS "METIS, ")
@@ -141,6 +148,7 @@ add_custom_target(BuildOfficial)
ei_add_test(rand)
ei_add_test(meta)
+ei_add_test(numext)
ei_add_test(sizeof)
ei_add_test(dynalloc)
ei_add_test(nomalloc)
@@ -162,8 +170,6 @@ ei_add_test(redux)
ei_add_test(visitor)
ei_add_test(block)
ei_add_test(corners)
-ei_add_test(symbolic_index)
-ei_add_test(indexed_view)
ei_add_test(swap)
ei_add_test(resize)
ei_add_test(conservative_resize)
diff --git a/eigen/test/array.cpp b/eigen/test/array.cpp
index f7f3ba7..15c3266 100644
--- a/eigen/test/array.cpp
+++ b/eigen/test/array.cpp
@@ -18,7 +18,7 @@ template<typename ArrayType> void array(const ArrayType& m)
typedef Array<Scalar, 1, ArrayType::ColsAtCompileTime> RowVectorType;
Index rows = m.rows();
- Index cols = m.cols();
+ Index cols = m.cols();
ArrayType m1 = ArrayType::Random(rows, cols),
m2 = ArrayType::Random(rows, cols),
@@ -44,25 +44,25 @@ template<typename ArrayType> void array(const ArrayType& m)
VERIFY_IS_APPROX(m3, m1 + s2);
m3 = m1;
m3 -= s1;
- VERIFY_IS_APPROX(m3, m1 - s1);
-
+ VERIFY_IS_APPROX(m3, m1 - s1);
+
// scalar operators via Maps
m3 = m1;
ArrayType::Map(m1.data(), m1.rows(), m1.cols()) -= ArrayType::Map(m2.data(), m2.rows(), m2.cols());
VERIFY_IS_APPROX(m1, m3 - m2);
-
+
m3 = m1;
ArrayType::Map(m1.data(), m1.rows(), m1.cols()) += ArrayType::Map(m2.data(), m2.rows(), m2.cols());
VERIFY_IS_APPROX(m1, m3 + m2);
-
+
m3 = m1;
ArrayType::Map(m1.data(), m1.rows(), m1.cols()) *= ArrayType::Map(m2.data(), m2.rows(), m2.cols());
VERIFY_IS_APPROX(m1, m3 * m2);
-
+
m3 = m1;
m2 = ArrayType::Random(rows,cols);
m2 = (m2==0).select(1,m2);
- ArrayType::Map(m1.data(), m1.rows(), m1.cols()) /= ArrayType::Map(m2.data(), m2.rows(), m2.cols());
+ ArrayType::Map(m1.data(), m1.rows(), m1.cols()) /= ArrayType::Map(m2.data(), m2.rows(), m2.cols());
VERIFY_IS_APPROX(m1, m3 / m2);
// reductions
@@ -84,7 +84,7 @@ template<typename ArrayType> void array(const ArrayType& m)
VERIFY_IS_APPROX(m3.rowwise() += rv1, m1.rowwise() + rv1);
m3 = m1;
VERIFY_IS_APPROX(m3.rowwise() -= rv1, m1.rowwise() - rv1);
-
+
// Conversion from scalar
VERIFY_IS_APPROX((m3 = s1), ArrayType::Constant(rows,cols,s1));
VERIFY_IS_APPROX((m3 = 1), ArrayType::Constant(rows,cols,1));
@@ -102,7 +102,7 @@ template<typename ArrayType> void array(const ArrayType& m)
f1.setRandom();
FixedArrayType f4(f1.data());
VERIFY_IS_APPROX(f4, f1);
-
+
// pow
VERIFY_IS_APPROX(m1.pow(2), m1.square());
VERIFY_IS_APPROX(pow(m1,2), m1.square());
@@ -144,7 +144,7 @@ template<typename ArrayType> void comparisons(const ArrayType& m)
m2 = ArrayType::Random(rows, cols),
m3(rows, cols),
m4 = m1;
-
+
m4 = (m4.abs()==Scalar(0)).select(1,m4);
VERIFY(((m1 + Scalar(1)) > m1).all());
@@ -295,9 +295,6 @@ template<typename ArrayType> void array_real(const ArrayType& m)
VERIFY_IS_APPROX(m1.exp(), exp(m1));
VERIFY_IS_APPROX(m1.exp() / m2.exp(),(m1-m2).exp());
- VERIFY_IS_APPROX(m1.expm1(), expm1(m1));
- VERIFY_IS_APPROX((m3 + smallNumber).exp() - 1, expm1(abs(m3) + smallNumber));
-
VERIFY_IS_APPROX(m3.pow(RealScalar(0.5)), m3.sqrt());
VERIFY_IS_APPROX(pow(m3,RealScalar(0.5)), m3.sqrt());
@@ -332,7 +329,7 @@ template<typename ArrayType> void array_complex(const ArrayType& m)
ArrayType m1 = ArrayType::Random(rows, cols),
m2(rows, cols),
m4 = m1;
-
+
m4.real() = (m4.real().abs()==RealScalar(0)).select(RealScalar(1),m4.real());
m4.imag() = (m4.imag().abs()==RealScalar(0)).select(RealScalar(1),m4.imag());
diff --git a/eigen/test/array_for_matrix.cpp b/eigen/test/array_for_matrix.cpp
index c150194..b872139 100644
--- a/eigen/test/array_for_matrix.cpp
+++ b/eigen/test/array_for_matrix.cpp
@@ -235,12 +235,31 @@ template<typename MatrixTraits> void resize(const MatrixTraits& t)
VERIFY(a1.size()==cols);
}
+template<int>
void regression_bug_654()
{
ArrayXf a = RowVectorXf(3);
VectorXf v = Array<float,1,Dynamic>(3);
}
+// Check propagation of LvalueBit through Array/Matrix-Wrapper
+template<int>
+void regrrssion_bug_1410()
+{
+ const Matrix4i M;
+ const Array4i A;
+ ArrayWrapper<const Matrix4i> MA = M.array();
+ MA.row(0);
+ MatrixWrapper<const Array4i> AM = A.matrix();
+ AM.row(0);
+
+ VERIFY((internal::traits<ArrayWrapper<const Matrix4i> >::Flags&LvalueBit)==0);
+ VERIFY((internal::traits<MatrixWrapper<const Array4i> >::Flags&LvalueBit)==0);
+
+ VERIFY((internal::traits<ArrayWrapper<Matrix4i> >::Flags&LvalueBit)==LvalueBit);
+ VERIFY((internal::traits<MatrixWrapper<Array4i> >::Flags&LvalueBit)==LvalueBit);
+}
+
void test_array_for_matrix()
{
for(int i = 0; i < g_repeat; i++) {
@@ -280,5 +299,6 @@ void test_array_for_matrix()
CALL_SUBTEST_5( resize(MatrixXf(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
CALL_SUBTEST_6( resize(MatrixXi(internal::random<int>(1,EIGEN_TEST_MAX_SIZE), internal::random<int>(1,EIGEN_TEST_MAX_SIZE))) );
}
- CALL_SUBTEST_6( regression_bug_654() );
+ CALL_SUBTEST_6( regression_bug_654<0>() );
+ CALL_SUBTEST_6( regrrssion_bug_1410<0>() );
}
diff --git a/eigen/test/basicstuff.cpp b/eigen/test/basicstuff.cpp
index c346ce6..99d91f9 100644
--- a/eigen/test/basicstuff.cpp
+++ b/eigen/test/basicstuff.cpp
@@ -49,22 +49,6 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
v1[r] = x;
VERIFY_IS_APPROX(x, v1[r]);
- // test fetching with various index types.
- Index r1 = internal::random<Index>(0, numext::mini(Index(127),rows-1));
- x = v1(static_cast<char>(r1));
- x = v1(static_cast<signed char>(r1));
- x = v1(static_cast<unsigned char>(r1));
- x = v1(static_cast<signed short>(r1));
- x = v1(static_cast<unsigned short>(r1));
- x = v1(static_cast<signed int>(r1));
- x = v1(static_cast<unsigned int>(r1));
- x = v1(static_cast<signed long>(r1));
- x = v1(static_cast<unsigned long>(r1));
-#if EIGEN_HAS_CXX11
- x = v1(static_cast<long long int>(r1));
- x = v1(static_cast<unsigned long long int>(r1));
-#endif
-
VERIFY_IS_APPROX( v1, v1);
VERIFY_IS_NOT_APPROX( v1, 2*v1);
VERIFY_IS_MUCH_SMALLER_THAN( vzero, v1);
diff --git a/eigen/test/block.cpp b/eigen/test/block.cpp
index d610598..39565af 100644
--- a/eigen/test/block.cpp
+++ b/eigen/test/block.cpp
@@ -29,13 +29,6 @@ block_real_only(const MatrixType &, Index, Index, Index, Index, const Scalar&) {
return Scalar(0);
}
-// Check at compile-time that T1==T2, and at runtime-time that a==b
-template<typename T1,typename T2>
-typename internal::enable_if<internal::is_same<T1,T2>::value,bool>::type
-is_same_block(const T1& a, const T2& b)
-{
- return a.isApprox(b);
-}
template<typename MatrixType> void block(const MatrixType& m)
{
@@ -94,9 +87,10 @@ template<typename MatrixType> void block(const MatrixType& m)
m1.block(r1,c1,r2-r1+1,c2-c1+1) = s1 * m2.block(0, 0, r2-r1+1,c2-c1+1);
m1.block(r1,c1,r2-r1+1,c2-c1+1)(r2-r1,c2-c1) = m2.block(0, 0, r2-r1+1,c2-c1+1)(0,0);
- const Index BlockRows = 2;
- const Index BlockCols = 5;
-
+ enum {
+ BlockRows = 2,
+ BlockCols = 5
+ };
if (rows>=5 && cols>=8)
{
// test fixed block() as lvalue
@@ -112,11 +106,6 @@ template<typename MatrixType> void block(const MatrixType& m)
m1.template block<BlockRows,Dynamic>(1,1,BlockRows,BlockCols)(0,3) = m1.template block<2,5>(1,1)(1,2);
Matrix<Scalar,Dynamic,Dynamic> b2 = m1.template block<Dynamic,BlockCols>(3,3,2,5);
VERIFY_IS_EQUAL(b2, m1.block(3,3,BlockRows,BlockCols));
-
- VERIFY(is_same_block(m1.block(3,3,BlockRows,BlockCols), m1.block(3,3,fix<Dynamic>(BlockRows),fix<Dynamic>(BlockCols))));
- VERIFY(is_same_block(m1.template block<BlockRows,Dynamic>(1,1,BlockRows,BlockCols), m1.block(1,1,fix<BlockRows>,BlockCols)));
- VERIFY(is_same_block(m1.template block<BlockRows,BlockCols>(1,1,BlockRows,BlockCols), m1.block(1,1,fix<BlockRows>(),fix<BlockCols>)));
- VERIFY(is_same_block(m1.template block<BlockRows,BlockCols>(1,1,BlockRows,BlockCols), m1.block(1,1,fix<BlockRows>,fix<BlockCols>(BlockCols))));
}
if (rows>2)
diff --git a/eigen/test/cholmod_support.cpp b/eigen/test/cholmod_support.cpp
index 9312073..a7eda28 100644
--- a/eigen/test/cholmod_support.cpp
+++ b/eigen/test/cholmod_support.cpp
@@ -12,21 +12,21 @@
#include <Eigen/CholmodSupport>
-template<typename SparseType> void test_cholmod_ST()
+template<typename T> void test_cholmod_T()
{
- CholmodDecomposition<SparseType, Lower> g_chol_colmajor_lower; g_chol_colmajor_lower.setMode(CholmodSupernodalLLt);
- CholmodDecomposition<SparseType, Upper> g_chol_colmajor_upper; g_chol_colmajor_upper.setMode(CholmodSupernodalLLt);
- CholmodDecomposition<SparseType, Lower> g_llt_colmajor_lower; g_llt_colmajor_lower.setMode(CholmodSimplicialLLt);
- CholmodDecomposition<SparseType, Upper> g_llt_colmajor_upper; g_llt_colmajor_upper.setMode(CholmodSimplicialLLt);
- CholmodDecomposition<SparseType, Lower> g_ldlt_colmajor_lower; g_ldlt_colmajor_lower.setMode(CholmodLDLt);
- CholmodDecomposition<SparseType, Upper> g_ldlt_colmajor_upper; g_ldlt_colmajor_upper.setMode(CholmodLDLt);
+ CholmodDecomposition<SparseMatrix<T>, Lower> g_chol_colmajor_lower; g_chol_colmajor_lower.setMode(CholmodSupernodalLLt);
+ CholmodDecomposition<SparseMatrix<T>, Upper> g_chol_colmajor_upper; g_chol_colmajor_upper.setMode(CholmodSupernodalLLt);
+ CholmodDecomposition<SparseMatrix<T>, Lower> g_llt_colmajor_lower; g_llt_colmajor_lower.setMode(CholmodSimplicialLLt);
+ CholmodDecomposition<SparseMatrix<T>, Upper> g_llt_colmajor_upper; g_llt_colmajor_upper.setMode(CholmodSimplicialLLt);
+ CholmodDecomposition<SparseMatrix<T>, Lower> g_ldlt_colmajor_lower; g_ldlt_colmajor_lower.setMode(CholmodLDLt);
+ CholmodDecomposition<SparseMatrix<T>, Upper> g_ldlt_colmajor_upper; g_ldlt_colmajor_upper.setMode(CholmodLDLt);
- CholmodSupernodalLLT<SparseType, Lower> chol_colmajor_lower;
- CholmodSupernodalLLT<SparseType, Upper> chol_colmajor_upper;
- CholmodSimplicialLLT<SparseType, Lower> llt_colmajor_lower;
- CholmodSimplicialLLT<SparseType, Upper> llt_colmajor_upper;
- CholmodSimplicialLDLT<SparseType, Lower> ldlt_colmajor_lower;
- CholmodSimplicialLDLT<SparseType, Upper> ldlt_colmajor_upper;
+ CholmodSupernodalLLT<SparseMatrix<T>, Lower> chol_colmajor_lower;
+ CholmodSupernodalLLT<SparseMatrix<T>, Upper> chol_colmajor_upper;
+ CholmodSimplicialLLT<SparseMatrix<T>, Lower> llt_colmajor_lower;
+ CholmodSimplicialLLT<SparseMatrix<T>, Upper> llt_colmajor_upper;
+ CholmodSimplicialLDLT<SparseMatrix<T>, Lower> ldlt_colmajor_lower;
+ CholmodSimplicialLDLT<SparseMatrix<T>, Upper> ldlt_colmajor_upper;
check_sparse_spd_solving(g_chol_colmajor_lower);
check_sparse_spd_solving(g_chol_colmajor_upper);
@@ -50,20 +50,8 @@ template<typename SparseType> void test_cholmod_ST()
check_sparse_spd_determinant(ldlt_colmajor_upper);
}
-template<typename T, int flags, typename IdxType> void test_cholmod_T()
-{
- test_cholmod_ST<SparseMatrix<T, flags, IdxType> >();
-}
-
void test_cholmod_support()
{
- CALL_SUBTEST_11( (test_cholmod_T<double , ColMajor, int >()) );
- CALL_SUBTEST_12( (test_cholmod_T<double , ColMajor, long>()) );
- CALL_SUBTEST_13( (test_cholmod_T<double , RowMajor, int >()) );
- CALL_SUBTEST_14( (test_cholmod_T<double , RowMajor, long>()) );
- CALL_SUBTEST_21( (test_cholmod_T<std::complex<double>, ColMajor, int >()) );
- CALL_SUBTEST_22( (test_cholmod_T<std::complex<double>, ColMajor, long>()) );
- // TODO complex row-major matrices do not work at the moment:
- // CALL_SUBTEST_23( (test_cholmod_T<std::complex<double>, RowMajor, int >()) );
- // CALL_SUBTEST_24( (test_cholmod_T<std::complex<double>, RowMajor, long>()) );
+ CALL_SUBTEST_1(test_cholmod_T<double>());
+ CALL_SUBTEST_2(test_cholmod_T<std::complex<double> >());
}
diff --git a/eigen/test/geo_alignedbox.cpp b/eigen/test/geo_alignedbox.cpp
index 223ff5e..d2339a6 100644
--- a/eigen/test/geo_alignedbox.cpp
+++ b/eigen/test/geo_alignedbox.cpp
@@ -15,17 +15,8 @@
#include<iostream>
using namespace std;
-// NOTE the following workaround was needed on some 32 bits builds to kill extra precision of x87 registers.
-// It seems that it os not needed anymore, but let's keep it here, just in case...
-
template<typename T> EIGEN_DONT_INLINE
-void kill_extra_precision(T& /* x */) {
- // This one worked but triggered a warning:
- /* eigen_assert((void*)(&x) != (void*)0); */
- // An alternative could be:
- /* volatile T tmp = x; */
- /* x = tmp; */
-}
+void kill_extra_precision(T& x) { eigen_assert((void*)(&x) != (void*)0); }
template<typename BoxType> void alignedbox(const BoxType& _box)
diff --git a/eigen/test/geo_parametrizedline.cpp b/eigen/test/geo_parametrizedline.cpp
index 29c1b10..9bf5f3c 100644
--- a/eigen/test/geo_parametrizedline.cpp
+++ b/eigen/test/geo_parametrizedline.cpp
@@ -25,8 +25,6 @@ template<typename LineType> void parametrizedline(const LineType& _line)
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime, 1> VectorType;
typedef Hyperplane<Scalar,LineType::AmbientDimAtCompileTime> HyperplaneType;
- typedef Matrix<Scalar, HyperplaneType::AmbientDimAtCompileTime,
- HyperplaneType::AmbientDimAtCompileTime> MatrixType;
VectorType p0 = VectorType::Random(dim);
VectorType p1 = VectorType::Random(dim);
@@ -61,31 +59,6 @@ template<typename LineType> void parametrizedline(const LineType& _line)
VERIFY_IS_MUCH_SMALLER_THAN(hp.signedDistance(pi), RealScalar(1));
VERIFY_IS_MUCH_SMALLER_THAN(l0.distance(pi), RealScalar(1));
VERIFY_IS_APPROX(l0.intersectionPoint(hp), pi);
-
- // transform
- if (!NumTraits<Scalar>::IsComplex)
- {
- MatrixType rot = MatrixType::Random(dim,dim).householderQr().householderQ();
- DiagonalMatrix<Scalar,LineType::AmbientDimAtCompileTime> scaling(VectorType::Random());
- Translation<Scalar,LineType::AmbientDimAtCompileTime> translation(VectorType::Random());
-
- while(scaling.diagonal().cwiseAbs().minCoeff()<RealScalar(1e-4)) scaling.diagonal() = VectorType::Random();
-
- LineType l1 = l0;
- VectorType p3 = l0.pointAt(Scalar(1));
- VERIFY_IS_MUCH_SMALLER_THAN( l1.transform(rot).distance(rot * p3), Scalar(1) );
- l1 = l0;
- VERIFY_IS_MUCH_SMALLER_THAN( l1.transform(rot,Isometry).distance(rot * p3), Scalar(1) );
- l1 = l0;
- VERIFY_IS_MUCH_SMALLER_THAN( l1.transform(rot*scaling).distance((rot*scaling) * p3), Scalar(1) );
- l1 = l0;
- VERIFY_IS_MUCH_SMALLER_THAN( l1.transform(rot*scaling*translation)
- .distance((rot*scaling*translation) * p3), Scalar(1) );
- l1 = l0;
- VERIFY_IS_MUCH_SMALLER_THAN( l1.transform(rot*translation,Isometry)
- .distance((rot*translation) * p3), Scalar(1) );
- }
-
}
template<typename Scalar> void parametrizedline_alignment()
diff --git a/eigen/test/half_float.cpp b/eigen/test/half_float.cpp
index 6f31968..3d2410a 100644
--- a/eigen/test/half_float.cpp
+++ b/eigen/test/half_float.cpp
@@ -96,12 +96,24 @@ void test_conversion()
void test_numtraits()
{
- std::cout << "epsilon = " << NumTraits<half>::epsilon() << std::endl;
- std::cout << "highest = " << NumTraits<half>::highest() << std::endl;
- std::cout << "lowest = " << NumTraits<half>::lowest() << std::endl;
- std::cout << "inifinty = " << NumTraits<half>::infinity() << std::endl;
- std::cout << "nan = " << NumTraits<half>::quiet_NaN() << std::endl;
-
+ std::cout << "epsilon = " << NumTraits<half>::epsilon() << " (0x" << std::hex << NumTraits<half>::epsilon().x << ")" << std::endl;
+ std::cout << "highest = " << NumTraits<half>::highest() << " (0x" << std::hex << NumTraits<half>::highest().x << ")" << std::endl;
+ std::cout << "lowest = " << NumTraits<half>::lowest() << " (0x" << std::hex << NumTraits<half>::lowest().x << ")" << std::endl;
+ std::cout << "min = " << (std::numeric_limits<half>::min)() << " (0x" << std::hex << half((std::numeric_limits<half>::min)()).x << ")" << std::endl;
+ std::cout << "denorm min = " << (std::numeric_limits<half>::denorm_min)() << " (0x" << std::hex << half((std::numeric_limits<half>::denorm_min)()).x << ")" << std::endl;
+ std::cout << "infinity = " << NumTraits<half>::infinity() << " (0x" << std::hex << NumTraits<half>::infinity().x << ")" << std::endl;
+ std::cout << "quiet nan = " << NumTraits<half>::quiet_NaN() << " (0x" << std::hex << NumTraits<half>::quiet_NaN().x << ")" << std::endl;
+ std::cout << "signaling nan = " << std::numeric_limits<half>::signaling_NaN() << " (0x" << std::hex << std::numeric_limits<half>::signaling_NaN().x << ")" << std::endl;
+
+ VERIFY(NumTraits<half>::IsSigned);
+
+ VERIFY_IS_EQUAL( std::numeric_limits<half>::infinity().x, half(std::numeric_limits<float>::infinity()).x );
+ VERIFY_IS_EQUAL( std::numeric_limits<half>::quiet_NaN().x, half(std::numeric_limits<float>::quiet_NaN()).x );
+ VERIFY_IS_EQUAL( std::numeric_limits<half>::signaling_NaN().x, half(std::numeric_limits<float>::signaling_NaN()).x );
+ VERIFY( (std::numeric_limits<half>::min)() > half(0.f) );
+ VERIFY( (std::numeric_limits<half>::denorm_min)() > half(0.f) );
+ VERIFY( (std::numeric_limits<half>::min)()/half(2) > half(0.f) );
+ VERIFY_IS_EQUAL( (std::numeric_limits<half>::denorm_min)()/half(2), half(0.f) );
}
void test_arithmetic()
@@ -185,11 +197,6 @@ void test_basic_functions()
VERIFY_IS_APPROX(float(numext::exp(half(EIGEN_PI))), 20.f + float(EIGEN_PI));
VERIFY_IS_APPROX(float(exp(half(EIGEN_PI))), 20.f + float(EIGEN_PI));
- VERIFY_IS_EQUAL(float(numext::expm1(half(0.0f))), 0.0f);
- VERIFY_IS_EQUAL(float(expm1(half(0.0f))), 0.0f);
- VERIFY_IS_APPROX(float(numext::expm1(half(2.0f))), 6.3890561f);
- VERIFY_IS_APPROX(float(expm1(half(2.0f))), 6.3890561f);
-
VERIFY_IS_EQUAL(float(numext::log(half(1.0f))), 0.0f);
VERIFY_IS_EQUAL(float(log(half(1.0f))), 0.0f);
VERIFY_IS_APPROX(float(numext::log(half(10.0f))), 2.30273f);
diff --git a/eigen/test/indexed_view.cpp b/eigen/test/indexed_view.cpp
deleted file mode 100644
index 7245cf3..0000000
--- a/eigen/test/indexed_view.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
-//
-// This Source Code Form is subject to the terms of the Mozilla
-// Public License v. 2.0. If a copy of the MPL was not distributed
-// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifdef EIGEN_TEST_PART_2
-// Make sure we also check c++11 max implementation
-#define EIGEN_MAX_CPP_VER 11
-#endif
-
-#ifdef EIGEN_TEST_PART_3
-// Make sure we also check c++98 max implementation
-#define EIGEN_MAX_CPP_VER 03
-#endif
-
-#include <valarray>
-#include <vector>
-#include "main.h"
-
-#if EIGEN_HAS_CXX11
-#include <array>
-#endif
-
-typedef std::pair<Index,Index> IndexPair;
-
-int encode(Index i, Index j) {
- return int(i*100 + j);
-}
-
-IndexPair decode(Index ij) {
- return IndexPair(ij / 100, ij % 100);
-}
-
-template<typename T>
-bool match(const T& xpr, std::string ref, std::string str_xpr = "") {
- EIGEN_UNUSED_VARIABLE(str_xpr);
- std::stringstream str;
- str << xpr;
- if(!(str.str() == ref))
- std::cout << str_xpr << "\n" << xpr << "\n\n";
- return str.str() == ref;
-}
-
-#define MATCH(X,R) match(X, R, #X)
-
-template<typename T1,typename T2>
-typename internal::enable_if<internal::is_same<T1,T2>::value,bool>::type
-is_same_eq(const T1& a, const T2& b)
-{
- return (a == b).all();
-}
-
-template<typename T1,typename T2>
-bool is_same_seq(const T1& a, const T2& b)
-{
- bool ok = a.first()==b.first() && a.size() == b.size() && Index(a.incrObject())==Index(b.incrObject());;
- if(!ok)
- {
- std::cerr << "seqN(" << a.first() << ", " << a.size() << ", " << Index(a.incrObject()) << ") != ";
- std::cerr << "seqN(" << b.first() << ", " << b.size() << ", " << Index(b.incrObject()) << ")\n";
- }
- return ok;
-}
-
-template<typename T1,typename T2>
-typename internal::enable_if<internal::is_same<T1,T2>::value,bool>::type
-is_same_seq_type(const T1& a, const T2& b)
-{
- return is_same_seq(a,b);
-}
-
-
-
-#define VERIFY_EQ_INT(A,B) VERIFY_IS_APPROX(int(A),int(B))
-
-void check_indexed_view()
-{
- using Eigen::placeholders::all;
- using Eigen::placeholders::last;
- using Eigen::placeholders::end;
-
- Index n = 10;
-
- ArrayXd a = ArrayXd::LinSpaced(n,0,n-1);
- Array<double,1,Dynamic> b = a.transpose();
-
- ArrayXXi A = ArrayXXi::NullaryExpr(n,n, std::ptr_fun(encode));
-
- for(Index i=0; i<n; ++i)
- for(Index j=0; j<n; ++j)
- VERIFY( decode(A(i,j)) == IndexPair(i,j) );
-
- Array4i eii(4); eii << 3, 1, 6, 5;
- std::valarray<int> vali(4); Map<ArrayXi>(&vali[0],4) = eii;
- std::vector<int> veci(4); Map<ArrayXi>(veci.data(),4) = eii;
-
- VERIFY( MATCH( A(3, seq(9,3,-1)),
- "309 308 307 306 305 304 303")
- );
-
- VERIFY( MATCH( A(seqN(2,5), seq(9,3,-1)),
- "209 208 207 206 205 204 203\n"
- "309 308 307 306 305 304 303\n"
- "409 408 407 406 405 404 403\n"
- "509 508 507 506 505 504 503\n"
- "609 608 607 606 605 604 603")
- );
-
- VERIFY( MATCH( A(seqN(2,5), 5),
- "205\n"
- "305\n"
- "405\n"
- "505\n"
- "605")
- );
-
- VERIFY( MATCH( A(seqN(last,5,-1), seq(2,last)),
- "902 903 904 905 906 907 908 909\n"
- "802 803 804 805 806 807 808 809\n"
- "702 703 704 705 706 707 708 709\n"
- "602 603 604 605 606 607 608 609\n"
- "502 503 504 505 506 507 508 509")
- );
-
- VERIFY( MATCH( A(eii, veci),
- "303 301 306 305\n"
- "103 101 106 105\n"
- "603 601 606 605\n"
- "503 501 506 505")
- );
-
- VERIFY( MATCH( A(eii, all),
- "300 301 302 303 304 305 306 307 308 309\n"
- "100 101 102 103 104 105 106 107 108 109\n"
- "600 601 602 603 604 605 606 607 608 609\n"
- "500 501 502 503 504 505 506 507 508 509")
- );
-
- // takes the row numer 3, and repeat it 5 times
- VERIFY( MATCH( A(seqN(3,5,0), all),
- "300 301 302 303 304 305 306 307 308 309\n"
- "300 301 302 303 304 305 306 307 308 309\n"
- "300 301 302 303 304 305 306 307 308 309\n"
- "300 301 302 303 304 305 306 307 308 309\n"
- "300 301 302 303 304 305 306 307 308 309")
- );
-
- VERIFY( MATCH( a(seqN(3,3),0), "3\n4\n5" ) );
- VERIFY( MATCH( a(seq(3,5)), "3\n4\n5" ) );
- VERIFY( MATCH( a(seqN(3,3,1)), "3\n4\n5" ) );
- VERIFY( MATCH( a(seqN(5,3,-1)), "5\n4\n3" ) );
-
- VERIFY( MATCH( b(0,seqN(3,3)), "3 4 5" ) );
- VERIFY( MATCH( b(seq(3,5)), "3 4 5" ) );
- VERIFY( MATCH( b(seqN(3,3,1)), "3 4 5" ) );
- VERIFY( MATCH( b(seqN(5,3,-1)), "5 4 3" ) );
-
- VERIFY( MATCH( b(all), "0 1 2 3 4 5 6 7 8 9" ) );
- VERIFY( MATCH( b(eii), "3 1 6 5" ) );
-
- Array44i B;
- B.setRandom();
- VERIFY( (A(seqN(2,5), 5)).ColsAtCompileTime == 1);
- VERIFY( (A(seqN(2,5), 5)).RowsAtCompileTime == Dynamic);
- VERIFY_EQ_INT( (A(seqN(2,5), 5)).InnerStrideAtCompileTime , A.InnerStrideAtCompileTime);
- VERIFY_EQ_INT( (A(seqN(2,5), 5)).OuterStrideAtCompileTime , A.col(5).OuterStrideAtCompileTime);
-
- VERIFY_EQ_INT( (A(5,seqN(2,5))).InnerStrideAtCompileTime , A.row(5).InnerStrideAtCompileTime);
- VERIFY_EQ_INT( (A(5,seqN(2,5))).OuterStrideAtCompileTime , A.row(5).OuterStrideAtCompileTime);
- VERIFY_EQ_INT( (B(1,seqN(1,2))).InnerStrideAtCompileTime , B.row(1).InnerStrideAtCompileTime);
- VERIFY_EQ_INT( (B(1,seqN(1,2))).OuterStrideAtCompileTime , B.row(1).OuterStrideAtCompileTime);
-
- VERIFY_EQ_INT( (A(seqN(2,5), seq(1,3))).InnerStrideAtCompileTime , A.InnerStrideAtCompileTime);
- VERIFY_EQ_INT( (A(seqN(2,5), seq(1,3))).OuterStrideAtCompileTime , A.OuterStrideAtCompileTime);
- VERIFY_EQ_INT( (B(seqN(1,2), seq(1,3))).InnerStrideAtCompileTime , B.InnerStrideAtCompileTime);
- VERIFY_EQ_INT( (B(seqN(1,2), seq(1,3))).OuterStrideAtCompileTime , B.OuterStrideAtCompileTime);
- VERIFY_EQ_INT( (A(seqN(2,5,2), seq(1,3,2))).InnerStrideAtCompileTime , Dynamic);
- VERIFY_EQ_INT( (A(seqN(2,5,2), seq(1,3,2))).OuterStrideAtCompileTime , Dynamic);
- VERIFY_EQ_INT( (A(seqN(2,5,fix<2>), seq(1,3,fix<3>))).InnerStrideAtCompileTime , 2);
- VERIFY_EQ_INT( (A(seqN(2,5,fix<2>), seq(1,3,fix<3>))).OuterStrideAtCompileTime , Dynamic);
- VERIFY_EQ_INT( (B(seqN(1,2,fix<2>), seq(1,3,fix<3>))).InnerStrideAtCompileTime , 2);
- VERIFY_EQ_INT( (B(seqN(1,2,fix<2>), seq(1,3,fix<3>))).OuterStrideAtCompileTime , 3*4);
-
- VERIFY_EQ_INT( (A(seqN(2,fix<5>), seqN(1,fix<3>))).RowsAtCompileTime, 5);
- VERIFY_EQ_INT( (A(seqN(2,fix<5>), seqN(1,fix<3>))).ColsAtCompileTime, 3);
- VERIFY_EQ_INT( (A(seqN(2,fix<5>(5)), seqN(1,fix<3>(3)))).RowsAtCompileTime, 5);
- VERIFY_EQ_INT( (A(seqN(2,fix<5>(5)), seqN(1,fix<3>(3)))).ColsAtCompileTime, 3);
- VERIFY_EQ_INT( (A(seqN(2,fix<Dynamic>(5)), seqN(1,fix<Dynamic>(3)))).RowsAtCompileTime, Dynamic);
- VERIFY_EQ_INT( (A(seqN(2,fix<Dynamic>(5)), seqN(1,fix<Dynamic>(3)))).ColsAtCompileTime, Dynamic);
- VERIFY_EQ_INT( (A(seqN(2,fix<Dynamic>(5)), seqN(1,fix<Dynamic>(3)))).rows(), 5);
- VERIFY_EQ_INT( (A(seqN(2,fix<Dynamic>(5)), seqN(1,fix<Dynamic>(3)))).cols(), 3);
-
- VERIFY( is_same_seq_type( seqN(2,5,fix<-1>), seqN(2,5,fix<-1>(-1)) ) );
- VERIFY( is_same_seq_type( seqN(2,5), seqN(2,5,fix<1>(1)) ) );
- VERIFY( is_same_seq_type( seqN(2,5,3), seqN(2,5,fix<DynamicIndex>(3)) ) );
- VERIFY( is_same_seq_type( seq(2,7,fix<3>), seqN(2,2,fix<3>) ) );
- VERIFY( is_same_seq_type( seqN(2,fix<Dynamic>(5),3), seqN(2,5,fix<DynamicIndex>(3)) ) );
- VERIFY( is_same_seq_type( seqN(2,fix<5>(5),fix<-2>), seqN(2,fix<5>,fix<-2>()) ) );
-
- VERIFY( is_same_seq_type( seq(2,fix<5>), seqN(2,4) ) );
-#if EIGEN_HAS_CXX11
- VERIFY( is_same_seq_type( seq(fix<2>,fix<5>), seqN(fix<2>,fix<4>) ) );
- VERIFY( is_same_seq( seqN(2,std::integral_constant<int,5>(),std::integral_constant<int,-2>()), seqN(2,fix<5>,fix<-2>()) ) );
- VERIFY( is_same_seq( seq(std::integral_constant<int,1>(),std::integral_constant<int,5>(),std::integral_constant<int,2>()),
- seq(fix<1>,fix<5>,fix<2>()) ) );
- VERIFY( is_same_seq_type( seqN(2,std::integral_constant<int,5>(),std::integral_constant<int,-2>()), seqN(2,fix<5>,fix<-2>()) ) );
- VERIFY( is_same_seq_type( seq(std::integral_constant<int,1>(),std::integral_constant<int,5>(),std::integral_constant<int,2>()),
- seq(fix<1>,fix<5>,fix<2>()) ) );
-
- VERIFY( is_same_seq_type( seqN(2,std::integral_constant<int,5>()), seqN(2,fix<5>) ) );
- VERIFY( is_same_seq_type( seq(std::integral_constant<int,1>(),std::integral_constant<int,5>()), seq(fix<1>,fix<5>) ) );
-#else
- // sorry, no compile-time size recovery in c++98/03
- VERIFY( is_same_seq( seq(fix<2>,fix<5>), seqN(fix<2>,fix<4>) ) );
-#endif
-
- VERIFY( (A(seqN(2,fix<5>), 5)).RowsAtCompileTime == 5);
- VERIFY( (A(4, all)).ColsAtCompileTime == Dynamic);
- VERIFY( (A(4, all)).RowsAtCompileTime == 1);
- VERIFY( (B(1, all)).ColsAtCompileTime == 4);
- VERIFY( (B(1, all)).RowsAtCompileTime == 1);
- VERIFY( (B(all,1)).ColsAtCompileTime == 1);
- VERIFY( (B(all,1)).RowsAtCompileTime == 4);
-
- VERIFY(int( (A(all, eii)).ColsAtCompileTime) == int(eii.SizeAtCompileTime));
- VERIFY_EQ_INT( (A(eii, eii)).Flags&DirectAccessBit, (unsigned int)(0));
- VERIFY_EQ_INT( (A(eii, eii)).InnerStrideAtCompileTime, 0);
- VERIFY_EQ_INT( (A(eii, eii)).OuterStrideAtCompileTime, 0);
-
- VERIFY_IS_APPROX( A(seq(n-1,2,-2), seqN(n-1-6,3,-1)), A(seq(last,2,fix<-2>), seqN(last-6,3,fix<-1>)) );
-
- VERIFY_IS_APPROX( A(seq(n-1,2,-2), seqN(n-1-6,4)), A(seq(last,2,-2), seqN(last-6,4)) );
- VERIFY_IS_APPROX( A(seq(n-1-6,n-1-2), seqN(n-1-6,4)), A(seq(last-6,last-2), seqN(6+last-6-6,4)) );
- VERIFY_IS_APPROX( A(seq((n-1)/2,(n)/2+3), seqN(2,4)), A(seq(last/2,(last+1)/2+3), seqN(last+2-last,4)) );
- VERIFY_IS_APPROX( A(seq(n-2,2,-2), seqN(n-8,4)), A(seq(end-2,2,-2), seqN(end-8,4)) );
-
- // Check all combinations of seq:
- VERIFY_IS_APPROX( A(seq(1,n-1-2,2), seq(1,n-1-2,2)), A(seq(1,last-2,2), seq(1,last-2,fix<2>)) );
- VERIFY_IS_APPROX( A(seq(n-1-5,n-1-2,2), seq(n-1-5,n-1-2,2)), A(seq(last-5,last-2,2), seq(last-5,last-2,fix<2>)) );
- VERIFY_IS_APPROX( A(seq(n-1-5,7,2), seq(n-1-5,7,2)), A(seq(last-5,7,2), seq(last-5,7,fix<2>)) );
- VERIFY_IS_APPROX( A(seq(1,n-1-2), seq(n-1-5,7)), A(seq(1,last-2), seq(last-5,7)) );
- VERIFY_IS_APPROX( A(seq(n-1-5,n-1-2), seq(n-1-5,n-1-2)), A(seq(last-5,last-2), seq(last-5,last-2)) );
-
- VERIFY_IS_APPROX( A.col(A.cols()-1), A(all,last) );
- VERIFY_IS_APPROX( A(A.rows()-2, A.cols()/2), A(last-1, end/2) );
- VERIFY_IS_APPROX( a(a.size()-2), a(last-1) );
- VERIFY_IS_APPROX( a(a.size()/2), a((last+1)/2) );
-
- // Check fall-back to Block
- {
- VERIFY( is_same_eq(A.col(0), A(all,0)) );
- VERIFY( is_same_eq(A.row(0), A(0,all)) );
- VERIFY( is_same_eq(A.block(0,0,2,2), A(seqN(0,2),seq(0,1))) );
- VERIFY( is_same_eq(A.middleRows(2,4), A(seqN(2,4),all)) );
- VERIFY( is_same_eq(A.middleCols(2,4), A(all,seqN(2,4))) );
-
- VERIFY( is_same_eq(A.col(A.cols()-1), A(all,last)) );
-
- const ArrayXXi& cA(A);
- VERIFY( is_same_eq(cA.col(0), cA(all,0)) );
- VERIFY( is_same_eq(cA.row(0), cA(0,all)) );
- VERIFY( is_same_eq(cA.block(0,0,2,2), cA(seqN(0,2),seq(0,1))) );
- VERIFY( is_same_eq(cA.middleRows(2,4), cA(seqN(2,4),all)) );
- VERIFY( is_same_eq(cA.middleCols(2,4), cA(all,seqN(2,4))) );
-
- VERIFY( is_same_eq(a.head(4), a(seq(0,3))) );
- VERIFY( is_same_eq(a.tail(4), a(seqN(last-3,4))) );
- VERIFY( is_same_eq(a.tail(4), a(seq(end-4,last))) );
- VERIFY( is_same_eq(a.segment<4>(3), a(seqN(3,fix<4>))) );
- }
-
- ArrayXXi A1=A, A2 = ArrayXXi::Random(4,4);
- ArrayXi range25(4); range25 << 3,2,4,5;
- A1(seqN(3,4),seq(2,5)) = A2;
- VERIFY_IS_APPROX( A1.block(3,2,4,4), A2 );
- A1 = A;
- A2.setOnes();
- A1(seq(6,3,-1),range25) = A2;
- VERIFY_IS_APPROX( A1.block(3,2,4,4), A2 );
-
- // check reverse
- {
- VERIFY( is_same_seq_type( seq(3,7).reverse(), seqN(7,5,fix<-1>) ) );
- VERIFY( is_same_seq_type( seq(7,3,fix<-2>).reverse(), seqN(3,3,fix<2>) ) );
- VERIFY_IS_APPROX( a(seqN(2,last/2).reverse()), a(seqN(2+(last/2-1)*1,last/2,fix<-1>)) );
- VERIFY_IS_APPROX( a(seqN(last/2,fix<4>).reverse()),a(seqN(last/2,fix<4>)).reverse() );
- VERIFY_IS_APPROX( A(seq(last-5,last-1,2).reverse(), seqN(last-3,3,fix<-2>).reverse()),
- A(seq(last-5,last-1,2), seqN(last-3,3,fix<-2>)).reverse() );
- }
-
-#if EIGEN_HAS_CXX11
- VERIFY( (A(all, std::array<int,4>{{1,3,2,4}})).ColsAtCompileTime == 4);
-
- VERIFY_IS_APPROX( (A(std::array<int,3>{{1,3,5}}, std::array<int,4>{{9,6,3,0}})), A(seqN(1,3,2), seqN(9,4,-3)) );
-
-#if EIGEN_HAS_STATIC_ARRAY_TEMPLATE
- VERIFY_IS_APPROX( A({3, 1, 6, 5}, all), A(std::array<int,4>{{3, 1, 6, 5}}, all) );
- VERIFY_IS_APPROX( A(all,{3, 1, 6, 5}), A(all,std::array<int,4>{{3, 1, 6, 5}}) );
- VERIFY_IS_APPROX( A({1,3,5},{3, 1, 6, 5}), A(std::array<int,3>{{1,3,5}},std::array<int,4>{{3, 1, 6, 5}}) );
-
- VERIFY_IS_EQUAL( A({1,3,5},{3, 1, 6, 5}).RowsAtCompileTime, 3 );
- VERIFY_IS_EQUAL( A({1,3,5},{3, 1, 6, 5}).ColsAtCompileTime, 4 );
-
- VERIFY_IS_APPROX( a({3, 1, 6, 5}), a(std::array<int,4>{{3, 1, 6, 5}}) );
- VERIFY_IS_EQUAL( a({1,3,5}).SizeAtCompileTime, 3 );
-
- VERIFY_IS_APPROX( b({3, 1, 6, 5}), b(std::array<int,4>{{3, 1, 6, 5}}) );
- VERIFY_IS_EQUAL( b({1,3,5}).SizeAtCompileTime, 3 );
-#endif
-
-#endif
-
- // check mat(i,j) with weird types for i and j
- {
- VERIFY_IS_APPROX( A(B.RowsAtCompileTime-1, 1), A(3,1) );
- VERIFY_IS_APPROX( A(B.RowsAtCompileTime, 1), A(4,1) );
- VERIFY_IS_APPROX( A(B.RowsAtCompileTime-1, B.ColsAtCompileTime-1), A(3,3) );
- VERIFY_IS_APPROX( A(B.RowsAtCompileTime, B.ColsAtCompileTime), A(4,4) );
- const Index I = 3, J = 4;
- VERIFY_IS_APPROX( A(I,J), A(3,4) );
- }
-
- // check extended block API
- {
- VERIFY( is_same_eq( A.block<3,4>(1,1), A.block(1,1,fix<3>,fix<4>)) );
- VERIFY( is_same_eq( A.block<3,4>(1,1,3,4), A.block(1,1,fix<3>(),fix<4>(4))) );
- VERIFY( is_same_eq( A.block<3,Dynamic>(1,1,3,4), A.block(1,1,fix<3>,4)) );
- VERIFY( is_same_eq( A.block<Dynamic,4>(1,1,3,4), A.block(1,1,fix<Dynamic>(3),fix<4>)) );
- VERIFY( is_same_eq( A.block(1,1,3,4), A.block(1,1,fix<Dynamic>(3),fix<Dynamic>(4))) );
-
- VERIFY( is_same_eq( A.topLeftCorner<3,4>(), A.topLeftCorner(fix<3>,fix<4>)) );
- VERIFY( is_same_eq( A.bottomLeftCorner<3,4>(), A.bottomLeftCorner(fix<3>,fix<4>)) );
- VERIFY( is_same_eq( A.bottomRightCorner<3,4>(), A.bottomRightCorner(fix<3>,fix<4>)) );
- VERIFY( is_same_eq( A.topRightCorner<3,4>(), A.topRightCorner(fix<3>,fix<4>)) );
-
- VERIFY( is_same_eq( A.leftCols<3>(), A.leftCols(fix<3>)) );
- VERIFY( is_same_eq( A.rightCols<3>(), A.rightCols(fix<3>)) );
- VERIFY( is_same_eq( A.middleCols<3>(1), A.middleCols(1,fix<3>)) );
-
- VERIFY( is_same_eq( A.topRows<3>(), A.topRows(fix<3>)) );
- VERIFY( is_same_eq( A.bottomRows<3>(), A.bottomRows(fix<3>)) );
- VERIFY( is_same_eq( A.middleRows<3>(1), A.middleRows(1,fix<3>)) );
-
- VERIFY( is_same_eq( a.segment<3>(1), a.segment(1,fix<3>)) );
- VERIFY( is_same_eq( a.head<3>(), a.head(fix<3>)) );
- VERIFY( is_same_eq( a.tail<3>(), a.tail(fix<3>)) );
-
- const ArrayXXi& cA(A);
- VERIFY( is_same_eq( cA.block<Dynamic,4>(1,1,3,4), cA.block(1,1,fix<Dynamic>(3),fix<4>)) );
-
- VERIFY( is_same_eq( cA.topLeftCorner<3,4>(), cA.topLeftCorner(fix<3>,fix<4>)) );
- VERIFY( is_same_eq( cA.bottomLeftCorner<3,4>(), cA.bottomLeftCorner(fix<3>,fix<4>)) );
- VERIFY( is_same_eq( cA.bottomRightCorner<3,4>(), cA.bottomRightCorner(fix<3>,fix<4>)) );
- VERIFY( is_same_eq( cA.topRightCorner<3,4>(), cA.topRightCorner(fix<3>,fix<4>)) );
-
- VERIFY( is_same_eq( cA.leftCols<3>(), cA.leftCols(fix<3>)) );
- VERIFY( is_same_eq( cA.rightCols<3>(), cA.rightCols(fix<3>)) );
- VERIFY( is_same_eq( cA.middleCols<3>(1), cA.middleCols(1,fix<3>)) );
-
- VERIFY( is_same_eq( cA.topRows<3>(), cA.topRows(fix<3>)) );
- VERIFY( is_same_eq( cA.bottomRows<3>(), cA.bottomRows(fix<3>)) );
- VERIFY( is_same_eq( cA.middleRows<3>(1), cA.middleRows(1,fix<3>)) );
- }
-
-}
-
-void test_indexed_view()
-{
-// for(int i = 0; i < g_repeat; i++) {
- CALL_SUBTEST_1( check_indexed_view() );
- CALL_SUBTEST_2( check_indexed_view() );
- CALL_SUBTEST_3( check_indexed_view() );
-// }
-}
diff --git a/eigen/test/lscg.cpp b/eigen/test/lscg.cpp
index daa62a9..d49ee00 100644
--- a/eigen/test/lscg.cpp
+++ b/eigen/test/lscg.cpp
@@ -14,12 +14,20 @@ template<typename T> void test_lscg_T()
{
LeastSquaresConjugateGradient<SparseMatrix<T> > lscg_colmajor_diag;
LeastSquaresConjugateGradient<SparseMatrix<T>, IdentityPreconditioner> lscg_colmajor_I;
+ LeastSquaresConjugateGradient<SparseMatrix<T,RowMajor> > lscg_rowmajor_diag;
+ LeastSquaresConjugateGradient<SparseMatrix<T,RowMajor>, IdentityPreconditioner> lscg_rowmajor_I;
CALL_SUBTEST( check_sparse_square_solving(lscg_colmajor_diag) );
CALL_SUBTEST( check_sparse_square_solving(lscg_colmajor_I) );
CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_colmajor_diag) );
CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_colmajor_I) );
+
+ CALL_SUBTEST( check_sparse_square_solving(lscg_rowmajor_diag) );
+ CALL_SUBTEST( check_sparse_square_solving(lscg_rowmajor_I) );
+
+ CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_rowmajor_diag) );
+ CALL_SUBTEST( check_sparse_leastsquare_solving(lscg_rowmajor_I) );
}
void test_lscg()
diff --git a/eigen/test/main.h b/eigen/test/main.h
index 25d2dcf..bd53251 100644
--- a/eigen/test/main.h
+++ b/eigen/test/main.h
@@ -310,6 +310,17 @@ template<> inline float test_precision<std::complex<float> >() { return test_pre
template<> inline double test_precision<std::complex<double> >() { return test_precision<double>(); }
template<> inline long double test_precision<std::complex<long double> >() { return test_precision<long double>(); }
+inline bool test_isApprox(const short& a, const short& b)
+{ return internal::isApprox(a, b, test_precision<short>()); }
+inline bool test_isApprox(const unsigned short& a, const unsigned short& b)
+{ return internal::isApprox(a, b, test_precision<unsigned long>()); }
+inline bool test_isApprox(const unsigned int& a, const unsigned int& b)
+{ return internal::isApprox(a, b, test_precision<unsigned int>()); }
+inline bool test_isApprox(const long& a, const long& b)
+{ return internal::isApprox(a, b, test_precision<long>()); }
+inline bool test_isApprox(const unsigned long& a, const unsigned long& b)
+{ return internal::isApprox(a, b, test_precision<unsigned long>()); }
+
inline bool test_isApprox(const int& a, const int& b)
{ return internal::isApprox(a, b, test_precision<int>()); }
inline bool test_isMuchSmallerThan(const int& a, const int& b)
diff --git a/eigen/test/mixingtypes.cpp b/eigen/test/mixingtypes.cpp
index b796082..ad9c2c6 100644
--- a/eigen/test/mixingtypes.cpp
+++ b/eigen/test/mixingtypes.cpp
@@ -69,7 +69,7 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
double epsd = std::sqrt(std::numeric_limits<double>::min EIGEN_EMPTY ());
while(std::abs(sf )<epsf) sf = internal::random<float>();
- while(std::abs(sd )<epsd) sd = internal::random<double>();
+ while(std::abs(sd )<epsd) sf = internal::random<double>();
while(std::abs(scf)<epsf) scf = internal::random<CF>();
while(std::abs(scd)<epsd) scd = internal::random<CD>();
diff --git a/eigen/test/numext.cpp b/eigen/test/numext.cpp
new file mode 100644
index 0000000..3de33e2
--- /dev/null
+++ b/eigen/test/numext.cpp
@@ -0,0 +1,53 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
+//
+// This Source Code Form is subject to the terms of the Mozilla
+// Public License v. 2.0. If a copy of the MPL was not distributed
+// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include "main.h"
+
+template<typename T>
+void check_abs() {
+ typedef typename NumTraits<T>::Real Real;
+
+ if(NumTraits<T>::IsSigned)
+ VERIFY_IS_EQUAL(numext::abs(-T(1)), T(1));
+ VERIFY_IS_EQUAL(numext::abs(T(0)), T(0));
+ VERIFY_IS_EQUAL(numext::abs(T(1)), T(1));
+
+ for(int k=0; k<g_repeat*100; ++k)
+ {
+ T x = internal::random<T>();
+ if(!internal::is_same<T,bool>::value)
+ x = x/Real(2);
+ if(NumTraits<T>::IsSigned)
+ {
+ VERIFY_IS_EQUAL(numext::abs(x), numext::abs(-x));
+ VERIFY( numext::abs(-x) >= Real(0));
+ }
+ VERIFY( numext::abs(x) >= Real(0));
+ VERIFY_IS_APPROX( numext::abs2(x), numext::abs2(numext::abs(x)) );
+ }
+}
+
+void test_numext() {
+ CALL_SUBTEST( check_abs<bool>() );
+ CALL_SUBTEST( check_abs<signed char>() );
+ CALL_SUBTEST( check_abs<unsigned char>() );
+ CALL_SUBTEST( check_abs<short>() );
+ CALL_SUBTEST( check_abs<unsigned short>() );
+ CALL_SUBTEST( check_abs<int>() );
+ CALL_SUBTEST( check_abs<unsigned int>() );
+ CALL_SUBTEST( check_abs<long>() );
+ CALL_SUBTEST( check_abs<unsigned long>() );
+ CALL_SUBTEST( check_abs<half>() );
+ CALL_SUBTEST( check_abs<float>() );
+ CALL_SUBTEST( check_abs<double>() );
+ CALL_SUBTEST( check_abs<long double>() );
+
+ CALL_SUBTEST( check_abs<std::complex<float> >() );
+ CALL_SUBTEST( check_abs<std::complex<double> >() );
+}
diff --git a/eigen/test/packetmath.cpp b/eigen/test/packetmath.cpp
index 08b3603..7821a17 100644
--- a/eigen/test/packetmath.cpp
+++ b/eigen/test/packetmath.cpp
@@ -438,7 +438,6 @@ template<typename Scalar> void packetmath_real()
CHECK_CWISE1_IF(PacketTraits::HasSqrt, std::sqrt, internal::psqrt);
CHECK_CWISE1_IF(PacketTraits::HasLog, std::log, internal::plog);
#if EIGEN_HAS_C99_MATH && (__cplusplus > 199711L)
- CHECK_CWISE1_IF(PacketTraits::HasExpm1, std::expm1, internal::pexpm1);
CHECK_CWISE1_IF(PacketTraits::HasLog1p, std::log1p, internal::plog1p);
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasLGamma, std::lgamma, internal::plgamma);
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasErf, std::erf, internal::perf);
diff --git a/eigen/test/product_mmtr.cpp b/eigen/test/product_mmtr.cpp
index f6e4bb1..d3e24b0 100644
--- a/eigen/test/product_mmtr.cpp
+++ b/eigen/test/product_mmtr.cpp
@@ -1,7 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
-// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>
+// Copyright (C) 2010-2017 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
@@ -10,12 +10,19 @@
#include "main.h"
#define CHECK_MMTR(DEST, TRI, OP) { \
+ ref3 = DEST; \
ref2 = ref1 = DEST; \
DEST.template triangularView<TRI>() OP; \
ref1 OP; \
ref2.template triangularView<TRI>() \
= ref1.template triangularView<TRI>(); \
VERIFY_IS_APPROX(DEST,ref2); \
+ \
+ DEST = ref3; \
+ ref3 = ref2; \
+ ref3.diagonal() = DEST.diagonal(); \
+ DEST.template triangularView<TRI|ZeroDiag>() OP; \
+ VERIFY_IS_APPROX(DEST,ref3); \
}
template<typename Scalar> void mmtr(int size)
@@ -27,7 +34,7 @@ template<typename Scalar> void mmtr(int size)
MatrixColMaj matc = MatrixColMaj::Zero(size, size);
MatrixRowMaj matr = MatrixRowMaj::Zero(size, size);
- MatrixColMaj ref1(size, size), ref2(size, size);
+ MatrixColMaj ref1(size, size), ref2(size, size), ref3(size,size);
MatrixColMaj soc(size,othersize); soc.setRandom();
MatrixColMaj osc(othersize,size); osc.setRandom();
diff --git a/eigen/test/product_notemporary.cpp b/eigen/test/product_notemporary.cpp
index 8bf71b4..30592b7 100644
--- a/eigen/test/product_notemporary.cpp
+++ b/eigen/test/product_notemporary.cpp
@@ -51,6 +51,7 @@ template<typename MatrixType> void product_notemporary(const MatrixType& m)
VERIFY_EVALUATION_COUNT( m3.noalias() = s1 * (m1 * m2.transpose()), 0);
VERIFY_EVALUATION_COUNT( m3 = m3 + (m1 * m2.adjoint()), 1);
+ VERIFY_EVALUATION_COUNT( m3 = m3 - (m1 * m2.adjoint()), 1);
VERIFY_EVALUATION_COUNT( m3 = m3 + (m1 * m2.adjoint()).transpose(), 1);
VERIFY_EVALUATION_COUNT( m3.noalias() = m3 + m1 * m2.transpose(), 0);
diff --git a/eigen/test/sparse_product.cpp b/eigen/test/sparse_product.cpp
index c1edd26..1975867 100644
--- a/eigen/test/sparse_product.cpp
+++ b/eigen/test/sparse_product.cpp
@@ -297,6 +297,10 @@ template<typename SparseMatrixType> void sparse_product()
VERIFY_IS_APPROX(x=mLo.template selfadjointView<Lower>()*b, refX=refS*b);
VERIFY_IS_APPROX(x=mS.template selfadjointView<Upper|Lower>()*b, refX=refS*b);
+ VERIFY_IS_APPROX(x=b * mUp.template selfadjointView<Upper>(), refX=b*refS);
+ VERIFY_IS_APPROX(x=b * mLo.template selfadjointView<Lower>(), refX=b*refS);
+ VERIFY_IS_APPROX(x=b * mS.template selfadjointView<Upper|Lower>(), refX=b*refS);
+
VERIFY_IS_APPROX(x.noalias()+=mUp.template selfadjointView<Upper>()*b, refX+=refS*b);
VERIFY_IS_APPROX(x.noalias()-=mLo.template selfadjointView<Lower>()*b, refX-=refS*b);
VERIFY_IS_APPROX(x.noalias()+=mS.template selfadjointView<Upper|Lower>()*b, refX+=refS*b);
diff --git a/eigen/test/symbolic_index.cpp b/eigen/test/symbolic_index.cpp
deleted file mode 100644
index 1db8514..0000000
--- a/eigen/test/symbolic_index.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
-//
-// This Source Code Form is subject to the terms of the Mozilla
-// Public License v. 2.0. If a copy of the MPL was not distributed
-// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifdef EIGEN_TEST_PART_2
-#define EIGEN_MAX_CPP_VER 03
-#endif
-
-#include "main.h"
-
-template<typename T>
-bool match(const T& xpr, std::string ref, std::string str_xpr = "") {
- EIGEN_UNUSED_VARIABLE(str_xpr);
- std::stringstream str;
- str << xpr;
- if(!(str.str() == ref))
- std::cout << str_xpr << "\n" << xpr << "\n\n";
- return str.str() == ref;
-}
-
-#define MATCH(X,R) match(X, R, #X)
-
-template<typename T1,typename T2>
-typename internal::enable_if<internal::is_same<T1,T2>::value,bool>::type
-is_same_fixed(const T1& a, const T2& b)
-{
- return (Index(a) == Index(b));
-}
-
-template<typename T1,typename T2>
-bool is_same_seq(const T1& a, const T2& b)
-{
- bool ok = a.first()==b.first() && a.size() == b.size() && Index(a.incrObject())==Index(b.incrObject());;
- if(!ok)
- {
- std::cerr << "seqN(" << a.first() << ", " << a.size() << ", " << Index(a.incrObject()) << ") != ";
- std::cerr << "seqN(" << b.first() << ", " << b.size() << ", " << Index(b.incrObject()) << ")\n";
- }
- return ok;
-}
-
-template<typename T1,typename T2>
-typename internal::enable_if<internal::is_same<T1,T2>::value,bool>::type
-is_same_type(const T1&, const T2&)
-{
- return true;
-}
-
-template<typename T1,typename T2>
-bool is_same_symb(const T1& a, const T2& b, Index size)
-{
- using Eigen::placeholders::last;
- return a.eval(last=size-1) == b.eval(last=size-1);
-}
-
-
-#define VERIFY_EQ_INT(A,B) VERIFY_IS_APPROX(int(A),int(B))
-
-void check_symbolic_index()
-{
- using Eigen::placeholders::last;
- using Eigen::placeholders::end;
-
- Index size=100;
-
- // First, let's check FixedInt arithmetic:
- VERIFY( is_same_type( (fix<5>()-fix<3>())*fix<9>()/(-fix<3>()), fix<-(5-3)*9/3>() ) );
- VERIFY( is_same_type( (fix<5>()-fix<3>())*fix<9>()/fix<2>(), fix<(5-3)*9/2>() ) );
- VERIFY( is_same_type( fix<9>()/fix<2>(), fix<9/2>() ) );
- VERIFY( is_same_type( fix<9>()%fix<2>(), fix<9%2>() ) );
- VERIFY( is_same_type( fix<9>()&fix<2>(), fix<9&2>() ) );
- VERIFY( is_same_type( fix<9>()|fix<2>(), fix<9|2>() ) );
- VERIFY( is_same_type( fix<9>()/2, int(9/2) ) );
-
- VERIFY( is_same_symb( end-1, last, size) );
- VERIFY( is_same_symb( end-fix<1>, last, size) );
-
- VERIFY_IS_EQUAL( ( (last*5-2)/3 ).eval(last=size-1), ((size-1)*5-2)/3 );
- VERIFY_IS_EQUAL( ( (last*fix<5>-fix<2>)/fix<3> ).eval(last=size-1), ((size-1)*5-2)/3 );
- VERIFY_IS_EQUAL( ( -last*end ).eval(last=size-1), -(size-1)*size );
- VERIFY_IS_EQUAL( ( end-3*last ).eval(last=size-1), size- 3*(size-1) );
- VERIFY_IS_EQUAL( ( (end-3*last)/end ).eval(last=size-1), (size- 3*(size-1))/size );
-
-#if EIGEN_HAS_CXX14
- {
- struct x_tag {}; static const Symbolic::SymbolExpr<x_tag> x;
- struct y_tag {}; static const Symbolic::SymbolExpr<y_tag> y;
- struct z_tag {}; static const Symbolic::SymbolExpr<z_tag> z;
-
- VERIFY_IS_APPROX( int(((x+3)/y+z).eval(x=6,y=3,z=-13)), (6+3)/3+(-13) );
- }
-#endif
-}
-
-void test_symbolic_index()
-{
- CALL_SUBTEST_1( check_symbolic_index() );
- CALL_SUBTEST_2( check_symbolic_index() );
-}