mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-22 04:44:25 +08:00
ok, this time cast should really work ; sorry for the noise
This commit is contained in:
parent
428a12902a
commit
7029ed6b88
@ -71,6 +71,22 @@ class DiagonalMatrixBase : ei_no_assignment_operator,
|
|||||||
::run(derived(),other.derived());
|
::run(derived(),other.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename NewType,int dummy=0>
|
||||||
|
struct cast_selector {
|
||||||
|
typedef const DiagonalMatrixWrapper<NestByValue<CwiseUnaryOp<ei_scalar_cast_op<Scalar, NewType>, _CoeffsVectorType> > > return_type;
|
||||||
|
inline static return_type run(const DiagonalMatrixBase& d) {
|
||||||
|
return d.m_coeffs.template cast<NewType>().nestByValue().asDiagonal();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<int dummy>
|
||||||
|
struct cast_selector<Scalar,dummy> {
|
||||||
|
typedef const Derived& return_type;
|
||||||
|
inline static return_type run(const DiagonalMatrixBase& d) {
|
||||||
|
return d.derived();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline DiagonalMatrixBase(const _CoeffsVectorType& coeffs) : m_coeffs(coeffs)
|
inline DiagonalMatrixBase(const _CoeffsVectorType& coeffs) : m_coeffs(coeffs)
|
||||||
@ -80,9 +96,10 @@ class DiagonalMatrixBase : ei_no_assignment_operator,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename NewType>
|
template<typename NewType>
|
||||||
inline DiagonalMatrixWrapper<NestByValue<CwiseUnaryOp<ei_scalar_cast_op<Scalar, NewType>, _CoeffsVectorType> > > cast() const
|
inline typename cast_selector<NewType,0>::return_type
|
||||||
|
cast() const
|
||||||
{
|
{
|
||||||
return m_coeffs.template cast<NewType>().nestByValue().asDiagonal();
|
return cast_selector<NewType,0>::run(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Assignment operator.
|
/** Assignment operator.
|
||||||
|
@ -242,9 +242,13 @@ template<typename ExpressionType> struct HNormalizedReturnType {
|
|||||||
NestByValue<StartMinusOne> > Type;
|
NestByValue<StartMinusOne> > Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename CurrentType, typename NewType> struct ei_cast_return_type
|
template<typename XprType, typename CastType> struct ei_cast_return_type
|
||||||
{
|
{
|
||||||
typedef typename ei_meta_if<ei_is_same_type<CurrentType,NewType>::ret,const CurrentType&,NewType>::ret type;
|
typedef typename XprType::Scalar CurrentScalarType;
|
||||||
|
typedef typename ei_cleantype<CastType>::type _CastType;
|
||||||
|
typedef typename _CastType::Scalar NewScalarType;
|
||||||
|
typedef typename ei_meta_if<ei_is_same_type<CurrentScalarType,NewScalarType>::ret,
|
||||||
|
const XprType&,CastType>::ret type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EIGEN_XPRHELPER_H
|
#endif // EIGEN_XPRHELPER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user