diff options
author | 2016-02-01 15:00:04 +0100 | |
---|---|---|
committer | 2016-02-01 15:00:04 +0100 | |
commit | 6e0a86194ce6664e83d8035cbdd6047e5a27ed43 (patch) | |
tree | 30c4488de83040d8ada5a50f6274f2d14c9f5df1 | |
parent | e1d219e5c9ea782550882aa8eb131b107f05105e (diff) |
Fix integer path for num_steps==1
-rw-r--r-- | Eigen/src/Core/functors/NullaryFunctors.h | 8 | ||||
-rw-r--r-- | test/nullary.cpp | 1 |
2 files changed, 5 insertions, 4 deletions
diff --git a/Eigen/src/Core/functors/NullaryFunctors.h b/Eigen/src/Core/functors/NullaryFunctors.h index 71629af4c..c5836d048 100644 --- a/Eigen/src/Core/functors/NullaryFunctors.h +++ b/Eigen/src/Core/functors/NullaryFunctors.h @@ -99,24 +99,24 @@ template <typename Scalar, typename Packet> struct linspaced_op_impl<Scalar,Packet,/*RandomAccess*/true,/*IsInteger*/true> { linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) : - m_low(low), m_length(high-low), m_numSteps(num_steps), m_interPacket(plset<Packet>(0)) + m_low(low), m_length(high-low), m_divisor(num_steps==1?1:num_steps-1), m_interPacket(plset<Packet>(0)) {} template<typename Index> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { - return m_low + (m_length*Scalar(i))/(m_numSteps-1); + return m_low + (m_length*Scalar(i))/m_divisor; } template<typename Index> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Packet packetOp(Index i) const { return internal::padd(pset1<Packet>(m_low), pdiv(pmul(pset1<Packet>(m_length), padd(pset1<Packet>(Scalar(i)),m_interPacket)), - pset1<Packet>(m_numSteps-1))); } + pset1<Packet>(m_divisor))); } const Scalar m_low; const Scalar m_length; - const Index m_numSteps; + const Index m_divisor; const Packet m_interPacket; }; diff --git a/test/nullary.cpp b/test/nullary.cpp index 8d65910eb..cb87695ee 100644 --- a/test/nullary.cpp +++ b/test/nullary.cpp @@ -130,6 +130,7 @@ void test_nullary() CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) ); CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(1,300))) ); + CALL_SUBTEST_9( testVectorType(Matrix<int,1,1>()) ); } #ifdef EIGEN_TEST_PART_6 |