mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-29 16:22:03 +08:00
* make sum and redux honor EvalBeforeNestingBit too
* fix MSVC issues (hopefully)
This commit is contained in:
parent
cc6159743d
commit
42b237b83a
@ -38,6 +38,27 @@ class DiagonalMatrixBase : ei_no_assignment_operator,
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef typename ei_cleantype<CoeffsVectorType>::type _CoeffsVectorType;
|
typedef typename ei_cleantype<CoeffsVectorType>::type _CoeffsVectorType;
|
||||||
|
|
||||||
|
template<typename OtherDerived,
|
||||||
|
bool IsVector = OtherDerived::IsVectorAtCompileTime,
|
||||||
|
bool IsDiagonal = (OtherDerived::Flags&Diagonal)==Diagonal>
|
||||||
|
struct construct_from_expression;
|
||||||
|
|
||||||
|
// = vector
|
||||||
|
template<typename OtherDerived>
|
||||||
|
struct construct_from_expression<OtherDerived,true,false>
|
||||||
|
{
|
||||||
|
static void run(Derived& dst, const OtherDerived& src)
|
||||||
|
{ dst.diagonal() = src; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// = diagonal expression
|
||||||
|
template<typename OtherDerived, bool IsVector>
|
||||||
|
struct construct_from_expression<OtherDerived,IsVector,true>
|
||||||
|
{
|
||||||
|
static void run(Derived& dst, const OtherDerived& src)
|
||||||
|
{ dst.diagonal() = src.diagonal(); }
|
||||||
|
};
|
||||||
|
|
||||||
/** Default constructor without initialization */
|
/** Default constructor without initialization */
|
||||||
inline DiagonalMatrixBase() {}
|
inline DiagonalMatrixBase() {}
|
||||||
@ -50,27 +71,6 @@ class DiagonalMatrixBase : ei_no_assignment_operator,
|
|||||||
construct_from_expression<OtherDerived>::run(derived(),other.derived());
|
construct_from_expression<OtherDerived>::run(derived(),other.derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OtherDerived,
|
|
||||||
bool IsVector = OtherDerived::IsVectorAtCompileTime,
|
|
||||||
bool IsDiagonal = (OtherDerived::Flags&Diagonal)==Diagonal>
|
|
||||||
struct construct_from_expression;
|
|
||||||
|
|
||||||
// = vector
|
|
||||||
template<typename OtherDerived>
|
|
||||||
struct construct_from_expression<OtherDerived,true,false>
|
|
||||||
{
|
|
||||||
static void run(Derived& dst, const OtherDerived& src)
|
|
||||||
{ dst.m_coeffs = src; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// = diagonal
|
|
||||||
template<typename OtherDerived, bool IsVector>
|
|
||||||
struct construct_from_expression<OtherDerived,IsVector,true>
|
|
||||||
{
|
|
||||||
static void run(Derived& dst, const OtherDerived& src)
|
|
||||||
{ dst.m_coeffs = src.diagonal(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline DiagonalMatrixBase(const _CoeffsVectorType& coeffs) : m_coeffs(coeffs)
|
inline DiagonalMatrixBase(const _CoeffsVectorType& coeffs) : m_coeffs(coeffs)
|
||||||
@ -79,21 +79,6 @@ class DiagonalMatrixBase : ei_no_assignment_operator,
|
|||||||
ei_assert(coeffs.size() > 0);
|
ei_assert(coeffs.size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OtherDerived, bool IsVector=OtherDerived::IsVectorAtCompileTime>
|
|
||||||
struct ei_diagonal_product_ctor {
|
|
||||||
static void run(DiagonalMatrixBase& dst, const OtherDerived& src)
|
|
||||||
{ dst.m_coeffs = src; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename OtherDerived>
|
|
||||||
struct ei_diagonal_product_ctor<OtherDerived,false> {
|
|
||||||
static void run(DiagonalMatrixBase& dst, const OtherDerived& src)
|
|
||||||
{
|
|
||||||
EIGEN_STATIC_ASSERT((OtherDerived::Flags&Diagonal)==Diagonal, THIS_METHOD_IS_ONLY_FOR_DIAGONAL_MATRIX);
|
|
||||||
dst.m_coeffs = src.diagonal();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename NewType>
|
template<typename NewType>
|
||||||
inline DiagonalMatrixWrapper<NestByValue<CwiseUnaryOp<ei_scalar_cast_op<Scalar, NewType>, _CoeffsVectorType> > > cast() const
|
inline DiagonalMatrixWrapper<NestByValue<CwiseUnaryOp<ei_scalar_cast_op<Scalar, NewType>, _CoeffsVectorType> > > cast() const
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,8 @@ MatrixBase<Derived>::redux(const BinaryOp& func) const
|
|||||||
const bool unroll = SizeAtCompileTime * CoeffReadCost
|
const bool unroll = SizeAtCompileTime * CoeffReadCost
|
||||||
+ (SizeAtCompileTime-1) * ei_functor_traits<BinaryOp>::Cost
|
+ (SizeAtCompileTime-1) * ei_functor_traits<BinaryOp>::Cost
|
||||||
<= EIGEN_UNROLLING_LIMIT;
|
<= EIGEN_UNROLLING_LIMIT;
|
||||||
return ei_redux_impl<BinaryOp, Derived, 0, unroll ? int(SizeAtCompileTime) : Dynamic>
|
typedef typename ei_cleantype<typename Derived::Nested>::type ThisNested;
|
||||||
|
return ei_redux_impl<BinaryOp, ThisNested, 0, unroll ? int(SizeAtCompileTime) : Dynamic>
|
||||||
::run(derived(), func);
|
::run(derived(), func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +252,8 @@ template<typename Derived>
|
|||||||
inline typename ei_traits<Derived>::Scalar
|
inline typename ei_traits<Derived>::Scalar
|
||||||
MatrixBase<Derived>::sum() const
|
MatrixBase<Derived>::sum() const
|
||||||
{
|
{
|
||||||
return ei_sum_impl<Derived>::run(derived());
|
typedef typename ei_cleantype<typename Derived::Nested>::type ThisNested;
|
||||||
|
return ei_sum_impl<ThisNested>::run(derived());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal.
|
/** \returns the trace of \c *this, i.e. the sum of the coefficients on the main diagonal.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user