mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-05 11:40:40 +08:00
Fix usage of nesting type in blas_traits. In practice, this fixes compilation of expressions such as A*(A*A)^T
where a product is hidden behind an expression supported by blas-traits.
This commit is contained in:
parent
ea12669f7a
commit
4854326ae8
@ -171,12 +171,13 @@ template<typename XprType> struct blas_traits
|
|||||||
};
|
};
|
||||||
|
|
||||||
// pop conjugate
|
// pop conjugate
|
||||||
template<typename Scalar, typename NestedXpr>
|
template<typename Scalar, typename Xpr>
|
||||||
struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> >
|
struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, Xpr> >
|
||||||
: blas_traits<NestedXpr>
|
: blas_traits<typename internal::remove_all<typename Xpr::Nested>::type>
|
||||||
{
|
{
|
||||||
|
typedef typename internal::remove_all<typename Xpr::Nested>::type NestedXpr;
|
||||||
typedef blas_traits<NestedXpr> Base;
|
typedef blas_traits<NestedXpr> Base;
|
||||||
typedef CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> XprType;
|
typedef CwiseUnaryOp<scalar_conjugate_op<Scalar>, Xpr> XprType;
|
||||||
typedef typename Base::ExtractType ExtractType;
|
typedef typename Base::ExtractType ExtractType;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -188,12 +189,13 @@ struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> >
|
|||||||
};
|
};
|
||||||
|
|
||||||
// pop scalar multiple
|
// pop scalar multiple
|
||||||
template<typename Scalar, typename NestedXpr>
|
template<typename Scalar, typename Xpr>
|
||||||
struct blas_traits<CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> >
|
struct blas_traits<CwiseUnaryOp<scalar_multiple_op<Scalar>, Xpr> >
|
||||||
: blas_traits<NestedXpr>
|
: blas_traits<typename internal::remove_all<typename Xpr::Nested>::type>
|
||||||
{
|
{
|
||||||
|
typedef typename internal::remove_all<typename Xpr::Nested>::type NestedXpr;
|
||||||
typedef blas_traits<NestedXpr> Base;
|
typedef blas_traits<NestedXpr> Base;
|
||||||
typedef CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> XprType;
|
typedef CwiseUnaryOp<scalar_multiple_op<Scalar>, Xpr> XprType;
|
||||||
typedef typename Base::ExtractType ExtractType;
|
typedef typename Base::ExtractType ExtractType;
|
||||||
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||||
static inline Scalar extractScalarFactor(const XprType& x)
|
static inline Scalar extractScalarFactor(const XprType& x)
|
||||||
@ -201,12 +203,13 @@ struct blas_traits<CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> >
|
|||||||
};
|
};
|
||||||
|
|
||||||
// pop opposite
|
// pop opposite
|
||||||
template<typename Scalar, typename NestedXpr>
|
template<typename Scalar, typename Xpr>
|
||||||
struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> >
|
struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, Xpr> >
|
||||||
: blas_traits<NestedXpr>
|
: blas_traits<typename internal::remove_all<typename Xpr::Nested>::type>
|
||||||
{
|
{
|
||||||
|
typedef typename internal::remove_all<typename Xpr::Nested>::type NestedXpr;
|
||||||
typedef blas_traits<NestedXpr> Base;
|
typedef blas_traits<NestedXpr> Base;
|
||||||
typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType;
|
typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, Xpr> XprType;
|
||||||
typedef typename Base::ExtractType ExtractType;
|
typedef typename Base::ExtractType ExtractType;
|
||||||
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||||
static inline Scalar extractScalarFactor(const XprType& x)
|
static inline Scalar extractScalarFactor(const XprType& x)
|
||||||
@ -214,13 +217,14 @@ struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> >
|
|||||||
};
|
};
|
||||||
|
|
||||||
// pop/push transpose
|
// pop/push transpose
|
||||||
template<typename NestedXpr>
|
template<typename Xpr>
|
||||||
struct blas_traits<Transpose<NestedXpr> >
|
struct blas_traits<Transpose<Xpr> >
|
||||||
: blas_traits<NestedXpr>
|
: blas_traits<typename internal::remove_all<typename Xpr::Nested>::type>
|
||||||
{
|
{
|
||||||
|
typedef typename internal::remove_all<typename Xpr::Nested>::type NestedXpr;
|
||||||
typedef typename NestedXpr::Scalar Scalar;
|
typedef typename NestedXpr::Scalar Scalar;
|
||||||
typedef blas_traits<NestedXpr> Base;
|
typedef blas_traits<NestedXpr> Base;
|
||||||
typedef Transpose<NestedXpr> XprType;
|
typedef Transpose<Xpr> XprType;
|
||||||
typedef Transpose<const typename Base::_ExtractType> ExtractType; // const to get rid of a compile error; anyway blas traits are only used on the RHS
|
typedef Transpose<const typename Base::_ExtractType> ExtractType; // const to get rid of a compile error; anyway blas traits are only used on the RHS
|
||||||
typedef Transpose<const typename Base::_ExtractType> _ExtractType;
|
typedef Transpose<const typename Base::_ExtractType> _ExtractType;
|
||||||
typedef typename conditional<bool(Base::HasUsableDirectAccess),
|
typedef typename conditional<bool(Base::HasUsableDirectAccess),
|
||||||
|
@ -178,4 +178,12 @@ template<typename MatrixType> void product(const MatrixType& m)
|
|||||||
// CwiseUnaryOp
|
// CwiseUnaryOp
|
||||||
VERIFY_IS_APPROX(x = Scalar(1.)*(A*x), A*z);
|
VERIFY_IS_APPROX(x = Scalar(1.)*(A*x), A*z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// regression for blas_trais
|
||||||
|
{
|
||||||
|
VERIFY_IS_APPROX(square * (square*square).transpose(), square * square.transpose() * square.transpose());
|
||||||
|
VERIFY_IS_APPROX(square * (-(square*square)), -square * square * square);
|
||||||
|
VERIFY_IS_APPROX(square * (s1*(square*square)), s1 * square * square * square);
|
||||||
|
VERIFY_IS_APPROX(square * (square*square).conjugate(), square * square.conjugate() * square.conjugate());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user