mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-08 17:59:00 +08:00
Add a NoPreferredStorageOrderBit flag for expression having no preferred storage order.
It is currently only used in Product.
This commit is contained in:
parent
f0648f8860
commit
ae039dde13
@ -30,7 +30,7 @@ class DiagonalBase : public EigenBase<Derived>
|
|||||||
MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
||||||
MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
|
||||||
IsVectorAtCompileTime = 0,
|
IsVectorAtCompileTime = 0,
|
||||||
Flags = 0
|
Flags = NoPreferredStorageOrderBit
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, 0, MaxRowsAtCompileTime, MaxColsAtCompileTime> DenseMatrixType;
|
typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, 0, MaxRowsAtCompileTime, MaxColsAtCompileTime> DenseMatrixType;
|
||||||
@ -159,7 +159,7 @@ struct traits<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> >
|
|||||||
typedef Dense StorageKind;
|
typedef Dense StorageKind;
|
||||||
typedef DenseIndex Index;
|
typedef DenseIndex Index;
|
||||||
enum {
|
enum {
|
||||||
Flags = LvalueBit
|
Flags = LvalueBit | NoPreferredStorageOrderBit
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ struct traits<DiagonalWrapper<_DiagonalVectorType> >
|
|||||||
ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
||||||
MaxRowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
MaxRowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
||||||
MaxColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
MaxColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
|
||||||
Flags = traits<DiagonalVectorType>::Flags & LvalueBit
|
Flags = (traits<DiagonalVectorType>::Flags & LvalueBit) | NoPreferredStorageOrderBit
|
||||||
#ifndef EIGEN_TEST_EVALUATORS
|
#ifndef EIGEN_TEST_EVALUATORS
|
||||||
,
|
,
|
||||||
CoeffReadCost = traits<_DiagonalVectorType>::CoeffReadCost
|
CoeffReadCost = traits<_DiagonalVectorType>::CoeffReadCost
|
||||||
|
@ -82,7 +82,10 @@ struct traits<Product<Lhs, Rhs, Option> >
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The storage order is somewhat arbitrary here. The correct one will be determined through the evaluator.
|
// The storage order is somewhat arbitrary here. The correct one will be determined through the evaluator.
|
||||||
Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0)
|
Flags = ( MaxRowsAtCompileTime==1
|
||||||
|
|| ((LhsCleaned::Flags&NoPreferredStorageOrderBit) && (RhsCleaned::Flags&RowMajorBit))
|
||||||
|
|| ((RhsCleaned::Flags&NoPreferredStorageOrderBit) && (LhsCleaned::Flags&RowMajorBit)) )
|
||||||
|
? RowMajorBit : (MaxColsAtCompileTime==1 ? 0 : NoPreferredStorageOrderBit)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -156,6 +159,16 @@ public:
|
|||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
|
#ifdef EIGEN_TEST_EVALUATORS
|
||||||
|
// Generic API dispatcher
|
||||||
|
template<typename Lhs, typename Rhs, int Option, typename StorageKind>
|
||||||
|
class ProductImpl : public internal::generic_xpr_base<Product<Lhs,Rhs,Option>, MatrixXpr, StorageKind>::type
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef typename internal::generic_xpr_base<Product<Lhs,Rhs,Option>, MatrixXpr, StorageKind>::type Base;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename Lhs, typename Rhs, int Option>
|
template<typename Lhs, typename Rhs, int Option>
|
||||||
class ProductImpl<Lhs,Rhs,Option,Dense>
|
class ProductImpl<Lhs,Rhs,Option,Dense>
|
||||||
: public internal::dense_product_base<Lhs,Rhs,Option>
|
: public internal::dense_product_base<Lhs,Rhs,Option>
|
||||||
|
@ -154,6 +154,16 @@ const unsigned int AlignedBit = 0x80;
|
|||||||
|
|
||||||
const unsigned int NestByRefBit = 0x100;
|
const unsigned int NestByRefBit = 0x100;
|
||||||
|
|
||||||
|
/** \ingroup flags
|
||||||
|
*
|
||||||
|
* for an expression, this means that the storage order
|
||||||
|
* can be either row-major or column-major.
|
||||||
|
* The precise choice will be decided at evaluation time or when
|
||||||
|
* combined with other expressions.
|
||||||
|
* \sa \ref RowMajorBit, \ref TopicStorageOrders */
|
||||||
|
const unsigned int NoPreferredStorageOrderBit = 0x200;
|
||||||
|
|
||||||
|
|
||||||
// list of flags that are inherited by default
|
// list of flags that are inherited by default
|
||||||
const unsigned int HereditaryBits = RowMajorBit
|
const unsigned int HereditaryBits = RowMajorBit
|
||||||
| EvalBeforeNestingBit
|
| EvalBeforeNestingBit
|
||||||
|
@ -220,7 +220,7 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src)
|
|||||||
for (Index j=0; j<outerSize; ++j)
|
for (Index j=0; j<outerSize; ++j)
|
||||||
{
|
{
|
||||||
temp.startVec(j);
|
temp.startVec(j);
|
||||||
for (typename SrcEvaluatorType::InnerIterator it(src, j); it; ++it)
|
for (typename SrcEvaluatorType::InnerIterator it(srcEvaluator, j); it; ++it)
|
||||||
{
|
{
|
||||||
Scalar v = it.value();
|
Scalar v = it.value();
|
||||||
temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
|
temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
|
||||||
|
@ -1123,7 +1123,7 @@ EIGEN_DONT_INLINE SparseMatrix<Scalar,_Options,_Index>& SparseMatrix<Scalar,_Opt
|
|||||||
EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
|
EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
|
||||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
||||||
|
|
||||||
const bool needToTranspose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit);
|
const bool needToTranspose = (Flags & RowMajorBit) != (internal::evaluator<OtherDerived>::Flags & RowMajorBit);
|
||||||
if (needToTranspose)
|
if (needToTranspose)
|
||||||
{
|
{
|
||||||
// two passes algorithm:
|
// two passes algorithm:
|
||||||
|
@ -149,7 +149,7 @@ template<typename T> struct plain_matrix_type<T,Sparse>
|
|||||||
{
|
{
|
||||||
typedef typename traits<T>::Scalar _Scalar;
|
typedef typename traits<T>::Scalar _Scalar;
|
||||||
typedef typename traits<T>::Index _Index;
|
typedef typename traits<T>::Index _Index;
|
||||||
enum { _Options = ((traits<T>::Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor };
|
enum { _Options = ((evaluator<T>::Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor };
|
||||||
public:
|
public:
|
||||||
typedef SparseMatrix<_Scalar, _Options, _Index> type;
|
typedef SparseMatrix<_Scalar, _Options, _Index> type;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user