mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
bug #1004: one more rewrite of LinSpaced for floating point numbers to guarantee both interpolation and monotonicity.
This version simply does low+i*step plus a branch to return high if i==size-1. Vectorization is accomplished with a branch and the help of pinsertlast. Some quick benchmark revealed that the overhead is really marginal, even when filling small vectors.
This commit is contained in:
@@ -30,6 +30,7 @@ bool equalsIdentity(const MatrixType& A)
|
||||
|
||||
bool diagOK = (A.diagonal().array() == 1).all();
|
||||
return offDiagOK && diagOK;
|
||||
|
||||
}
|
||||
|
||||
template<typename VectorType>
|
||||
@@ -43,6 +44,10 @@ void testVectorType(const VectorType& base)
|
||||
Scalar low = (size == 1 ? high : internal::random<Scalar>(-500,500));
|
||||
if (low>high) std::swap(low,high);
|
||||
|
||||
// check low==high
|
||||
if(internal::random<float>(0.f,1.f)<0.05f)
|
||||
low = high;
|
||||
|
||||
const Scalar step = ((size == 1) ? 1 : (high-low)/(size-1));
|
||||
|
||||
// check whether the result yields what we expect it to do
|
||||
@@ -77,6 +82,8 @@ void testVectorType(const VectorType& base)
|
||||
}
|
||||
|
||||
VERIFY( m(m.size()-1) <= high );
|
||||
VERIFY( (m.array() <= high).all() );
|
||||
VERIFY( (m.array() >= low).all() );
|
||||
|
||||
|
||||
VERIFY( m(m.size()-1) >= low );
|
||||
|
||||
Reference in New Issue
Block a user