mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
* Refactoring of the class hierarchy: introduction of DenseDirectAccessBase, removal of extra _Base/_Options template parameters.
* Introduction of strides-at-compile-time so for example the optimized code really knows when it needs to evaluate to a temporary * StorageKind / XprKind * Quaternion::setFromTwoVectors: use JacobiSVD instead of SVD * ComplexSchur: support the 1x1 case
This commit is contained in:
@@ -61,22 +61,36 @@ template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessSta
|
||||
struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> > : ei_traits<MatrixType>
|
||||
{
|
||||
typedef typename ei_traits<MatrixType>::Scalar Scalar;
|
||||
typedef typename ei_traits<MatrixType>::StorageKind StorageKind;
|
||||
typedef typename ei_traits<MatrixType>::XprKind XprKind;
|
||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
enum{
|
||||
RowsAtCompileTime = BlockRows,
|
||||
ColsAtCompileTime = BlockCols,
|
||||
MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1
|
||||
: (BlockRows==Dynamic ? int(ei_traits<MatrixType>::MaxRowsAtCompileTime) : BlockRows),
|
||||
MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1
|
||||
: (BlockCols==Dynamic ? int(ei_traits<MatrixType>::MaxColsAtCompileTime) : BlockCols),
|
||||
MatrixRows = ei_traits<MatrixType>::RowsAtCompileTime,
|
||||
MatrixCols = ei_traits<MatrixType>::ColsAtCompileTime,
|
||||
RowsAtCompileTime = MatrixRows == 0 ? 0 : BlockRows,
|
||||
ColsAtCompileTime = MatrixCols == 0 ? 0 : BlockCols,
|
||||
MaxRowsAtCompileTime = BlockRows==0 ? 0
|
||||
: RowsAtCompileTime != Dynamic ? int(RowsAtCompileTime)
|
||||
: int(ei_traits<MatrixType>::MaxRowsAtCompileTime),
|
||||
MaxColsAtCompileTime = BlockCols==0 ? 0
|
||||
: ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime)
|
||||
: int(ei_traits<MatrixType>::MaxColsAtCompileTime),
|
||||
MatrixTypeIsRowMajor = (int(ei_traits<MatrixType>::Flags)&RowMajorBit) != 0,
|
||||
IsRowMajor = (BlockRows==1&&BlockCols!=1) ? 1
|
||||
: (BlockCols==1&&BlockRows!=1) ? 0
|
||||
IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
|
||||
: (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
|
||||
: MatrixTypeIsRowMajor,
|
||||
InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
|
||||
HasSameStorageOrderAsMatrixType = (IsRowMajor == MatrixTypeIsRowMajor),
|
||||
InnerSize = MatrixTypeIsRowMajor // notice how it's MatrixTypeIsRowMajor here, not IsRowMajor. Inner size is computed wrt the host matrix's storage order.
|
||||
? int(ColsAtCompileTime) : int(RowsAtCompileTime),
|
||||
InnerStrideAtCompileTime = HasSameStorageOrderAsMatrixType
|
||||
? int(ei_inner_stride_at_compile_time<MatrixType>::ret)
|
||||
: int(ei_outer_stride_at_compile_time<MatrixType>::ret),
|
||||
OuterStrideAtCompileTime = HasSameStorageOrderAsMatrixType
|
||||
? int(ei_outer_stride_at_compile_time<MatrixType>::ret)
|
||||
: int(ei_inner_stride_at_compile_time<MatrixType>::ret),
|
||||
MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % ei_packet_traits<Scalar>::size) == 0)
|
||||
&& (IsRowMajor == MatrixTypeIsRowMajor) // check for bad case of row-xpr inside col-major matrix...
|
||||
&& (InnerStrideAtCompileTime == 1)
|
||||
? PacketAccessBit : 0,
|
||||
FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
|
||||
Flags0 = ei_traits<MatrixType>::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit),
|
||||
@@ -86,7 +100,7 @@ struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> >
|
||||
};
|
||||
|
||||
template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessStatus> class Block
|
||||
: public MatrixType::template MakeBase< Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> >::Type
|
||||
: public ei_dense_xpr_base<Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> >::type
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -217,12 +231,11 @@ template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessSta
|
||||
/** \internal */
|
||||
template<typename MatrixType, int BlockRows, int BlockCols>
|
||||
class Block<MatrixType,BlockRows,BlockCols,HasDirectAccess>
|
||||
: public MapBase<Block<MatrixType, BlockRows, BlockCols,HasDirectAccess>,
|
||||
typename MatrixType::template MakeBase< Block<MatrixType, BlockRows, BlockCols,HasDirectAccess> >::Type>
|
||||
: public MapBase<Block<MatrixType, BlockRows, BlockCols,HasDirectAccess> >
|
||||
{
|
||||
public:
|
||||
|
||||
typedef MapBase<Block, typename MatrixType::template MakeBase<Block>::Type> Base;
|
||||
typedef MapBase<Block> Base;
|
||||
EIGEN_DENSE_PUBLIC_INTERFACE(Block)
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
||||
@@ -268,15 +281,17 @@ class Block<MatrixType,BlockRows,BlockCols,HasDirectAccess>
|
||||
/** \sa MapBase::innerStride() */
|
||||
inline int innerStride() const
|
||||
{
|
||||
return RowsAtCompileTime==1 ? m_matrix.colStride()
|
||||
: ColsAtCompileTime==1 ? m_matrix.rowStride()
|
||||
: m_matrix.innerStride();
|
||||
return ei_traits<Block>::HasSameStorageOrderAsMatrixType
|
||||
? m_matrix.innerStride()
|
||||
: m_matrix.outerStride();
|
||||
}
|
||||
|
||||
|
||||
/** \sa MapBase::outerStride() */
|
||||
inline int outerStride() const
|
||||
{
|
||||
return IsVectorAtCompileTime ? this->size() : m_matrix.outerStride();
|
||||
return ei_traits<Block>::HasSameStorageOrderAsMatrixType
|
||||
? m_matrix.outerStride()
|
||||
: m_matrix.innerStride();
|
||||
}
|
||||
|
||||
#ifndef __SUNPRO_CC
|
||||
|
||||
Reference in New Issue
Block a user