From 863580fe881c32af82eb106817e71dc560d9e775 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 18 Jul 2018 23:33:07 +0200 Subject: bug #1432: fix conservativeResize for non-relocatable scalar types. For those we need to by-pass realloc routines and fall-back to allocate as new - copy - delete. The remaining problem is that we don't have any mechanism to accurately determine whether a type is relocatable or not, so currently let's be super conservative using either RequireInitialization or std::is_trivially_copyable --- test/sparse_block.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/sparse_block.cpp') diff --git a/test/sparse_block.cpp b/test/sparse_block.cpp index e7303eab0..f9668102c 100644 --- a/test/sparse_block.cpp +++ b/test/sparse_block.cpp @@ -8,6 +8,7 @@ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "sparse.h" +#include "AnnoyingScalar.h" template typename Eigen::internal::enable_if<(T::Flags&RowMajorBit)==RowMajorBit, typename T::RowXpr>::type @@ -31,6 +32,7 @@ template void sparse_block(const SparseMatrixType& re const Index outer = ref.outerSize(); typedef typename SparseMatrixType::Scalar Scalar; + typedef typename SparseMatrixType::RealScalar RealScalar; typedef typename SparseMatrixType::StorageIndex StorageIndex; double density = (std::max)(8./(rows*cols), 0.01); @@ -164,14 +166,14 @@ template void sparse_block(const SparseMatrixType& re { VERIFY(j==numext::real(m3.innerVector(j).nonZeros())); if(j>0) - VERIFY(j==numext::real(m3.innerVector(j).lastCoeff())); + VERIFY(RealScalar(j)==numext::real(m3.innerVector(j).lastCoeff())); } m3.makeCompressed(); for(Index j=0; j<(std::min)(outer, inner); ++j) { VERIFY(j==numext::real(m3.innerVector(j).nonZeros())); if(j>0) - VERIFY(j==numext::real(m3.innerVector(j).lastCoeff())); + VERIFY(RealScalar(j)==numext::real(m3.innerVector(j).lastCoeff())); } VERIFY(m3.innerVector(j0).nonZeros() == m3.transpose().innerVector(j0).nonZeros()); @@ -313,5 +315,8 @@ EIGEN_DECLARE_TEST(sparse_block) CALL_SUBTEST_4(( sparse_block(SparseMatrix(short(r), short(c))) )); CALL_SUBTEST_4(( sparse_block(SparseMatrix(short(r), short(c))) )); + + AnnoyingScalar::dont_throw = true; + CALL_SUBTEST_5(( sparse_block(SparseMatrix(r,c)) )); } } -- cgit v1.2.3