bug #1383: fix regression in LinSpaced for integers and high<low

This commit is contained in:
Gael Guennebaud
2017-01-25 18:13:53 +01:00
parent 296d24be4d
commit 850ca961d2
2 changed files with 19 additions and 3 deletions

View File

@@ -93,8 +93,8 @@ struct linspaced_op_impl<Scalar,Packet,/*IsInteger*/true>
linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) :
m_low(low),
m_multiplier((high-low)/convert_index<Scalar>(num_steps<=1 ? 1 : num_steps-1)),
m_divisor(convert_index<Scalar>(num_steps+high-low)/((high-low+1)==0?1:(high-low+1))),
m_use_divisor((high+1)<(low+num_steps))
m_divisor(convert_index<Scalar>((high>=low?num_steps:-num_steps)+(high-low))/((numext::abs(high-low)+1)==0?1:(numext::abs(high-low)+1))),
m_use_divisor(num_steps>1 && (numext::abs(high-low)+1)<num_steps)
{}
template<typename IndexType>