mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
Fix harmless Scalar vs RealScalar cast.
This commit is contained in:
parent
e23bf40dc2
commit
7580112c31
@ -42,14 +42,15 @@ template <typename Scalar, bool IsInteger> struct linspaced_op_impl;
|
|||||||
template <typename Scalar>
|
template <typename Scalar>
|
||||||
struct linspaced_op_impl<Scalar,/*IsInteger*/false>
|
struct linspaced_op_impl<Scalar,/*IsInteger*/false>
|
||||||
{
|
{
|
||||||
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
|
||||||
linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) :
|
linspaced_op_impl(const Scalar& low, const Scalar& high, Index num_steps) :
|
||||||
m_low(low), m_high(high), m_size1(num_steps==1 ? 1 : num_steps-1), m_step(num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1)),
|
m_low(low), m_high(high), m_size1(num_steps==1 ? 1 : num_steps-1), m_step(num_steps==1 ? Scalar() : (high-low)/RealScalar(num_steps-1)),
|
||||||
m_flip(numext::abs(high)<numext::abs(low))
|
m_flip(numext::abs(high)<numext::abs(low))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename IndexType>
|
template<typename IndexType>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (IndexType i) const {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (IndexType i) const {
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
|
||||||
if(m_flip)
|
if(m_flip)
|
||||||
return (i==0)? m_low : (m_high - RealScalar(m_size1-i)*m_step);
|
return (i==0)? m_low : (m_high - RealScalar(m_size1-i)*m_step);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user