aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/nullary.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2016-10-25 16:53:09 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2016-10-25 16:53:09 +0200
commit58146be99b4b8ecc0f56ed8177b30c96cec8b4f4 (patch)
treec2a264a14e2fc35acdc060f4874def776c754862 /test/nullary.cpp
parent13fc18d3a24849529efe605992cddf4498a59c74 (diff)
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.
Diffstat (limited to 'test/nullary.cpp')
-rw-r--r--test/nullary.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/nullary.cpp b/test/nullary.cpp
index 92514b847..6d16bd4d2 100644
--- a/test/nullary.cpp
+++ b/test/nullary.cpp
@@ -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 );