mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-11-27 06:30:28 +08:00
bug #54 - really fix const correctness except in Sparse
This commit is contained in:
parent
3b6d97b51a
commit
75b7d98665
@ -130,7 +130,7 @@ template<typename _MatrixType, int _UpLo> class LDLT
|
||||
}
|
||||
|
||||
/** \returns the coefficients of the diagonal matrix D */
|
||||
inline Diagonal<MatrixType,0> vectorD(void) const
|
||||
inline Diagonal<const MatrixType> vectorD(void) const
|
||||
{
|
||||
eigen_assert(m_isInitialized && "LDLT is not initialized.");
|
||||
return m_matrix.diagonal();
|
||||
|
@ -91,6 +91,7 @@ template<typename Derived> class ArrayBase
|
||||
using Base::operator/=;
|
||||
|
||||
typedef typename Base::CoeffReturnType CoeffReturnType;
|
||||
|
||||
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||
|
||||
#ifndef EIGEN_PARSED_BY_DOXYGEN
|
||||
|
@ -132,8 +132,8 @@ class BandMatrix : public EigenBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Opt
|
||||
{ return Block<DataType,1,SizeAtCompileTime>(m_data,supers(),0,1,std::min(rows(),cols())); }
|
||||
|
||||
/** \returns a vector expression of the main diagonal (const version) */
|
||||
inline const Block<DataType,1,SizeAtCompileTime> diagonal() const
|
||||
{ return Block<DataType,1,SizeAtCompileTime>(m_data,supers(),0,1,std::min(rows(),cols())); }
|
||||
inline const Block<const DataType,1,SizeAtCompileTime> diagonal() const
|
||||
{ return Block<const DataType,1,SizeAtCompileTime>(m_data,supers(),0,1,std::min(rows(),cols())); }
|
||||
|
||||
template<int Index> struct DiagonalIntReturnType {
|
||||
enum {
|
||||
@ -172,10 +172,10 @@ class BandMatrix : public EigenBase<BandMatrix<_Scalar,Rows,Cols,Supers,Subs,Opt
|
||||
}
|
||||
|
||||
/** \returns a vector expression of the \a i -th sub or super diagonal */
|
||||
inline const Block<DataType,1,Dynamic> diagonal(Index i) const
|
||||
inline const Block<const DataType,1,Dynamic> diagonal(Index i) const
|
||||
{
|
||||
eigen_assert((i<0 && -i<=subs()) || (i>=0 && i<=supers()));
|
||||
return Block<DataType,1,Dynamic>(m_data, supers()-i, std::max<Index>(0,i), 1, diagonalLength(i));
|
||||
return Block<const DataType,1,Dynamic>(m_data, supers()-i, std::max<Index>(0,i), 1, diagonalLength(i));
|
||||
}
|
||||
|
||||
template<typename Dest> inline void evalTo(Dest& dst) const
|
||||
|
@ -96,9 +96,13 @@ struct traits<Block<XprType, BlockRows, BlockCols, InnerPanel, HasDirectAccess>
|
||||
? PacketAccessBit : 0,
|
||||
MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && ((OuterStrideAtCompileTime % packet_traits<Scalar>::size) == 0)) ? AlignedBit : 0,
|
||||
FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
|
||||
Flags0 = traits<XprType>::Flags & (HereditaryBits | MaskPacketAccessBit | LvalueBit | DirectAccessBit | MaskAlignedBit),
|
||||
Flags1 = Flags0 | FlagsLinearAccessBit,
|
||||
Flags = (Flags1 & ~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0)
|
||||
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
|
||||
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
|
||||
Flags0 = traits<XprType>::Flags & ( (HereditaryBits & ~RowMajorBit) |
|
||||
DirectAccessBit |
|
||||
MaskPacketAccessBit |
|
||||
MaskAlignedBit),
|
||||
Flags = Flags0 | FlagsLinearAccessBit | FlagsLvalueBit | FlagsRowMajorBit
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -162,6 +166,13 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H
|
||||
inline Index cols() const { return m_blockCols.value(); }
|
||||
|
||||
inline Scalar& coeffRef(Index row, Index col)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
||||
return m_xpr.const_cast_derived()
|
||||
.coeffRef(row + m_startRow.value(), col + m_startCol.value());
|
||||
}
|
||||
|
||||
inline const Scalar& coeffRef(Index row, Index col) const
|
||||
{
|
||||
return m_xpr.const_cast_derived()
|
||||
.coeffRef(row + m_startRow.value(), col + m_startCol.value());
|
||||
@ -173,6 +184,14 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H
|
||||
}
|
||||
|
||||
inline Scalar& coeffRef(Index index)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_LVALUE(XprType)
|
||||
return m_xpr.const_cast_derived()
|
||||
.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
||||
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
|
||||
}
|
||||
|
||||
inline const Scalar& coeffRef(Index index) const
|
||||
{
|
||||
return m_xpr.const_cast_derived()
|
||||
.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
|
||||
@ -246,8 +265,8 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true>
|
||||
|
||||
/** Column or Row constructor
|
||||
*/
|
||||
inline Block(const XprType& xpr, Index i)
|
||||
: Base(&xpr.const_cast_derived().coeffRef(
|
||||
inline Block(XprType& xpr, Index i)
|
||||
: Base(&xpr.coeffRef(
|
||||
(BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0,
|
||||
(BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
|
||||
BlockRows==1 ? 1 : xpr.rows(),
|
||||
@ -262,8 +281,8 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true>
|
||||
|
||||
/** Fixed-size constructor
|
||||
*/
|
||||
inline Block(const XprType& xpr, Index startRow, Index startCol)
|
||||
: Base(&xpr.const_cast_derived().coeffRef(startRow,startCol)), m_xpr(xpr)
|
||||
inline Block(XprType& xpr, Index startRow, Index startCol)
|
||||
: Base(&xpr.coeffRef(startRow,startCol)), m_xpr(xpr)
|
||||
{
|
||||
eigen_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows()
|
||||
&& startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= xpr.cols());
|
||||
@ -272,10 +291,10 @@ class Block<XprType,BlockRows,BlockCols, InnerPanel,true>
|
||||
|
||||
/** Dynamic-size constructor
|
||||
*/
|
||||
inline Block(const XprType& xpr,
|
||||
inline Block(XprType& xpr,
|
||||
Index startRow, Index startCol,
|
||||
Index blockRows, Index blockCols)
|
||||
: Base(&xpr.const_cast_derived().coeffRef(startRow,startCol), blockRows, blockCols),
|
||||
: Base(&xpr.coeffRef(startRow,startCol), blockRows, blockCols),
|
||||
m_xpr(xpr)
|
||||
{
|
||||
eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows)
|
||||
|
@ -172,6 +172,8 @@ template<typename Derived> class DenseBase
|
||||
OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret
|
||||
};
|
||||
|
||||
enum { ThisConstantIsPrivateInPlainObjectBase };
|
||||
|
||||
/** \returns the number of nonzero coefficients which is in practice the number
|
||||
* of stored coefficients. */
|
||||
inline Index nonZeros() const { return size(); }
|
||||
@ -273,7 +275,8 @@ template<typename Derived> class DenseBase
|
||||
CommaInitializer<Derived> operator<< (const DenseBase<OtherDerived>& other);
|
||||
|
||||
Eigen::Transpose<Derived> transpose();
|
||||
const Eigen::Transpose<Derived> transpose() const;
|
||||
typedef const Transpose<const Derived> ConstTransposeReturnType;
|
||||
ConstTransposeReturnType transpose() const;
|
||||
void transposeInPlace();
|
||||
#ifndef EIGEN_NO_DEBUG
|
||||
protected:
|
||||
@ -282,41 +285,28 @@ template<typename Derived> class DenseBase
|
||||
public:
|
||||
#endif
|
||||
|
||||
VectorBlock<Derived> segment(Index start, Index size);
|
||||
const VectorBlock<Derived> segment(Index start, Index size) const;
|
||||
typedef VectorBlock<Derived> SegmentReturnType;
|
||||
typedef const VectorBlock<const Derived> ConstSegmentReturnType;
|
||||
template<int Size> struct FixedSegmentReturnType { typedef VectorBlock<Derived, Size> Type; };
|
||||
template<int Size> struct ConstFixedSegmentReturnType { typedef const VectorBlock<const Derived, Size> Type; };
|
||||
|
||||
SegmentReturnType segment(Index start, Index size);
|
||||
ConstSegmentReturnType segment(Index start, Index size) const;
|
||||
|
||||
VectorBlock<Derived> head(Index size);
|
||||
const VectorBlock<Derived> head(Index size) const;
|
||||
SegmentReturnType head(Index size);
|
||||
ConstSegmentReturnType head(Index size) const;
|
||||
|
||||
VectorBlock<Derived> tail(Index size);
|
||||
const VectorBlock<Derived> tail(Index size) const;
|
||||
SegmentReturnType tail(Index size);
|
||||
ConstSegmentReturnType tail(Index size) const;
|
||||
|
||||
template<int Size> VectorBlock<Derived,Size> head(void);
|
||||
template<int Size> const VectorBlock<Derived,Size> head() const;
|
||||
template<int Size> typename FixedSegmentReturnType<Size>::Type head();
|
||||
template<int Size> typename ConstFixedSegmentReturnType<Size>::Type head() const;
|
||||
|
||||
template<int Size> VectorBlock<Derived,Size> tail();
|
||||
template<int Size> const VectorBlock<Derived,Size> tail() const;
|
||||
template<int Size> typename FixedSegmentReturnType<Size>::Type tail();
|
||||
template<int Size> typename ConstFixedSegmentReturnType<Size>::Type tail() const;
|
||||
|
||||
template<int Size> VectorBlock<Derived,Size> segment(Index start);
|
||||
template<int Size> const VectorBlock<Derived,Size> segment(Index start) const;
|
||||
|
||||
Diagonal<Derived,0> diagonal();
|
||||
const Diagonal<Derived,0> diagonal() const;
|
||||
|
||||
template<int Index> Diagonal<Derived,Index> diagonal();
|
||||
template<int Index> const Diagonal<Derived,Index> diagonal() const;
|
||||
|
||||
Diagonal<Derived, Dynamic> diagonal(Index index);
|
||||
const Diagonal<Derived, Dynamic> diagonal(Index index) const;
|
||||
|
||||
template<unsigned int Mode> TriangularView<Derived, Mode> part();
|
||||
template<unsigned int Mode> const TriangularView<Derived, Mode> part() const;
|
||||
|
||||
template<unsigned int Mode> TriangularView<Derived, Mode> triangularView();
|
||||
template<unsigned int Mode> const TriangularView<Derived, Mode> triangularView() const;
|
||||
|
||||
template<unsigned int UpLo> SelfAdjointView<Derived, UpLo> selfadjointView();
|
||||
template<unsigned int UpLo> const SelfAdjointView<Derived, UpLo> selfadjointView() const;
|
||||
template<int Size> typename FixedSegmentReturnType<Size>::Type segment(Index start);
|
||||
template<int Size> typename ConstFixedSegmentReturnType<Size>::Type segment(Index start) const;
|
||||
|
||||
static const ConstantReturnType
|
||||
Constant(Index rows, Index cols, const Scalar& value);
|
||||
@ -389,8 +379,25 @@ template<typename Derived> class DenseBase
|
||||
return typename internal::eval<Derived>::type(derived());
|
||||
}
|
||||
|
||||
/** swaps *this with the expression \a other.
|
||||
*
|
||||
*/
|
||||
template<typename OtherDerived>
|
||||
void swap(DenseBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
|
||||
void swap(const DenseBase<OtherDerived>& other,
|
||||
int = OtherDerived::ThisConstantIsPrivateInPlainObjectBase)
|
||||
{
|
||||
SwapWrapper<Derived>(derived()).lazyAssign(other.derived());
|
||||
}
|
||||
|
||||
/** swaps *this with the matrix or array \a other.
|
||||
*
|
||||
*/
|
||||
template<typename OtherDerived>
|
||||
void swap(PlainObjectBase<OtherDerived>& other)
|
||||
{
|
||||
SwapWrapper<Derived>(derived()).lazyAssign(other.derived());
|
||||
}
|
||||
|
||||
|
||||
inline const NestByValue<Derived> nestByValue() const;
|
||||
inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;
|
||||
@ -436,10 +443,15 @@ template<typename Derived> class DenseBase
|
||||
bool any(void) const;
|
||||
Index count() const;
|
||||
|
||||
const VectorwiseOp<Derived,Horizontal> rowwise() const;
|
||||
VectorwiseOp<Derived,Horizontal> rowwise();
|
||||
const VectorwiseOp<Derived,Vertical> colwise() const;
|
||||
VectorwiseOp<Derived,Vertical> colwise();
|
||||
typedef VectorwiseOp<Derived, Horizontal> RowwiseReturnType;
|
||||
typedef const VectorwiseOp<const Derived, Horizontal> ConstRowwiseReturnType;
|
||||
typedef VectorwiseOp<Derived, Vertical> ColwiseReturnType;
|
||||
typedef const VectorwiseOp<const Derived, Vertical> ConstColwiseReturnType;
|
||||
|
||||
ConstRowwiseReturnType rowwise() const;
|
||||
RowwiseReturnType rowwise();
|
||||
ConstColwiseReturnType colwise() const;
|
||||
ColwiseReturnType colwise();
|
||||
|
||||
static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index rows, Index cols);
|
||||
static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index size);
|
||||
@ -464,8 +476,10 @@ template<typename Derived> class DenseBase
|
||||
const Replicate<Derived,RowFactor,ColFactor> replicate() const;
|
||||
const Replicate<Derived,Dynamic,Dynamic> replicate(Index rowFacor,Index colFactor) const;
|
||||
|
||||
Eigen::Reverse<Derived, BothDirections> reverse();
|
||||
const Eigen::Reverse<Derived, BothDirections> reverse() const;
|
||||
typedef Reverse<Derived, BothDirections> ReverseReturnType;
|
||||
typedef const Reverse<const Derived, BothDirections> ConstReverseReturnType;
|
||||
ReverseReturnType reverse();
|
||||
ConstReverseReturnType reverse() const;
|
||||
void reverseInPlace();
|
||||
|
||||
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
|
||||
|
@ -64,7 +64,8 @@ struct traits<Diagonal<MatrixType,DiagIndex> >
|
||||
MatrixType::MaxColsAtCompileTime)
|
||||
: (EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) - AbsDiagIndex),
|
||||
MaxColsAtCompileTime = 1,
|
||||
Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit | LvalueBit | DirectAccessBit) & ~RowMajorBit,
|
||||
MaskLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
|
||||
Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit | MaskLvalueBit | DirectAccessBit) & ~RowMajorBit,
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost,
|
||||
MatrixTypeOuterStride = outer_stride_at_compile_time<MatrixType>::ret,
|
||||
InnerStrideAtCompileTime = MatrixTypeOuterStride == Dynamic ? Dynamic : MatrixTypeOuterStride+1,
|
||||
@ -105,6 +106,11 @@ template<typename MatrixType, int DiagIndex> class Diagonal
|
||||
return m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset());
|
||||
}
|
||||
|
||||
inline const Scalar& coeffRef(Index row, Index) const
|
||||
{
|
||||
return m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset());
|
||||
}
|
||||
|
||||
inline CoeffReturnType coeff(Index row, Index) const
|
||||
{
|
||||
return m_matrix.coeff(row+rowOffset(), row+colOffset());
|
||||
@ -115,6 +121,11 @@ template<typename MatrixType, int DiagIndex> class Diagonal
|
||||
return m_matrix.const_cast_derived().coeffRef(index+rowOffset(), index+colOffset());
|
||||
}
|
||||
|
||||
inline const Scalar& coeffRef(Index index) const
|
||||
{
|
||||
return m_matrix.const_cast_derived().coeffRef(index+rowOffset(), index+colOffset());
|
||||
}
|
||||
|
||||
inline CoeffReturnType coeff(Index index) const
|
||||
{
|
||||
return m_matrix.coeff(index+rowOffset(), index+colOffset());
|
||||
@ -143,18 +154,18 @@ template<typename MatrixType, int DiagIndex> class Diagonal
|
||||
*
|
||||
* \sa class Diagonal */
|
||||
template<typename Derived>
|
||||
inline Diagonal<Derived, 0>
|
||||
inline typename MatrixBase<Derived>::DiagonalReturnType
|
||||
MatrixBase<Derived>::diagonal()
|
||||
{
|
||||
return Diagonal<Derived, 0>(derived());
|
||||
return derived();
|
||||
}
|
||||
|
||||
/** This is the const version of diagonal(). */
|
||||
template<typename Derived>
|
||||
inline const Diagonal<Derived, 0>
|
||||
inline const typename MatrixBase<Derived>::ConstDiagonalReturnType
|
||||
MatrixBase<Derived>::diagonal() const
|
||||
{
|
||||
return Diagonal<Derived, 0>(derived());
|
||||
return derived();
|
||||
}
|
||||
|
||||
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
|
||||
@ -169,18 +180,18 @@ MatrixBase<Derived>::diagonal() const
|
||||
*
|
||||
* \sa MatrixBase::diagonal(), class Diagonal */
|
||||
template<typename Derived>
|
||||
inline Diagonal<Derived, Dynamic>
|
||||
inline typename MatrixBase<Derived>::template DiagonalIndexReturnType<Dynamic>::Type
|
||||
MatrixBase<Derived>::diagonal(Index index)
|
||||
{
|
||||
return Diagonal<Derived, Dynamic>(derived(), index);
|
||||
return typename DiagonalIndexReturnType<Dynamic>::Type(derived(), index);
|
||||
}
|
||||
|
||||
/** This is the const version of diagonal(Index). */
|
||||
template<typename Derived>
|
||||
inline const Diagonal<Derived, Dynamic>
|
||||
inline typename MatrixBase<Derived>::template ConstDiagonalIndexReturnType<Dynamic>::Type
|
||||
MatrixBase<Derived>::diagonal(Index index) const
|
||||
{
|
||||
return Diagonal<Derived, Dynamic>(derived(), index);
|
||||
return typename ConstDiagonalIndexReturnType<Dynamic>::Type(derived(), index);
|
||||
}
|
||||
|
||||
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
|
||||
@ -195,20 +206,20 @@ MatrixBase<Derived>::diagonal(Index index) const
|
||||
*
|
||||
* \sa MatrixBase::diagonal(), class Diagonal */
|
||||
template<typename Derived>
|
||||
template<int DiagIndex>
|
||||
inline Diagonal<Derived,DiagIndex>
|
||||
template<int Index>
|
||||
inline typename MatrixBase<Derived>::template DiagonalIndexReturnType<Index>::Type
|
||||
MatrixBase<Derived>::diagonal()
|
||||
{
|
||||
return Diagonal<Derived,DiagIndex>(derived());
|
||||
return derived();
|
||||
}
|
||||
|
||||
/** This is the const version of diagonal<int>(). */
|
||||
template<typename Derived>
|
||||
template<int DiagIndex>
|
||||
inline const Diagonal<Derived,DiagIndex>
|
||||
template<int Index>
|
||||
inline typename MatrixBase<Derived>::template ConstDiagonalIndexReturnType<Index>::Type
|
||||
MatrixBase<Derived>::diagonal() const
|
||||
{
|
||||
return Diagonal<Derived,DiagIndex>(derived());
|
||||
return derived();
|
||||
}
|
||||
|
||||
#endif // EIGEN_DIAGONAL_H
|
||||
|
@ -51,6 +51,8 @@ template<typename Derived> struct EigenBase
|
||||
|
||||
inline Derived& const_cast_derived() const
|
||||
{ return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
|
||||
inline const Derived& const_derived() const
|
||||
{ return *static_cast<const Derived*>(this); }
|
||||
|
||||
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
|
||||
inline Index rows() const { return derived().rows(); }
|
||||
|
@ -80,9 +80,9 @@
|
||||
namespace internal {
|
||||
template<typename PlainObjectType, int MapOptions, typename StrideType>
|
||||
struct traits<Map<PlainObjectType, MapOptions, StrideType> >
|
||||
: public traits<typename internal::remove_const<PlainObjectType>::type>
|
||||
: public traits<PlainObjectType>
|
||||
{
|
||||
typedef traits<typename internal::remove_const<PlainObjectType>::type> TraitsBase;
|
||||
typedef traits<PlainObjectType> TraitsBase;
|
||||
typedef typename PlainObjectType::Index Index;
|
||||
typedef typename PlainObjectType::Scalar Scalar;
|
||||
enum {
|
||||
@ -106,7 +106,7 @@ struct traits<Map<PlainObjectType, MapOptions, StrideType> >
|
||||
Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit),
|
||||
Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime))
|
||||
? int(Flags1) : int(Flags1 & ~LinearAccessBit),
|
||||
Flags3 = internal::is_const<PlainObjectType>::value ? (int(Flags2) & ~LvalueBit) : int(Flags2),
|
||||
Flags3 = is_lvalue<PlainObjectType>::value ? int(Flags2) : (int(Flags2) & ~LvalueBit),
|
||||
Flags = KeepsPacketAccess ? int(Flags3) : (int(Flags3) & ~PacketAccessBit)
|
||||
};
|
||||
private:
|
||||
|
@ -56,7 +56,7 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
|
||||
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef typename internal::conditional<
|
||||
bool(int(internal::traits<Derived>::Flags) & LvalueBit),
|
||||
bool(internal::is_lvalue<Derived>::value),
|
||||
Scalar *,
|
||||
const Scalar *>::type
|
||||
PointerType;
|
||||
|
@ -93,6 +93,7 @@ template<typename Derived> class MatrixBase
|
||||
using Base::operator/=;
|
||||
|
||||
typedef typename Base::CoeffReturnType CoeffReturnType;
|
||||
typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType;
|
||||
typedef typename Base::RowXpr RowXpr;
|
||||
typedef typename Base::ColXpr ColXpr;
|
||||
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||
@ -128,8 +129,8 @@ template<typename Derived> class MatrixBase
|
||||
typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
|
||||
/** \internal the return type of MatrixBase::adjoint() */
|
||||
typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
|
||||
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Eigen::Transpose<Derived> >,
|
||||
Transpose<Derived>
|
||||
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, ConstTransposeReturnType>,
|
||||
ConstTransposeReturnType
|
||||
>::type AdjointReturnType;
|
||||
/** \internal Return type of eigenvalues() */
|
||||
typedef Matrix<std::complex<RealScalar>, internal::traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType;
|
||||
@ -212,23 +213,34 @@ template<typename Derived> class MatrixBase
|
||||
const AdjointReturnType adjoint() const;
|
||||
void adjointInPlace();
|
||||
|
||||
Diagonal<Derived,0> diagonal();
|
||||
const Diagonal<Derived,0> diagonal() const;
|
||||
typedef Diagonal<Derived> DiagonalReturnType;
|
||||
DiagonalReturnType diagonal();
|
||||
typedef const Diagonal<const Derived> ConstDiagonalReturnType;
|
||||
ConstDiagonalReturnType diagonal() const;
|
||||
|
||||
template<int Index> Diagonal<Derived,Index> diagonal();
|
||||
template<int Index> const Diagonal<Derived,Index> diagonal() const;
|
||||
template<int Index> struct DiagonalIndexReturnType { typedef Diagonal<Derived,Index> Type; };
|
||||
template<int Index> struct ConstDiagonalIndexReturnType { typedef const Diagonal<const Derived,Index> Type; };
|
||||
|
||||
Diagonal<Derived, Dynamic> diagonal(Index index);
|
||||
const Diagonal<Derived, Dynamic> diagonal(Index index) const;
|
||||
template<int Index> typename DiagonalIndexReturnType<Index>::Type diagonal();
|
||||
template<int Index> typename ConstDiagonalIndexReturnType<Index>::Type diagonal() const;
|
||||
|
||||
typename DiagonalIndexReturnType<Dynamic>::Type diagonal(Index index);
|
||||
typename ConstDiagonalIndexReturnType<Dynamic>::Type diagonal(Index index) const;
|
||||
|
||||
template<unsigned int Mode> TriangularView<Derived, Mode> part();
|
||||
template<unsigned int Mode> const TriangularView<Derived, Mode> part() const;
|
||||
|
||||
template<unsigned int Mode> TriangularView<Derived, Mode> triangularView();
|
||||
template<unsigned int Mode> const TriangularView<Derived, Mode> triangularView() const;
|
||||
template<unsigned int Mode> struct TriangularViewReturnType { typedef TriangularView<Derived, Mode> Type; };
|
||||
template<unsigned int Mode> struct ConstTriangularViewReturnType { typedef const TriangularView<const Derived, Mode> Type; };
|
||||
|
||||
template<unsigned int UpLo> SelfAdjointView<Derived, UpLo> selfadjointView();
|
||||
template<unsigned int UpLo> const SelfAdjointView<Derived, UpLo> selfadjointView() const;
|
||||
template<unsigned int Mode> typename TriangularViewReturnType<Mode>::Type triangularView();
|
||||
template<unsigned int Mode> typename ConstTriangularViewReturnType<Mode>::Type triangularView() const;
|
||||
|
||||
template<unsigned int UpLo> struct SelfAdjointViewReturnType { typedef SelfAdjointView<Derived, UpLo> Type; };
|
||||
template<unsigned int UpLo> struct ConstSelfAdjointViewReturnType { typedef const SelfAdjointView<const Derived, UpLo> Type; };
|
||||
|
||||
template<unsigned int UpLo> typename SelfAdjointViewReturnType<UpLo>::Type selfadjointView();
|
||||
template<unsigned int UpLo> typename ConstSelfAdjointViewReturnType<UpLo>::Type selfadjointView() const;
|
||||
|
||||
const SparseView<Derived> sparseView(const Scalar& m_reference = Scalar(0),
|
||||
typename NumTraits<Scalar>::Real m_epsilon = NumTraits<Scalar>::dummy_precision()) const;
|
||||
@ -345,13 +357,13 @@ template<typename Derived> class MatrixBase
|
||||
enum {
|
||||
SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1
|
||||
};
|
||||
typedef Block<Derived,
|
||||
typedef Block<const Derived,
|
||||
internal::traits<Derived>::ColsAtCompileTime==1 ? SizeMinusOne : 1,
|
||||
internal::traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne;
|
||||
internal::traits<Derived>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> ConstStartMinusOne;
|
||||
typedef CwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>,
|
||||
StartMinusOne > HNormalizedReturnType;
|
||||
ConstStartMinusOne > HNormalizedReturnType;
|
||||
|
||||
HNormalizedReturnType hnormalized() const;
|
||||
const HNormalizedReturnType hnormalized() const;
|
||||
|
||||
// put this as separate enum value to work around possible GCC 4.3 bug (?)
|
||||
enum { HomogeneousReturnTypeDirection = ColsAtCompileTime==1?Vertical:Horizontal };
|
||||
|
@ -389,7 +389,7 @@ struct permut_matrix_product_retval
|
||||
|
||||
=
|
||||
|
||||
Block<MatrixTypeNestedCleaned,Side==OnTheLeft ? 1 : MatrixType::RowsAtCompileTime,Side==OnTheRight ? 1 : MatrixType::ColsAtCompileTime>
|
||||
Block<const MatrixTypeNestedCleaned,Side==OnTheLeft ? 1 : MatrixType::RowsAtCompileTime,Side==OnTheRight ? 1 : MatrixType::ColsAtCompileTime>
|
||||
(m_matrix, ((Side==OnTheRight) ^ Transposed) ? m_permutation.indices().coeff(i) : i);
|
||||
}
|
||||
}
|
||||
|
@ -66,15 +66,14 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
using Base::IsVectorAtCompileTime;
|
||||
using Base::Flags;
|
||||
|
||||
typedef typename internal::add_const<Derived>::type ConstDerived;
|
||||
friend class Eigen::Map<Derived, Unaligned>;
|
||||
typedef class Eigen::Map<Derived, Unaligned> MapType;
|
||||
friend class Eigen::Map<ConstDerived, Unaligned>;
|
||||
typedef class Eigen::Map<ConstDerived, Unaligned> ConstMapType;
|
||||
typedef Eigen::Map<Derived, Unaligned> MapType;
|
||||
friend class Eigen::Map<const Derived, Unaligned>;
|
||||
typedef const Eigen::Map<const Derived, Unaligned> ConstMapType;
|
||||
friend class Eigen::Map<Derived, Aligned>;
|
||||
typedef class Eigen::Map<Derived, Aligned> AlignedMapType;
|
||||
friend class Eigen::Map<ConstDerived, Aligned>;
|
||||
typedef class Eigen::Map<ConstDerived, Aligned> ConstAlignedMapType;
|
||||
typedef Eigen::Map<Derived, Aligned> AlignedMapType;
|
||||
friend class Eigen::Map<const Derived, Aligned>;
|
||||
typedef const Eigen::Map<const Derived, Aligned> ConstAlignedMapType;
|
||||
|
||||
protected:
|
||||
DenseStorage<Scalar, Base::MaxSizeAtCompileTime, Base::RowsAtCompileTime, Base::ColsAtCompileTime, Options> m_storage;
|
||||
@ -116,6 +115,19 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
return m_storage.data()[index];
|
||||
}
|
||||
|
||||
EIGEN_STRONG_INLINE const Scalar& coeffRef(Index row, Index col) const
|
||||
{
|
||||
if(Flags & RowMajorBit)
|
||||
return m_storage.data()[col + row * m_storage.cols()];
|
||||
else // column-major
|
||||
return m_storage.data()[row + col * m_storage.rows()];
|
||||
}
|
||||
|
||||
EIGEN_STRONG_INLINE const Scalar& coeffRef(Index index) const
|
||||
{
|
||||
return m_storage.data()[index];
|
||||
}
|
||||
|
||||
template<int LoadMode>
|
||||
EIGEN_STRONG_INLINE PacketScalar packet(Index row, Index col) const
|
||||
{
|
||||
@ -381,28 +393,28 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
* \see class Map
|
||||
*/
|
||||
//@{
|
||||
inline static const ConstMapType Map(const Scalar* data)
|
||||
inline static ConstMapType Map(const Scalar* data)
|
||||
{ return ConstMapType(data); }
|
||||
inline static MapType Map(Scalar* data)
|
||||
{ return MapType(data); }
|
||||
inline static const ConstMapType Map(const Scalar* data, Index size)
|
||||
inline static ConstMapType Map(const Scalar* data, Index size)
|
||||
{ return ConstMapType(data, size); }
|
||||
inline static MapType Map(Scalar* data, Index size)
|
||||
{ return MapType(data, size); }
|
||||
inline static const ConstMapType Map(const Scalar* data, Index rows, Index cols)
|
||||
inline static ConstMapType Map(const Scalar* data, Index rows, Index cols)
|
||||
{ return ConstMapType(data, rows, cols); }
|
||||
inline static MapType Map(Scalar* data, Index rows, Index cols)
|
||||
{ return MapType(data, rows, cols); }
|
||||
|
||||
inline static const ConstAlignedMapType MapAligned(const Scalar* data)
|
||||
inline static ConstAlignedMapType MapAligned(const Scalar* data)
|
||||
{ return ConstAlignedMapType(data); }
|
||||
inline static AlignedMapType MapAligned(Scalar* data)
|
||||
{ return AlignedMapType(data); }
|
||||
inline static const ConstAlignedMapType MapAligned(const Scalar* data, Index size)
|
||||
inline static ConstAlignedMapType MapAligned(const Scalar* data, Index size)
|
||||
{ return ConstAlignedMapType(data, size); }
|
||||
inline static AlignedMapType MapAligned(Scalar* data, Index size)
|
||||
{ return AlignedMapType(data, size); }
|
||||
inline static const ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols)
|
||||
inline static ConstAlignedMapType MapAligned(const Scalar* data, Index rows, Index cols)
|
||||
{ return ConstAlignedMapType(data, rows, cols); }
|
||||
inline static AlignedMapType MapAligned(Scalar* data, Index rows, Index cols)
|
||||
{ return AlignedMapType(data, rows, cols); }
|
||||
@ -536,6 +548,9 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
|
||||
INVALID_MATRIX_TEMPLATE_PARAMETERS)
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
enum { ThisConstantIsPrivateInPlainObjectBase };
|
||||
};
|
||||
|
||||
template <typename Derived, typename OtherDerived, bool IsVector>
|
||||
|
@ -353,7 +353,7 @@ struct gemv_selector<OnTheLeft,StorageOrder,BlasCompatible>
|
||||
Transpose<Dest> destT(dest);
|
||||
enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };
|
||||
gemv_selector<OnTheRight,OtherStorageOrder,BlasCompatible>
|
||||
::run(GeneralProduct<Transpose<typename ProductType::_RhsNested>,Transpose<typename ProductType::_LhsNested>, GemvProduct>
|
||||
::run(GeneralProduct<Transpose<const typename ProductType::_RhsNested>,Transpose<const typename ProductType::_LhsNested>, GemvProduct>
|
||||
(prod.rhs().transpose(), prod.lhs().transpose()), destT, alpha);
|
||||
}
|
||||
};
|
||||
@ -442,8 +442,8 @@ template<> struct gemv_selector<OnTheRight,RowMajor,true>
|
||||
typedef typename ProductType::LhsBlasTraits LhsBlasTraits;
|
||||
typedef typename ProductType::RhsBlasTraits RhsBlasTraits;
|
||||
|
||||
ActualLhsType actualLhs = LhsBlasTraits::extract(prod.lhs());
|
||||
ActualRhsType actualRhs = RhsBlasTraits::extract(prod.rhs());
|
||||
typename add_const<ActualLhsType>::type actualLhs = LhsBlasTraits::extract(prod.lhs());
|
||||
typename add_const<ActualRhsType>::type actualRhs = RhsBlasTraits::extract(prod.rhs());
|
||||
|
||||
ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(prod.lhs())
|
||||
* RhsBlasTraits::extractScalarFactor(prod.rhs());
|
||||
@ -457,7 +457,7 @@ template<> struct gemv_selector<OnTheRight,RowMajor,true>
|
||||
|
||||
RhsScalar* rhs_data;
|
||||
if (DirectlyUseRhs)
|
||||
rhs_data = &actualRhs.const_cast_derived().coeffRef(0);
|
||||
rhs_data = const_cast<RhsScalar*>(&actualRhs.coeffRef(0));
|
||||
else
|
||||
{
|
||||
rhs_data = ei_aligned_stack_new(RhsScalar, actualRhs.size());
|
||||
@ -467,7 +467,7 @@ template<> struct gemv_selector<OnTheRight,RowMajor,true>
|
||||
general_matrix_vector_product
|
||||
<Index,LhsScalar,RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsBlasTraits::NeedToConjugate>::run(
|
||||
actualLhs.rows(), actualLhs.cols(),
|
||||
&actualLhs.const_cast_derived().coeffRef(0,0), actualLhs.outerStride(),
|
||||
&actualLhs.coeffRef(0,0), actualLhs.outerStride(),
|
||||
rhs_data, 1,
|
||||
&dest.coeffRef(0,0), dest.innerStride(),
|
||||
actualAlpha);
|
||||
|
@ -81,7 +81,7 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
|
||||
inline explicit Replicate(const OriginalMatrixType& matrix)
|
||||
: m_matrix(matrix), m_rowFactor(RowFactor), m_colFactor(ColFactor)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT((internal::is_same<MatrixType,OriginalMatrixType>::value),
|
||||
EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
|
||||
THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
|
||||
eigen_assert(RowFactor!=Dynamic && ColFactor!=Dynamic);
|
||||
}
|
||||
@ -90,7 +90,7 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
|
||||
inline Replicate(const OriginalMatrixType& matrix, int rowFactor, int colFactor)
|
||||
: m_matrix(matrix), m_rowFactor(rowFactor), m_colFactor(colFactor)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT((internal::is_same<MatrixType,OriginalMatrixType>::value),
|
||||
EIGEN_STATIC_ASSERT((internal::is_same<typename internal::remove_const<MatrixType>::type,OriginalMatrixType>::value),
|
||||
THE_MATRIX_OR_EXPRESSION_THAT_YOU_PASSED_DOES_NOT_HAVE_THE_EXPECTED_TYPE)
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ template<typename MatrixType, int Direction> class Reverse
|
||||
*
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline Reverse<Derived, BothDirections>
|
||||
inline typename DenseBase<Derived>::ReverseReturnType
|
||||
DenseBase<Derived>::reverse()
|
||||
{
|
||||
return derived();
|
||||
@ -202,7 +202,7 @@ DenseBase<Derived>::reverse()
|
||||
|
||||
/** This is the const version of reverse(). */
|
||||
template<typename Derived>
|
||||
inline const Reverse<Derived, BothDirections>
|
||||
inline const typename DenseBase<Derived>::ConstReverseReturnType
|
||||
DenseBase<Derived>::reverse() const
|
||||
{
|
||||
return derived();
|
||||
@ -216,7 +216,7 @@ DenseBase<Derived>::reverse() const
|
||||
* the following additional features:
|
||||
* - less error prone: doing the same operation with .reverse() requires special care:
|
||||
* \code m = m.reverse().eval(); \endcode
|
||||
* - no temporary object is created (currently there is one created but could be avoided using swap)
|
||||
* - this API allows to avoid creating a temporary (the current implementation creates a temporary, but that could be avoided using swap)
|
||||
* - it allows future optimizations (cache friendliness, etc.)
|
||||
*
|
||||
* \sa reverse() */
|
||||
|
@ -282,14 +282,16 @@ struct triangular_assignment_selector<Derived1, Derived2, SelfAdjoint|Lower, Dyn
|
||||
|
||||
template<typename Derived>
|
||||
template<unsigned int UpLo>
|
||||
const SelfAdjointView<Derived, UpLo> MatrixBase<Derived>::selfadjointView() const
|
||||
typename MatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type
|
||||
MatrixBase<Derived>::selfadjointView() const
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
template<unsigned int UpLo>
|
||||
SelfAdjointView<Derived, UpLo> MatrixBase<Derived>::selfadjointView()
|
||||
typename MatrixBase<Derived>::template SelfAdjointViewReturnType<UpLo>::Type
|
||||
MatrixBase<Derived>::selfadjointView()
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
|
@ -77,12 +77,22 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp
|
||||
// TODO make Assign use .data()
|
||||
inline Scalar& coeffRef(Index row, Index col)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_LVALUE(Lhs)
|
||||
return m_matrix.const_cast_derived().coeffRef(row, col);
|
||||
}
|
||||
inline const Scalar& coeffRef(Index row, Index col) const
|
||||
{
|
||||
return m_matrix.coeffRef(row, col);
|
||||
}
|
||||
|
||||
// note that this function is needed by assign to correctly align loads/stores
|
||||
// TODO make Assign use .data()
|
||||
inline Scalar& coeffRef(Index index)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_LVALUE(Lhs)
|
||||
return m_matrix.const_cast_derived().coeffRef(index);
|
||||
}
|
||||
inline const Scalar& coeffRef(Index index) const
|
||||
{
|
||||
return m_matrix.const_cast_derived().coeffRef(index);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ struct triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,Dynamic>
|
||||
const ActualLhsType actualLhs = LhsProductTraits::extract(lhs);
|
||||
triangular_solve_matrix<Scalar,Index,Side,Mode,LhsProductTraits::NeedToConjugate,(int(Lhs::Flags) & RowMajorBit) ? RowMajor : ColMajor,
|
||||
(Rhs::Flags&RowMajorBit) ? RowMajor : ColMajor>
|
||||
::run(lhs.rows(), Side==OnTheLeft? rhs.cols() : rhs.rows(), &actualLhs.coeff(0,0), actualLhs.outerStride(), &rhs.coeffRef(0,0), rhs.outerStride());
|
||||
::run(lhs.rows(), Side==OnTheLeft? rhs.cols() : rhs.rows(), &actualLhs.coeffRef(0,0), actualLhs.outerStride(), &rhs.coeffRef(0,0), rhs.outerStride());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -63,6 +63,16 @@ template<typename ExpressionType> class SwapWrapper
|
||||
return m_expression.const_cast_derived().coeffRef(index);
|
||||
}
|
||||
|
||||
inline Scalar& coeffRef(Index row, Index col) const
|
||||
{
|
||||
return m_expression.coeffRef(row, col);
|
||||
}
|
||||
|
||||
inline Scalar& coeffRef(Index index) const
|
||||
{
|
||||
return m_expression.coeffRef(index);
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
void copyCoeff(Index row, Index col, const DenseBase<OtherDerived>& other)
|
||||
{
|
||||
@ -113,18 +123,4 @@ template<typename ExpressionType> class SwapWrapper
|
||||
ExpressionType& m_expression;
|
||||
};
|
||||
|
||||
/** swaps *this with the expression \a other.
|
||||
*
|
||||
* \note \a other is only marked for internal reasons, but of course
|
||||
* it gets const-casted. One reason is that one will often call swap
|
||||
* on temporary objects (hence non-const references are forbidden).
|
||||
* Another reason is that lazyAssign takes a const argument anyway.
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
void DenseBase<Derived>::swap(DenseBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
|
||||
{
|
||||
(SwapWrapper<Derived>(derived())).lazyAssign(other);
|
||||
}
|
||||
|
||||
#endif // EIGEN_SWAP_H
|
||||
|
@ -46,7 +46,7 @@ struct traits<Transpose<MatrixType> > : traits<MatrixType>
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedPlain;
|
||||
typedef typename traits<MatrixType>::StorageKind StorageKind;
|
||||
typedef typename traits<MatrixType>::XprKind XprKind;
|
||||
enum {
|
||||
@ -54,8 +54,11 @@ struct traits<Transpose<MatrixType> > : traits<MatrixType>
|
||||
ColsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
Flags = int(_MatrixTypeNested::Flags & ~NestByRefBit) ^ RowMajorBit,
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost,
|
||||
FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0,
|
||||
Flags0 = MatrixTypeNestedPlain::Flags & ~(LvalueBit | NestByRefBit),
|
||||
Flags1 = Flags0 | FlagsLvalueBit,
|
||||
Flags = Flags1 ^ RowMajorBit,
|
||||
CoeffReadCost = MatrixTypeNestedPlain::CoeffReadCost,
|
||||
InnerStrideAtCompileTime = inner_stride_at_compile_time<MatrixType>::ret,
|
||||
OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret
|
||||
};
|
||||
@ -122,12 +125,24 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Dense>
|
||||
|
||||
inline Scalar& coeffRef(Index row, Index col)
|
||||
{
|
||||
return const_cast_derived().nestedExpression().coeffRef(col, row);
|
||||
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||
return derived().nestedExpression().const_cast_derived().coeffRef(col, row);
|
||||
}
|
||||
|
||||
inline Scalar& coeffRef(Index index)
|
||||
{
|
||||
return const_cast_derived().nestedExpression().coeffRef(index);
|
||||
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||
return derived().nestedExpression().const_cast_derived().coeffRef(index);
|
||||
}
|
||||
|
||||
inline const Scalar& coeffRef(Index row, Index col) const
|
||||
{
|
||||
return derived().nestedExpression().coeffRef(col, row);
|
||||
}
|
||||
|
||||
inline const Scalar& coeffRef(Index index) const
|
||||
{
|
||||
return derived().nestedExpression().coeffRef(index);
|
||||
}
|
||||
|
||||
inline const CoeffReturnType coeff(Index row, Index col) const
|
||||
@ -149,7 +164,7 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Dense>
|
||||
template<int LoadMode>
|
||||
inline void writePacket(Index row, Index col, const PacketScalar& x)
|
||||
{
|
||||
const_cast_derived().nestedExpression().template writePacket<LoadMode>(col, row, x);
|
||||
derived().nestedExpression().const_cast_derived().template writePacket<LoadMode>(col, row, x);
|
||||
}
|
||||
|
||||
template<int LoadMode>
|
||||
@ -161,7 +176,7 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Dense>
|
||||
template<int LoadMode>
|
||||
inline void writePacket(Index index, const PacketScalar& x)
|
||||
{
|
||||
const_cast_derived().nestedExpression().template writePacket<LoadMode>(index, x);
|
||||
derived().nestedExpression().const_cast_derived().template writePacket<LoadMode>(index, x);
|
||||
}
|
||||
};
|
||||
|
||||
@ -197,7 +212,7 @@ DenseBase<Derived>::transpose()
|
||||
*
|
||||
* \sa transposeInPlace(), adjoint() */
|
||||
template<typename Derived>
|
||||
inline const Transpose<Derived>
|
||||
inline const typename DenseBase<Derived>::ConstTransposeReturnType
|
||||
DenseBase<Derived>::transpose() const
|
||||
{
|
||||
return derived();
|
||||
@ -226,7 +241,8 @@ template<typename Derived>
|
||||
inline const typename MatrixBase<Derived>::AdjointReturnType
|
||||
MatrixBase<Derived>::adjoint() const
|
||||
{
|
||||
return this->transpose();
|
||||
return this->transpose(); // in the complex case, the .conjugate() is be implicit here
|
||||
// due to implicit conversion to return type
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
|
@ -95,10 +95,11 @@ template<typename Derived> class TriangularBase : public EigenBase<Derived>
|
||||
EIGEN_ONLY_USED_FOR_DEBUG(row);
|
||||
EIGEN_ONLY_USED_FOR_DEBUG(col);
|
||||
eigen_assert(col>=0 && col<cols() && row>=0 && row<rows());
|
||||
eigen_assert( (Mode==Upper && col>=row)
|
||||
|| (Mode==Lower && col<=row)
|
||||
|| ((Mode==StrictlyUpper || Mode==UnitUpper) && col>row)
|
||||
|| ((Mode==StrictlyLower || Mode==UnitLower) && col<row));
|
||||
const int mode = int(Mode) & ~SelfAdjoint;
|
||||
eigen_assert((mode==Upper && col>=row)
|
||||
|| (mode==Lower && col<=row)
|
||||
|| ((mode==StrictlyUpper || mode==UnitUpper) && col>row)
|
||||
|| ((mode==StrictlyLower || mode==UnitLower) && col<row));
|
||||
}
|
||||
|
||||
#ifdef EIGEN_INTERNAL_DEBUGGING
|
||||
@ -260,7 +261,10 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
|
||||
|
||||
/** \sa MatrixBase::transpose() */
|
||||
inline TriangularView<Transpose<MatrixType>,TransposeMode> transpose()
|
||||
{ return m_matrix.transpose(); }
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||
return m_matrix.const_cast_derived().transpose();
|
||||
}
|
||||
/** \sa MatrixBase::transpose() const */
|
||||
inline const TriangularView<Transpose<MatrixType>,TransposeMode> transpose() const
|
||||
{ return m_matrix.transpose(); }
|
||||
@ -701,7 +705,8 @@ EIGEN_DEPRECATED TriangularView<Derived, Mode> MatrixBase<Derived>::part()
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<unsigned int Mode>
|
||||
TriangularView<Derived, Mode> MatrixBase<Derived>::triangularView()
|
||||
typename MatrixBase<Derived>::template TriangularViewReturnType<Mode>::Type
|
||||
MatrixBase<Derived>::triangularView()
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
@ -709,7 +714,8 @@ TriangularView<Derived, Mode> MatrixBase<Derived>::triangularView()
|
||||
/** This is the const version of MatrixBase::triangularView() */
|
||||
template<typename Derived>
|
||||
template<unsigned int Mode>
|
||||
const TriangularView<Derived, Mode> MatrixBase<Derived>::triangularView() const
|
||||
typename MatrixBase<Derived>::template ConstTriangularViewReturnType<Mode>::Type
|
||||
MatrixBase<Derived>::triangularView() const
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ template<typename VectorType, int Size> class VectorBlock
|
||||
|
||||
/** Dynamic-size constructor
|
||||
*/
|
||||
inline VectorBlock(const VectorType& vector, Index start, Index size)
|
||||
inline VectorBlock(VectorType& vector, Index start, Index size)
|
||||
: Base(vector,
|
||||
IsColVector ? start : 0, IsColVector ? 0 : start,
|
||||
IsColVector ? size : 1, IsColVector ? 1 : size)
|
||||
@ -95,7 +95,7 @@ template<typename VectorType, int Size> class VectorBlock
|
||||
|
||||
/** Fixed-size constructor
|
||||
*/
|
||||
inline VectorBlock(const VectorType& vector, Index start)
|
||||
inline VectorBlock(VectorType& vector, Index start)
|
||||
: Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
|
||||
@ -120,20 +120,20 @@ template<typename VectorType, int Size> class VectorBlock
|
||||
* \sa class Block, segment(Index)
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline VectorBlock<Derived> DenseBase<Derived>
|
||||
::segment(Index start, Index size)
|
||||
inline typename DenseBase<Derived>::SegmentReturnType
|
||||
DenseBase<Derived>::segment(Index start, Index size)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived>(derived(), start, size);
|
||||
return SegmentReturnType(derived(), start, size);
|
||||
}
|
||||
|
||||
/** This is the const version of segment(Index,Index).*/
|
||||
template<typename Derived>
|
||||
inline const VectorBlock<Derived>
|
||||
inline typename DenseBase<Derived>::ConstSegmentReturnType
|
||||
DenseBase<Derived>::segment(Index start, Index size) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived>(derived(), start, size);
|
||||
return ConstSegmentReturnType(derived(), start, size);
|
||||
}
|
||||
|
||||
/** \returns a dynamic-size expression of the first coefficients of *this.
|
||||
@ -152,20 +152,20 @@ DenseBase<Derived>::segment(Index start, Index size) const
|
||||
* \sa class Block, block(Index,Index)
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline VectorBlock<Derived>
|
||||
inline typename DenseBase<Derived>::SegmentReturnType
|
||||
DenseBase<Derived>::head(Index size)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived>(derived(), 0, size);
|
||||
return SegmentReturnType(derived(), 0, size);
|
||||
}
|
||||
|
||||
/** This is the const version of head(Index).*/
|
||||
template<typename Derived>
|
||||
inline const VectorBlock<Derived>
|
||||
inline typename DenseBase<Derived>::ConstSegmentReturnType
|
||||
DenseBase<Derived>::head(Index size) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived>(derived(), 0, size);
|
||||
return ConstSegmentReturnType(derived(), 0, size);
|
||||
}
|
||||
|
||||
/** \returns a dynamic-size expression of the last coefficients of *this.
|
||||
@ -184,20 +184,20 @@ DenseBase<Derived>::head(Index size) const
|
||||
* \sa class Block, block(Index,Index)
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline VectorBlock<Derived>
|
||||
inline typename DenseBase<Derived>::SegmentReturnType
|
||||
DenseBase<Derived>::tail(Index size)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived>(derived(), this->size() - size, size);
|
||||
return SegmentReturnType(derived(), this->size() - size, size);
|
||||
}
|
||||
|
||||
/** This is the const version of tail(Index).*/
|
||||
template<typename Derived>
|
||||
inline const VectorBlock<Derived>
|
||||
inline typename DenseBase<Derived>::ConstSegmentReturnType
|
||||
DenseBase<Derived>::tail(Index size) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived>(derived(), this->size() - size, size);
|
||||
return ConstSegmentReturnType(derived(), this->size() - size, size);
|
||||
}
|
||||
|
||||
/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this
|
||||
@ -215,21 +215,21 @@ DenseBase<Derived>::tail(Index size) const
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline VectorBlock<Derived,Size>
|
||||
inline typename DenseBase<Derived>::template FixedSegmentReturnType<Size>::Type
|
||||
DenseBase<Derived>::segment(Index start)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived,Size>(derived(), start);
|
||||
return typename FixedSegmentReturnType<Size>::Type(derived(), start);
|
||||
}
|
||||
|
||||
/** This is the const version of segment<int>(Index).*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline const VectorBlock<Derived,Size>
|
||||
inline typename DenseBase<Derived>::template ConstFixedSegmentReturnType<Size>::Type
|
||||
DenseBase<Derived>::segment(Index start) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived,Size>(derived(), start);
|
||||
return typename ConstFixedSegmentReturnType<Size>::Type(derived(), start);
|
||||
}
|
||||
|
||||
/** \returns a fixed-size expression of the first coefficients of *this.
|
||||
@ -245,21 +245,21 @@ DenseBase<Derived>::segment(Index start) const
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline VectorBlock<Derived,Size>
|
||||
inline typename DenseBase<Derived>::template FixedSegmentReturnType<Size>::Type
|
||||
DenseBase<Derived>::head()
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived,Size>(derived(), 0);
|
||||
return typename FixedSegmentReturnType<Size>::Type(derived(), 0);
|
||||
}
|
||||
|
||||
/** This is the const version of head<int>().*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline const VectorBlock<Derived,Size>
|
||||
inline typename DenseBase<Derived>::template ConstFixedSegmentReturnType<Size>::Type
|
||||
DenseBase<Derived>::head() const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived,Size>(derived(), 0);
|
||||
return typename ConstFixedSegmentReturnType<Size>::Type(derived(), 0);
|
||||
}
|
||||
|
||||
/** \returns a fixed-size expression of the last coefficients of *this.
|
||||
@ -275,21 +275,21 @@ DenseBase<Derived>::head() const
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline VectorBlock<Derived,Size>
|
||||
inline typename DenseBase<Derived>::template FixedSegmentReturnType<Size>::Type
|
||||
DenseBase<Derived>::tail()
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived, Size>(derived(), size() - Size);
|
||||
return typename FixedSegmentReturnType<Size>::Type(derived(), size() - Size);
|
||||
}
|
||||
|
||||
/** This is the const version of tail<int>.*/
|
||||
template<typename Derived>
|
||||
template<int Size>
|
||||
inline const VectorBlock<Derived,Size>
|
||||
inline typename DenseBase<Derived>::template ConstFixedSegmentReturnType<Size>::Type
|
||||
DenseBase<Derived>::tail() const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return VectorBlock<Derived, Size>(derived(), size() - Size);
|
||||
return typename ConstFixedSegmentReturnType<Size>::Type(derived(), size() - Size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,7 +183,8 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
typedef typename ExpressionType::RealScalar RealScalar;
|
||||
typedef typename ExpressionType::Index Index;
|
||||
typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret,
|
||||
ExpressionType, const ExpressionType&>::type ExpressionTypeNested;
|
||||
ExpressionType, ExpressionType&>::type ExpressionTypeNested;
|
||||
typedef typename internal::remove_all<ExpressionTypeNested>::type ExpressionTypeNestedCleaned;
|
||||
|
||||
template<template<typename _Scalar> class Functor,
|
||||
typename Scalar=typename internal::traits<ExpressionType>::Scalar> struct ReturnType
|
||||
@ -245,7 +246,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
|
||||
public:
|
||||
|
||||
inline VectorwiseOp(const ExpressionType& matrix) : m_matrix(matrix) {}
|
||||
inline VectorwiseOp(ExpressionType& matrix) : m_matrix(matrix) {}
|
||||
|
||||
/** \internal */
|
||||
inline const ExpressionType& _expression() const { return m_matrix; }
|
||||
@ -444,9 +445,9 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
}
|
||||
|
||||
/** Returns the expression of the sum of the vector \a other to each subvector of \c *this */
|
||||
template<typename OtherDerived> EIGEN_STRONG_INLINE
|
||||
template<typename OtherDerived> EIGEN_STRONG_INLINE
|
||||
CwiseBinaryOp<internal::scalar_sum_op<Scalar>,
|
||||
ExpressionType,
|
||||
ExpressionTypeNestedCleaned,
|
||||
typename ExtendedType<OtherDerived>::Type>
|
||||
operator+(const DenseBase<OtherDerived>& other) const
|
||||
{
|
||||
@ -457,7 +458,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
/** Returns the expression of the difference between each subvector of \c *this and the vector \a other */
|
||||
template<typename OtherDerived>
|
||||
CwiseBinaryOp<internal::scalar_difference_op<Scalar>,
|
||||
ExpressionType,
|
||||
ExpressionTypeNestedCleaned,
|
||||
typename ExtendedType<OtherDerived>::Type>
|
||||
operator-(const DenseBase<OtherDerived>& other) const
|
||||
{
|
||||
@ -478,13 +479,13 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
: internal::traits<ExpressionType>::ColsAtCompileTime,
|
||||
HNormalized_SizeMinusOne = HNormalized_Size==Dynamic ? Dynamic : HNormalized_Size-1
|
||||
};
|
||||
typedef Block<ExpressionType,
|
||||
typedef Block<const ExpressionType,
|
||||
Direction==Vertical ? int(HNormalized_SizeMinusOne)
|
||||
: int(internal::traits<ExpressionType>::RowsAtCompileTime),
|
||||
Direction==Horizontal ? int(HNormalized_SizeMinusOne)
|
||||
: int(internal::traits<ExpressionType>::ColsAtCompileTime)>
|
||||
HNormalized_Block;
|
||||
typedef Block<ExpressionType,
|
||||
typedef Block<const ExpressionType,
|
||||
Direction==Vertical ? 1 : int(internal::traits<ExpressionType>::RowsAtCompileTime),
|
||||
Direction==Horizontal ? 1 : int(internal::traits<ExpressionType>::ColsAtCompileTime)>
|
||||
HNormalized_Factors;
|
||||
@ -495,7 +496,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
Direction==Horizontal ? HNormalized_SizeMinusOne : 1> >
|
||||
HNormalizedReturnType;
|
||||
|
||||
HNormalizedReturnType hnormalized() const;
|
||||
const HNormalizedReturnType hnormalized() const;
|
||||
|
||||
protected:
|
||||
ExpressionTypeNested m_matrix;
|
||||
@ -509,7 +510,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
* \sa rowwise(), class VectorwiseOp
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline const VectorwiseOp<Derived,Vertical>
|
||||
inline const typename DenseBase<Derived>::ConstColwiseReturnType
|
||||
DenseBase<Derived>::colwise() const
|
||||
{
|
||||
return derived();
|
||||
@ -520,7 +521,7 @@ DenseBase<Derived>::colwise() const
|
||||
* \sa rowwise(), class VectorwiseOp
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline VectorwiseOp<Derived,Vertical>
|
||||
inline typename DenseBase<Derived>::ColwiseReturnType
|
||||
DenseBase<Derived>::colwise()
|
||||
{
|
||||
return derived();
|
||||
@ -534,7 +535,7 @@ DenseBase<Derived>::colwise()
|
||||
* \sa colwise(), class VectorwiseOp
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline const VectorwiseOp<Derived,Horizontal>
|
||||
inline const typename DenseBase<Derived>::ConstRowwiseReturnType
|
||||
DenseBase<Derived>::rowwise() const
|
||||
{
|
||||
return derived();
|
||||
@ -545,7 +546,7 @@ DenseBase<Derived>::rowwise() const
|
||||
* \sa colwise(), class VectorwiseOp
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline VectorwiseOp<Derived,Horizontal>
|
||||
inline typename DenseBase<Derived>::RowwiseReturnType
|
||||
DenseBase<Derived>::rowwise()
|
||||
{
|
||||
return derived();
|
||||
|
@ -238,8 +238,8 @@ struct gemm_functor
|
||||
cols = m_rhs.cols();
|
||||
|
||||
Gemm::run(rows, cols, m_lhs.cols(),
|
||||
/*(const Scalar*)*/&(m_lhs.const_cast_derived().coeffRef(row,0)), m_lhs.outerStride(),
|
||||
/*(const Scalar*)*/&(m_rhs.const_cast_derived().coeffRef(0,col)), m_rhs.outerStride(),
|
||||
/*(const Scalar*)*/&m_lhs.coeffRef(row,0), m_lhs.outerStride(),
|
||||
/*(const Scalar*)*/&m_rhs.coeffRef(0,col), m_rhs.outerStride(),
|
||||
(Scalar*)&(m_dest.coeffRef(row,col)), m_dest.outerStride(),
|
||||
m_actualAlpha, m_blocking, info);
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ TriangularView<MatrixType,UpLo>& TriangularView<MatrixType,UpLo>::assignProduct(
|
||||
typename Rhs::Scalar, _ActualRhs::Flags&RowMajorBit ? RowMajor : ColMajor, RhsBlasTraits::NeedToConjugate,
|
||||
MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor, UpLo>
|
||||
::run(m_matrix.cols(), actualLhs.cols(),
|
||||
&actualLhs.coeff(0,0), actualLhs.outerStride(), &actualRhs.coeff(0,0), actualRhs.outerStride(),
|
||||
&actualLhs.coeffRef(0,0), actualLhs.outerStride(), &actualRhs.coeffRef(0,0), actualRhs.outerStride(),
|
||||
const_cast<Scalar*>(m_matrix.data()), m_matrix.outerStride(), actualAlpha);
|
||||
|
||||
return *this;
|
||||
|
@ -423,8 +423,8 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,RhsMode,false>
|
||||
internal::traits<Dest>::Flags&RowMajorBit ? RowMajor : ColMajor>
|
||||
::run(
|
||||
lhs.rows(), rhs.cols(), // sizes
|
||||
&lhs.coeff(0,0), lhs.outerStride(), // lhs info
|
||||
&rhs.coeff(0,0), rhs.outerStride(), // rhs info
|
||||
&lhs.coeffRef(0,0), lhs.outerStride(), // lhs info
|
||||
&rhs.coeffRef(0,0), rhs.outerStride(), // rhs info
|
||||
&dst.coeffRef(0,0), dst.outerStride(), // result info
|
||||
actualAlpha // alpha
|
||||
);
|
||||
|
@ -203,8 +203,8 @@ struct SelfadjointProductMatrix<Lhs,LhsMode,false,Rhs,0,true>
|
||||
internal::product_selfadjoint_vector<Scalar, Index, (internal::traits<_ActualLhsType>::Flags&RowMajorBit) ? RowMajor : ColMajor, int(LhsUpLo), bool(LhsBlasTraits::NeedToConjugate), bool(RhsBlasTraits::NeedToConjugate)>
|
||||
(
|
||||
lhs.rows(), // size
|
||||
&lhs.coeff(0,0), lhs.outerStride(), // lhs info
|
||||
&rhs.coeff(0), rhs.innerStride(), // rhs info
|
||||
&lhs.coeffRef(0,0), lhs.outerStride(), // lhs info
|
||||
&rhs.coeffRef(0), rhs.innerStride(), // rhs info
|
||||
&dst.coeffRef(0), // result info
|
||||
actualAlpha // scale factor
|
||||
);
|
||||
@ -247,8 +247,8 @@ struct SelfadjointProductMatrix<Lhs,0,true,Rhs,RhsMode,false>
|
||||
bool(RhsBlasTraits::NeedToConjugate), bool(LhsBlasTraits::NeedToConjugate)>
|
||||
(
|
||||
rhs.rows(), // size
|
||||
&rhs.coeff(0,0), rhs.outerStride(), // lhs info
|
||||
&lhs.coeff(0), lhs.innerStride(), // rhs info
|
||||
&rhs.coeffRef(0,0), rhs.outerStride(), // lhs info
|
||||
&lhs.coeffRef(0), lhs.innerStride(), // rhs info
|
||||
&dst.coeffRef(0), // result info
|
||||
actualAlpha // scale factor
|
||||
);
|
||||
|
@ -52,7 +52,7 @@ SelfAdjointView<MatrixType,UpLo>& SelfAdjointView<MatrixType,UpLo>
|
||||
Scalar, _ActualUType::Flags&RowMajorBit ? ColMajor : RowMajor, (!UBlasTraits::NeedToConjugate) && NumTraits<Scalar>::IsComplex,
|
||||
MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor, UpLo>
|
||||
::run(_expression().cols(), actualU.cols(),
|
||||
&actualU.coeff(0,0), actualU.outerStride(), &actualU.coeff(0,0), actualU.outerStride(),
|
||||
&actualU.coeffRef(0,0), actualU.outerStride(), &actualU.coeffRef(0,0), actualU.outerStride(),
|
||||
_expression().const_cast_derived().data(), _expression().outerStride(), actualAlpha);
|
||||
|
||||
return *this;
|
||||
|
@ -387,8 +387,8 @@ struct TriangularProduct<Mode,LhsIsTriangular,Lhs,false,Rhs,false>
|
||||
(internal::traits<Dest >::Flags&RowMajorBit) ? RowMajor : ColMajor>
|
||||
::run(
|
||||
lhs.rows(), rhs.cols(), lhs.cols(),// LhsIsTriangular ? rhs.cols() : lhs.rows(), // sizes
|
||||
&lhs.coeff(0,0), lhs.outerStride(), // lhs info
|
||||
&rhs.coeff(0,0), rhs.outerStride(), // rhs info
|
||||
&lhs.coeffRef(0,0), lhs.outerStride(), // lhs info
|
||||
&rhs.coeffRef(0,0), rhs.outerStride(), // rhs info
|
||||
&dst.coeffRef(0,0), dst.outerStride(), // result info
|
||||
actualAlpha // alpha
|
||||
);
|
||||
|
@ -76,8 +76,8 @@ struct product_triangular_matrix_vector<Index,Mode,LhsScalar,ConjLhs,RhsScalar,C
|
||||
Index s = IsLower ? pi+actualPanelWidth : 0;
|
||||
general_matrix_vector_product<Index,LhsScalar,ColMajor,ConjLhs,RhsScalar,ConjRhs>::run(
|
||||
r, actualPanelWidth,
|
||||
&lhs.coeff(s,pi), lhsStride,
|
||||
&rhs.coeff(pi), rhsIncr,
|
||||
&lhs.coeffRef(s,pi), lhsStride,
|
||||
&rhs.coeffRef(pi), rhsIncr,
|
||||
&res.coeffRef(s), resIncr, alpha);
|
||||
}
|
||||
}
|
||||
@ -130,8 +130,8 @@ struct product_triangular_matrix_vector<Index,Mode,LhsScalar,ConjLhs,RhsScalar,C
|
||||
Index s = IsLower ? 0 : pi + actualPanelWidth;
|
||||
general_matrix_vector_product<Index,LhsScalar,RowMajor,ConjLhs,RhsScalar,ConjRhs>::run(
|
||||
actualPanelWidth, r,
|
||||
&(lhs.coeff(pi,s)), lhsStride,
|
||||
&(rhs.coeff(s)), rhsIncr,
|
||||
&lhs.coeffRef(pi,s), lhsStride,
|
||||
&rhs.coeffRef(s), rhsIncr,
|
||||
&res.coeffRef(pi), resIncr, alpha);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ struct triangular_solve_vector<LhsScalar, RhsScalar, Index, OnTheLeft, Mode, Con
|
||||
|
||||
general_matrix_vector_product<Index,LhsScalar,RowMajor,Conjugate,RhsScalar,false>::run(
|
||||
actualPanelWidth, r,
|
||||
&(lhs.coeff(startRow,startCol)), lhsStride,
|
||||
&lhs.coeffRef(startRow,startCol), lhsStride,
|
||||
rhs + startCol, 1,
|
||||
rhs + startRow, 1,
|
||||
RhsScalar(-1));
|
||||
@ -137,7 +137,7 @@ struct triangular_solve_vector<LhsScalar, RhsScalar, Index, OnTheLeft, Mode, Con
|
||||
// 2 - it is slighlty faster at runtime
|
||||
general_matrix_vector_product<Index,LhsScalar,ColMajor,Conjugate,RhsScalar,false>::run(
|
||||
r, actualPanelWidth,
|
||||
&(lhs.coeff(endBlock,startBlock)), lhsStride,
|
||||
&lhs.coeffRef(endBlock,startBlock), lhsStride,
|
||||
rhs+startBlock, 1,
|
||||
rhs+endBlock, 1, RhsScalar(-1));
|
||||
}
|
||||
|
@ -177,8 +177,8 @@ template<typename XprType> struct blas_traits
|
||||
ExtractType,
|
||||
typename _ExtractType::PlainObject
|
||||
>::type DirectLinearAccessType;
|
||||
static inline ExtractType extract(const XprType& x) { return x; }
|
||||
static inline Scalar extractScalarFactor(const XprType&) { return Scalar(1); }
|
||||
static inline const ExtractType extract(const XprType& x) { return x; }
|
||||
static inline const Scalar extractScalarFactor(const XprType&) { return Scalar(1); }
|
||||
};
|
||||
|
||||
// pop conjugate
|
||||
@ -194,7 +194,7 @@ struct blas_traits<CwiseUnaryOp<scalar_conjugate_op<Scalar>, NestedXpr> >
|
||||
IsComplex = NumTraits<Scalar>::IsComplex,
|
||||
NeedToConjugate = Base::NeedToConjugate ? 0 : IsComplex
|
||||
};
|
||||
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||
static inline const ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||
static inline Scalar extractScalarFactor(const XprType& x) { return conj(Base::extractScalarFactor(x.nestedExpression())); }
|
||||
};
|
||||
|
||||
@ -206,7 +206,7 @@ struct blas_traits<CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> >
|
||||
typedef blas_traits<NestedXpr> Base;
|
||||
typedef CwiseUnaryOp<scalar_multiple_op<Scalar>, NestedXpr> XprType;
|
||||
typedef typename Base::ExtractType ExtractType;
|
||||
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||
static inline const ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||
static inline Scalar extractScalarFactor(const XprType& x)
|
||||
{ return x.functor().m_other * Base::extractScalarFactor(x.nestedExpression()); }
|
||||
};
|
||||
@ -219,7 +219,7 @@ struct blas_traits<CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> >
|
||||
typedef blas_traits<NestedXpr> Base;
|
||||
typedef CwiseUnaryOp<scalar_opposite_op<Scalar>, NestedXpr> XprType;
|
||||
typedef typename Base::ExtractType ExtractType;
|
||||
static inline ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||
static inline const ExtractType extract(const XprType& x) { return Base::extract(x.nestedExpression()); }
|
||||
static inline Scalar extractScalarFactor(const XprType& x)
|
||||
{ return - Base::extractScalarFactor(x.nestedExpression()); }
|
||||
};
|
||||
@ -245,11 +245,16 @@ struct blas_traits<Transpose<NestedXpr> >
|
||||
static inline Scalar extractScalarFactor(const XprType& x) { return Base::extractScalarFactor(x.nestedExpression()); }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct blas_traits<const T>
|
||||
: blas_traits<T>
|
||||
{};
|
||||
|
||||
template<typename T, bool HasUsableDirectAccess=blas_traits<T>::HasUsableDirectAccess>
|
||||
struct extract_data_selector {
|
||||
static const typename T::Scalar* run(const T& m)
|
||||
{
|
||||
return &blas_traits<T>::extract(m).const_cast_derived().coeffRef(0,0); // FIXME this should be .data()
|
||||
return const_cast<typename T::Scalar*>(&blas_traits<T>::extract(m).coeffRef(0,0)); // FIXME this should be .data()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -27,8 +27,15 @@
|
||||
#define EIGEN_FORWARDDECLARATIONS_H
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename T> struct traits;
|
||||
|
||||
// here we say once and for all that traits<const T> == traits<T>
|
||||
// When constness must affect traits, it has to be constness on template parameters on which T itself depends.
|
||||
// For example, traits<Map<const T> > != traits<Map<T> >, but
|
||||
// traits<const Map<T> > == traits<Map<T> >
|
||||
template<typename T> struct traits<const T> : traits<T> {};
|
||||
|
||||
template<typename Derived> struct has_direct_access
|
||||
{
|
||||
enum { ret = (traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 };
|
||||
@ -49,6 +56,7 @@ template<typename T> struct NumTraits;
|
||||
|
||||
template<typename Derived> struct EigenBase;
|
||||
template<typename Derived> class DenseBase;
|
||||
template<typename Derived> class PlainObjectBase;
|
||||
|
||||
|
||||
template<typename Derived,
|
||||
@ -92,7 +100,7 @@ template<typename Derived> class DiagonalBase;
|
||||
template<typename _DiagonalVectorType> class DiagonalWrapper;
|
||||
template<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime=SizeAtCompileTime> class DiagonalMatrix;
|
||||
template<typename MatrixType, typename DiagonalType, int ProductOrder> class DiagonalProduct;
|
||||
template<typename MatrixType, int Index> class Diagonal;
|
||||
template<typename MatrixType, int Index = 0> class Diagonal;
|
||||
template<int SizeAtCompileTime, int MaxSizeAtCompileTime = SizeAtCompileTime> class PermutationMatrix;
|
||||
template<int SizeAtCompileTime, int MaxSizeAtCompileTime = SizeAtCompileTime> class Transpositions;
|
||||
|
||||
|
@ -93,7 +93,7 @@
|
||||
THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS,
|
||||
YOU_CANNOT_MIX_ARRAYS_AND_MATRICES,
|
||||
YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION,
|
||||
YOU_ARE_TRYING_TO_WRITE_INTO_A_READ_ONLY_EXPRESSION,
|
||||
THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY,
|
||||
YOU_ARE_TRYING_TO_USE_AN_INDEX_BASED_ACCESSOR_ON_AN_EXPRESSION_THAT_DOES_NOT_SUPPORT_THAT,
|
||||
THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS
|
||||
};
|
||||
@ -187,6 +187,6 @@
|
||||
|
||||
#define EIGEN_STATIC_ASSERT_LVALUE(Derived) \
|
||||
EIGEN_STATIC_ASSERT(int(internal::traits<Derived>::Flags) & LvalueBit, \
|
||||
YOU_ARE_TRYING_TO_WRITE_INTO_A_READ_ONLY_EXPRESSION)
|
||||
THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY)
|
||||
|
||||
#endif // EIGEN_STATIC_ASSERT_H
|
||||
|
@ -377,19 +377,6 @@ struct special_scalar_op_base<Derived,Scalar,OtherScalar,true> : public DenseCo
|
||||
{ return static_cast<const special_scalar_op_base&>(matrix).operator*(scalar); }
|
||||
};
|
||||
|
||||
template<typename ExpressionType> struct HNormalizedReturnType {
|
||||
|
||||
enum {
|
||||
SizeAtCompileTime = ExpressionType::SizeAtCompileTime,
|
||||
SizeMinusOne = SizeAtCompileTime==Dynamic ? Dynamic : SizeAtCompileTime-1
|
||||
};
|
||||
typedef Block<ExpressionType,
|
||||
traits<ExpressionType>::ColsAtCompileTime==1 ? SizeMinusOne : 1,
|
||||
traits<ExpressionType>::ColsAtCompileTime==1 ? 1 : SizeMinusOne> StartMinusOne;
|
||||
typedef CwiseUnaryOp<scalar_quotient1_op<typename traits<ExpressionType>::Scalar>,
|
||||
StartMinusOne > Type;
|
||||
};
|
||||
|
||||
template<typename XprType, typename CastType> struct cast_return_type
|
||||
{
|
||||
typedef typename XprType::Scalar CurrentScalarType;
|
||||
@ -455,6 +442,13 @@ struct plain_diag_type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename ExpressionType>
|
||||
struct is_lvalue
|
||||
{
|
||||
enum { value = !bool(is_const<ExpressionType>::value) &&
|
||||
bool(traits<ExpressionType>::Flags & LvalueBit) };
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_XPRHELPER_H
|
||||
|
@ -113,23 +113,11 @@ template<typename MatrixType,int _Direction> class Homogeneous
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim, int Mode> friend
|
||||
inline const internal::homogeneous_left_product_impl<Homogeneous,
|
||||
typename Transform<Scalar,Dim,Mode>::AffinePartNested>
|
||||
operator* (const Transform<Scalar,Dim,Mode>& tr, const Homogeneous& rhs)
|
||||
inline const internal::homogeneous_left_product_impl<Homogeneous,Transform<Scalar,Dim,Mode> >
|
||||
operator* (const Transform<Scalar,Dim,Mode>& lhs, const Homogeneous& rhs)
|
||||
{
|
||||
eigen_assert(int(Direction)==Vertical);
|
||||
return internal::homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Mode>::AffinePartNested >
|
||||
(tr.affine(),rhs.m_matrix);
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim> friend
|
||||
inline const internal::homogeneous_left_product_impl<Homogeneous,
|
||||
typename Transform<Scalar,Dim,Projective>::MatrixType>
|
||||
operator* (const Transform<Scalar,Dim,Projective>& tr, const Homogeneous& rhs)
|
||||
{
|
||||
eigen_assert(int(Direction)==Vertical);
|
||||
return internal::homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Projective>::MatrixType>
|
||||
(tr.matrix(),rhs.m_matrix);
|
||||
return internal::homogeneous_left_product_impl<Homogeneous,Transform<Scalar,Dim,Mode> >(lhs,rhs.m_matrix);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -179,11 +167,11 @@ VectorwiseOp<ExpressionType,Direction>::homogeneous() const
|
||||
*
|
||||
* \sa VectorwiseOp::hnormalized() */
|
||||
template<typename Derived>
|
||||
inline typename MatrixBase<Derived>::HNormalizedReturnType
|
||||
inline const typename MatrixBase<Derived>::HNormalizedReturnType
|
||||
MatrixBase<Derived>::hnormalized() const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
|
||||
return StartMinusOne(derived(),0,0,
|
||||
return ConstStartMinusOne(derived(),0,0,
|
||||
ColsAtCompileTime==1?size()-1:1,
|
||||
ColsAtCompileTime==1?1:size()-1) / coeff(size()-1);
|
||||
}
|
||||
@ -197,7 +185,7 @@ MatrixBase<Derived>::hnormalized() const
|
||||
*
|
||||
* \sa MatrixBase::hnormalized() */
|
||||
template<typename ExpressionType, int Direction>
|
||||
inline typename VectorwiseOp<ExpressionType,Direction>::HNormalizedReturnType
|
||||
inline const typename VectorwiseOp<ExpressionType,Direction>::HNormalizedReturnType
|
||||
VectorwiseOp<ExpressionType,Direction>::hnormalized() const
|
||||
{
|
||||
return HNormalized_Block(_expression(),0,0,
|
||||
@ -217,15 +205,39 @@ VectorwiseOp<ExpressionType,Direction>::hnormalized() const
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename MatrixOrTransformType>
|
||||
struct take_matrix_for_product
|
||||
{
|
||||
typedef MatrixOrTransformType type;
|
||||
static const type& run(const type &x) { return x; }
|
||||
};
|
||||
|
||||
template<typename Scalar, int Dim, int Mode>
|
||||
struct take_matrix_for_product<Transform<Scalar, Dim, Mode> >
|
||||
{
|
||||
typedef Transform<Scalar, Dim, Mode> TransformType;
|
||||
typedef typename TransformType::ConstAffinePart type;
|
||||
static const type run (const TransformType& x) { return x.affine(); }
|
||||
};
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
struct take_matrix_for_product<Transform<Scalar, Dim, Projective> >
|
||||
{
|
||||
typedef Transform<Scalar, Dim, Projective> TransformType;
|
||||
typedef typename TransformType::MatrixType type;
|
||||
static const type& run (const TransformType& x) { return x.matrix(); }
|
||||
};
|
||||
|
||||
template<typename MatrixType,typename Lhs>
|
||||
struct traits<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >
|
||||
{
|
||||
typedef typename take_matrix_for_product<Lhs>::type LhsMatrixType;
|
||||
typedef typename make_proper_matrix_type<
|
||||
typename traits<MatrixType>::Scalar,
|
||||
Lhs::RowsAtCompileTime,
|
||||
LhsMatrixType::RowsAtCompileTime,
|
||||
MatrixType::ColsAtCompileTime,
|
||||
MatrixType::PlainObject::Options,
|
||||
Lhs::MaxRowsAtCompileTime,
|
||||
LhsMatrixType::MaxRowsAtCompileTime,
|
||||
MatrixType::MaxColsAtCompileTime>::type ReturnType;
|
||||
};
|
||||
|
||||
@ -233,10 +245,12 @@ template<typename MatrixType,typename Lhs>
|
||||
struct homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
|
||||
: public ReturnByValue<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >
|
||||
{
|
||||
typedef typename remove_all<typename Lhs::Nested>::type LhsNested;
|
||||
typedef typename traits<homogeneous_left_product_impl>::LhsMatrixType LhsMatrixType;
|
||||
typedef typename remove_all<typename LhsMatrixType::Nested>::type LhsMatrixTypeNested;
|
||||
typedef typename MatrixType::Index Index;
|
||||
homogeneous_left_product_impl(const Lhs& lhs, const MatrixType& rhs)
|
||||
: m_lhs(lhs), m_rhs(rhs)
|
||||
: m_lhs(take_matrix_for_product<Lhs>::run(lhs)),
|
||||
m_rhs(rhs)
|
||||
{}
|
||||
|
||||
inline Index rows() const { return m_lhs.rows(); }
|
||||
@ -245,15 +259,15 @@ struct homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
{
|
||||
// FIXME investigate how to allow lazy evaluation of this product when possible
|
||||
dst = Block<LhsNested,
|
||||
LhsNested::RowsAtCompileTime,
|
||||
LhsNested::ColsAtCompileTime==Dynamic?Dynamic:LhsNested::ColsAtCompileTime-1>
|
||||
dst = Block<const LhsMatrixTypeNested,
|
||||
LhsMatrixTypeNested::RowsAtCompileTime,
|
||||
LhsMatrixTypeNested::ColsAtCompileTime==Dynamic?Dynamic:LhsMatrixTypeNested::ColsAtCompileTime-1>
|
||||
(m_lhs,0,0,m_lhs.rows(),m_lhs.cols()-1) * m_rhs;
|
||||
dst += m_lhs.col(m_lhs.cols()-1).rowwise()
|
||||
.template replicate<MatrixType::ColsAtCompileTime>(m_rhs.cols());
|
||||
}
|
||||
|
||||
const typename Lhs::Nested m_lhs;
|
||||
const typename LhsMatrixType::Nested m_lhs;
|
||||
const typename MatrixType::Nested m_rhs;
|
||||
};
|
||||
|
||||
@ -284,7 +298,7 @@ struct homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>
|
||||
template<typename Dest> void evalTo(Dest& dst) const
|
||||
{
|
||||
// FIXME investigate how to allow lazy evaluation of this product when possible
|
||||
dst = m_lhs * Block<RhsNested,
|
||||
dst = m_lhs * Block<const RhsNested,
|
||||
RhsNested::RowsAtCompileTime==Dynamic?Dynamic:RhsNested::RowsAtCompileTime-1,
|
||||
RhsNested::ColsAtCompileTime>
|
||||
(m_rhs,0,0,m_rhs.rows()-1,m_rhs.cols());
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
? Dynamic
|
||||
: Index(AmbientDimAtCompileTime)+1,1> Coefficients;
|
||||
typedef Block<Coefficients,AmbientDimAtCompileTime,1> NormalReturnType;
|
||||
typedef const Block<const Coefficients,AmbientDimAtCompileTime,1> ConstNormalReturnType;
|
||||
|
||||
/** Default constructor without initialization */
|
||||
inline explicit Hyperplane() {}
|
||||
@ -148,7 +149,7 @@ public:
|
||||
/** \returns a constant reference to the unit normal vector of the plane, which corresponds
|
||||
* to the linear part of the implicit equation.
|
||||
*/
|
||||
inline const NormalReturnType normal() const { return NormalReturnType(m_coeffs,0,0,dim(),1); }
|
||||
inline ConstNormalReturnType normal() const { return ConstNormalReturnType(m_coeffs,0,0,dim(),1); }
|
||||
|
||||
/** \returns a non-constant reference to the unit normal vector of the plane, which corresponds
|
||||
* to the linear part of the implicit equation.
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
inline Scalar& w() { return this->derived().coeffs().coeffRef(3); }
|
||||
|
||||
/** \returns a read-only vector expression of the imaginary part (x,y,z) */
|
||||
inline const VectorBlock<Coefficients,3> vec() const { return coeffs().template head<3>(); }
|
||||
inline const VectorBlock<const Coefficients,3> vec() const { return coeffs().template head<3>(); }
|
||||
|
||||
/** \returns a vector expression of the imaginary part (x,y,z) */
|
||||
inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }
|
||||
|
@ -193,22 +193,28 @@ public:
|
||||
typedef DenseIndex Index;
|
||||
/** type of the matrix used to represent the transformation */
|
||||
typedef Matrix<Scalar,Rows,HDim> MatrixType;
|
||||
/** constified MatrixType */
|
||||
typedef const MatrixType ConstMatrixType;
|
||||
/** type of the matrix used to represent the linear part of the transformation */
|
||||
typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
|
||||
/** type of read/write reference to the linear part of the transformation */
|
||||
typedef Block<MatrixType,Dim,Dim> LinearPart;
|
||||
/** type of read reference to the linear part of the transformation */
|
||||
typedef const Block<ConstMatrixType,Dim,Dim> ConstLinearPart;
|
||||
/** type of read/write reference to the affine part of the transformation */
|
||||
typedef typename internal::conditional<int(Mode)==int(AffineCompact),
|
||||
MatrixType&,
|
||||
Block<MatrixType,Dim,HDim> >::type AffinePart;
|
||||
/** type of read/write reference to the affine part of the transformation */
|
||||
/** type of read reference to the affine part of the transformation */
|
||||
typedef typename internal::conditional<int(Mode)==int(AffineCompact),
|
||||
MatrixType&,
|
||||
Block<MatrixType,Dim,HDim> >::type AffinePartNested;
|
||||
const MatrixType&,
|
||||
const Block<const MatrixType,Dim,HDim> >::type ConstAffinePart;
|
||||
/** type of a vector */
|
||||
typedef Matrix<Scalar,Dim,1> VectorType;
|
||||
/** type of a read/write reference to the translation part of the rotation */
|
||||
typedef Block<MatrixType,Dim,1> TranslationPart;
|
||||
/** type of a read reference to the translation part of the rotation */
|
||||
typedef const Block<ConstMatrixType,Dim,1> ConstTranslationPart;
|
||||
/** corresponding translation type */
|
||||
typedef Translation<Scalar,Dim> TranslationType;
|
||||
|
||||
@ -336,17 +342,17 @@ public:
|
||||
inline MatrixType& matrix() { return m_matrix; }
|
||||
|
||||
/** \returns a read-only expression of the linear part of the transformation */
|
||||
inline const LinearPart linear() const { return m_matrix.template block<Dim,Dim>(0,0); }
|
||||
inline ConstLinearPart linear() const { return m_matrix.template block<Dim,Dim>(0,0); }
|
||||
/** \returns a writable expression of the linear part of the transformation */
|
||||
inline LinearPart linear() { return m_matrix.template block<Dim,Dim>(0,0); }
|
||||
|
||||
/** \returns a read-only expression of the Dim x HDim affine part of the transformation */
|
||||
inline const AffinePart affine() const { return take_affine_part::run(m_matrix); }
|
||||
inline ConstAffinePart affine() const { return take_affine_part::run(m_matrix); }
|
||||
/** \returns a writable expression of the Dim x HDim affine part of the transformation */
|
||||
inline AffinePart affine() { return take_affine_part::run(m_matrix); }
|
||||
|
||||
/** \returns a read-only expression of the translation vector of the transformation */
|
||||
inline const TranslationPart translation() const { return m_matrix.template block<Dim,1>(0,Dim); }
|
||||
inline ConstTranslationPart translation() const { return m_matrix.template block<Dim,1>(0,Dim); }
|
||||
/** \returns a writable expression of the translation vector of the transformation */
|
||||
inline TranslationPart translation() { return m_matrix.template block<Dim,1>(0,Dim); }
|
||||
|
||||
@ -1083,9 +1089,10 @@ namespace internal {
|
||||
template<typename TransformType> struct transform_take_affine_part {
|
||||
typedef typename TransformType::MatrixType MatrixType;
|
||||
typedef typename TransformType::AffinePart AffinePart;
|
||||
typedef typename TransformType::ConstAffinePart ConstAffinePart;
|
||||
static inline AffinePart run(MatrixType& m)
|
||||
{ return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
|
||||
static inline const AffinePart run(const MatrixType& m)
|
||||
static inline ConstAffinePart run(const MatrixType& m)
|
||||
{ return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
|
||||
};
|
||||
|
||||
@ -1180,7 +1187,7 @@ struct transform_right_product_impl< TransformType, MatrixType, false >
|
||||
EIGEN_STATIC_ASSERT(OtherRows==Dim || OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
|
||||
|
||||
typedef Block<ResultType, Dim, OtherCols> TopLeftLhs;
|
||||
typedef Block<MatrixType, Dim, OtherCols> TopLeftRhs;
|
||||
typedef Block<const MatrixType, Dim, OtherCols> TopLeftRhs;
|
||||
|
||||
ResultType res(other.rows(),other.cols());
|
||||
|
||||
|
@ -65,7 +65,7 @@ void MatrixBase<Derived>::makeHouseholder(
|
||||
RealScalar& beta) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(EssentialPart)
|
||||
VectorBlock<Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size()-1);
|
||||
VectorBlock<const Derived, EssentialPart::SizeAtCompileTime> tail(derived(), 1, size()-1);
|
||||
|
||||
RealScalar tailSqNorm = size()==1 ? RealScalar(0) : tail.squaredNorm();
|
||||
Scalar c0 = coeff(0);
|
||||
|
@ -71,26 +71,26 @@ struct traits<HouseholderSequence<VectorsType,CoeffsType,Side> >
|
||||
template<typename VectorsType, typename CoeffsType, int Side>
|
||||
struct hseq_side_dependent_impl
|
||||
{
|
||||
typedef Block<VectorsType, Dynamic, 1> EssentialVectorType;
|
||||
typedef Block<const VectorsType, Dynamic, 1> EssentialVectorType;
|
||||
typedef HouseholderSequence<VectorsType, CoeffsType, OnTheLeft> HouseholderSequenceType;
|
||||
typedef typename VectorsType::Index Index;
|
||||
static inline const EssentialVectorType essentialVector(const HouseholderSequenceType& h, Index k)
|
||||
{
|
||||
Index start = k+1+h.m_shift;
|
||||
return Block<VectorsType,Dynamic,1>(h.m_vectors, start, k, h.rows()-start, 1);
|
||||
return Block<const VectorsType,Dynamic,1>(h.m_vectors, start, k, h.rows()-start, 1);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename VectorsType, typename CoeffsType>
|
||||
struct hseq_side_dependent_impl<VectorsType, CoeffsType, OnTheRight>
|
||||
{
|
||||
typedef Transpose<Block<VectorsType, 1, Dynamic> > EssentialVectorType;
|
||||
typedef Transpose<Block<const VectorsType, 1, Dynamic> > EssentialVectorType;
|
||||
typedef HouseholderSequence<VectorsType, CoeffsType, OnTheRight> HouseholderSequenceType;
|
||||
typedef typename VectorsType::Index Index;
|
||||
static inline const EssentialVectorType essentialVector(const HouseholderSequenceType& h, Index k)
|
||||
{
|
||||
Index start = k+1+h.m_shift;
|
||||
return Block<VectorsType,1,Dynamic>(h.m_vectors, k, start, 1, h.rows()-start).transpose();
|
||||
return Block<const VectorsType,1,Dynamic>(h.m_vectors, k, start, 1, h.rows()-start).transpose();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -48,12 +48,12 @@ template<typename _MatrixType> class UpperBidiagonalization
|
||||
typedef Matrix<Scalar, ColsAtCompileTime, 1> DiagVectorType;
|
||||
typedef Matrix<Scalar, ColsAtCompileTimeMinusOne, 1> SuperDiagVectorType;
|
||||
typedef HouseholderSequence<
|
||||
MatrixType,
|
||||
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Diagonal<MatrixType,0> >
|
||||
const MatrixType,
|
||||
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Diagonal<const MatrixType,0> >
|
||||
> HouseholderUSequenceType;
|
||||
typedef HouseholderSequence<
|
||||
MatrixType,
|
||||
Diagonal<MatrixType,1>,
|
||||
const MatrixType,
|
||||
Diagonal<const MatrixType,1>,
|
||||
OnTheRight
|
||||
> HouseholderVSequenceType;
|
||||
|
||||
@ -78,16 +78,16 @@ template<typename _MatrixType> class UpperBidiagonalization
|
||||
const MatrixType& householder() const { return m_householder; }
|
||||
const BidiagonalType& bidiagonal() const { return m_bidiagonal; }
|
||||
|
||||
HouseholderUSequenceType householderU() const
|
||||
const HouseholderUSequenceType householderU() const
|
||||
{
|
||||
eigen_assert(m_isInitialized && "UpperBidiagonalization is not initialized.");
|
||||
return HouseholderUSequenceType(m_householder, m_householder.diagonal().conjugate());
|
||||
}
|
||||
|
||||
HouseholderVSequenceType householderV() // const here gives nasty errors and i'm lazy
|
||||
const HouseholderVSequenceType householderV() // const here gives nasty errors and i'm lazy
|
||||
{
|
||||
eigen_assert(m_isInitialized && "UpperBidiagonalization is not initialized.");
|
||||
return HouseholderVSequenceType(m_householder, m_householder.template diagonal<1>(),
|
||||
return HouseholderVSequenceType(m_householder, m_householder.const_derived().template diagonal<1>(),
|
||||
false, m_householder.cols()-1, 1);
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,8 @@ class sparse_diagonal_product_inner_iterator_selector
|
||||
public:
|
||||
inline sparse_diagonal_product_inner_iterator_selector(
|
||||
const SparseDiagonalProductType& expr, Index outer)
|
||||
: Base(expr.lhs().innerVector(outer) .cwiseProduct(expr.rhs().diagonal().transpose()), 0)
|
||||
: Base(expr.lhs().innerVector(outer) .cwiseProduct(expr.rhs().const_cast_derived().diagonal().transpose()), 0)
|
||||
// the const_cast_derived above is to get it to compile. once Sparse is const correct, that shouldn't be needed anymore.
|
||||
{}
|
||||
};
|
||||
|
||||
|
@ -30,16 +30,22 @@
|
||||
|
||||
/** \internal expression type of a column */
|
||||
typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ColXpr;
|
||||
typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, 1, !IsRowMajor> ConstColXpr;
|
||||
/** \internal expression type of a row */
|
||||
typedef Block<Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowXpr;
|
||||
typedef const Block<const Derived, 1, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowXpr;
|
||||
/** \internal expression type of a block of whole columns */
|
||||
typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ColsBlockXpr;
|
||||
typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, Dynamic, !IsRowMajor> ConstColsBlockXpr;
|
||||
/** \internal expression type of a block of whole rows */
|
||||
typedef Block<Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> RowsBlockXpr;
|
||||
typedef const Block<const Derived, Dynamic, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> ConstRowsBlockXpr;
|
||||
/** \internal expression type of a block of whole columns */
|
||||
template<int N> struct NColsBlockXpr { typedef Block<Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
|
||||
template<int N> struct ConstNColsBlockXpr { typedef const Block<const Derived, internal::traits<Derived>::RowsAtCompileTime, N, !IsRowMajor> Type; };
|
||||
/** \internal expression type of a block of whole rows */
|
||||
template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
|
||||
template<int N> struct ConstNRowsBlockXpr { typedef const Block<const Derived, N, internal::traits<Derived>::ColsAtCompileTime, IsRowMajor> Type; };
|
||||
|
||||
|
||||
#endif // not EIGEN_PARSED_BY_DOXYGEN
|
||||
@ -66,9 +72,9 @@ inline Block<Derived> block(Index startRow, Index startCol, Index blockRows, Ind
|
||||
}
|
||||
|
||||
/** This is the const version of block(Index,Index,Index,Index). */
|
||||
inline const Block<Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
|
||||
inline const Block<const Derived> block(Index startRow, Index startCol, Index blockRows, Index blockCols) const
|
||||
{
|
||||
return Block<Derived>(derived(), startRow, startCol, blockRows, blockCols);
|
||||
return Block<const Derived>(derived(), startRow, startCol, blockRows, blockCols);
|
||||
}
|
||||
|
||||
|
||||
@ -90,9 +96,9 @@ inline Block<Derived> topRightCorner(Index cRows, Index cCols)
|
||||
}
|
||||
|
||||
/** This is the const version of topRightCorner(Index, Index).*/
|
||||
inline const Block<Derived> topRightCorner(Index cRows, Index cCols) const
|
||||
inline const Block<const Derived> topRightCorner(Index cRows, Index cCols) const
|
||||
{
|
||||
return Block<Derived>(derived(), 0, cols() - cCols, cRows, cCols);
|
||||
return Block<const Derived>(derived(), 0, cols() - cCols, cRows, cCols);
|
||||
}
|
||||
|
||||
/** \returns an expression of a fixed-size top-right corner of *this.
|
||||
@ -112,9 +118,9 @@ inline Block<Derived, CRows, CCols> topRightCorner()
|
||||
|
||||
/** This is the const version of topRightCorner<int, int>().*/
|
||||
template<int CRows, int CCols>
|
||||
inline const Block<Derived, CRows, CCols> topRightCorner() const
|
||||
inline const Block<const Derived, CRows, CCols> topRightCorner() const
|
||||
{
|
||||
return Block<Derived, CRows, CCols>(derived(), 0, cols() - CCols);
|
||||
return Block<const Derived, CRows, CCols>(derived(), 0, cols() - CCols);
|
||||
}
|
||||
|
||||
|
||||
@ -136,9 +142,9 @@ inline Block<Derived> topLeftCorner(Index cRows, Index cCols)
|
||||
}
|
||||
|
||||
/** This is the const version of topLeftCorner(Index, Index).*/
|
||||
inline const Block<Derived> topLeftCorner(Index cRows, Index cCols) const
|
||||
inline const Block<const Derived> topLeftCorner(Index cRows, Index cCols) const
|
||||
{
|
||||
return Block<Derived>(derived(), 0, 0, cRows, cCols);
|
||||
return Block<const Derived>(derived(), 0, 0, cRows, cCols);
|
||||
}
|
||||
|
||||
/** \returns an expression of a fixed-size top-left corner of *this.
|
||||
@ -158,9 +164,9 @@ inline Block<Derived, CRows, CCols> topLeftCorner()
|
||||
|
||||
/** This is the const version of topLeftCorner<int, int>().*/
|
||||
template<int CRows, int CCols>
|
||||
inline const Block<Derived, CRows, CCols> topLeftCorner() const
|
||||
inline const Block<const Derived, CRows, CCols> topLeftCorner() const
|
||||
{
|
||||
return Block<Derived, CRows, CCols>(derived(), 0, 0);
|
||||
return Block<const Derived, CRows, CCols>(derived(), 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -181,9 +187,9 @@ inline Block<Derived> bottomRightCorner(Index cRows, Index cCols)
|
||||
}
|
||||
|
||||
/** This is the const version of bottomRightCorner(Index, Index).*/
|
||||
inline const Block<Derived> bottomRightCorner(Index cRows, Index cCols) const
|
||||
inline const Block<const Derived> bottomRightCorner(Index cRows, Index cCols) const
|
||||
{
|
||||
return Block<Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
|
||||
return Block<const Derived>(derived(), rows() - cRows, cols() - cCols, cRows, cCols);
|
||||
}
|
||||
|
||||
/** \returns an expression of a fixed-size bottom-right corner of *this.
|
||||
@ -203,9 +209,9 @@ inline Block<Derived, CRows, CCols> bottomRightCorner()
|
||||
|
||||
/** This is the const version of bottomRightCorner<int, int>().*/
|
||||
template<int CRows, int CCols>
|
||||
inline const Block<Derived, CRows, CCols> bottomRightCorner() const
|
||||
inline const Block<const Derived, CRows, CCols> bottomRightCorner() const
|
||||
{
|
||||
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
|
||||
return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, cols() - CCols);
|
||||
}
|
||||
|
||||
|
||||
@ -226,9 +232,9 @@ inline Block<Derived> bottomLeftCorner(Index cRows, Index cCols)
|
||||
}
|
||||
|
||||
/** This is the const version of bottomLeftCorner(Index, Index).*/
|
||||
inline const Block<Derived> bottomLeftCorner(Index cRows, Index cCols) const
|
||||
inline const Block<const Derived> bottomLeftCorner(Index cRows, Index cCols) const
|
||||
{
|
||||
return Block<Derived>(derived(), rows() - cRows, 0, cRows, cCols);
|
||||
return Block<const Derived>(derived(), rows() - cRows, 0, cRows, cCols);
|
||||
}
|
||||
|
||||
/** \returns an expression of a fixed-size bottom-left corner of *this.
|
||||
@ -248,9 +254,9 @@ inline Block<Derived, CRows, CCols> bottomLeftCorner()
|
||||
|
||||
/** This is the const version of bottomLeftCorner<int, int>().*/
|
||||
template<int CRows, int CCols>
|
||||
inline const Block<Derived, CRows, CCols> bottomLeftCorner() const
|
||||
inline const Block<const Derived, CRows, CCols> bottomLeftCorner() const
|
||||
{
|
||||
return Block<Derived, CRows, CCols>(derived(), rows() - CRows, 0);
|
||||
return Block<const Derived, CRows, CCols>(derived(), rows() - CRows, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -270,9 +276,9 @@ inline RowsBlockXpr topRows(Index n)
|
||||
}
|
||||
|
||||
/** This is the const version of topRows(Index).*/
|
||||
inline const RowsBlockXpr topRows(Index n) const
|
||||
inline ConstRowsBlockXpr topRows(Index n) const
|
||||
{
|
||||
return RowsBlockXpr(derived(), 0, 0, n, cols());
|
||||
return ConstRowsBlockXpr(derived(), 0, 0, n, cols());
|
||||
}
|
||||
|
||||
/** \returns a block consisting of the top rows of *this.
|
||||
@ -292,9 +298,9 @@ inline typename NRowsBlockXpr<N>::Type topRows()
|
||||
|
||||
/** This is the const version of topRows<int>().*/
|
||||
template<int N>
|
||||
inline const typename NRowsBlockXpr<N>::Type topRows() const
|
||||
inline typename ConstNRowsBlockXpr<N>::Type topRows() const
|
||||
{
|
||||
return typename NRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols());
|
||||
return typename ConstNRowsBlockXpr<N>::Type(derived(), 0, 0, N, cols());
|
||||
}
|
||||
|
||||
|
||||
@ -314,9 +320,9 @@ inline RowsBlockXpr bottomRows(Index n)
|
||||
}
|
||||
|
||||
/** This is the const version of bottomRows(Index).*/
|
||||
inline const RowsBlockXpr bottomRows(Index n) const
|
||||
inline ConstRowsBlockXpr bottomRows(Index n) const
|
||||
{
|
||||
return RowsBlockXpr(derived(), rows() - n, 0, n, cols());
|
||||
return ConstRowsBlockXpr(derived(), rows() - n, 0, n, cols());
|
||||
}
|
||||
|
||||
/** \returns a block consisting of the bottom rows of *this.
|
||||
@ -336,9 +342,9 @@ inline typename NRowsBlockXpr<N>::Type bottomRows()
|
||||
|
||||
/** This is the const version of bottomRows<int>().*/
|
||||
template<int N>
|
||||
inline const typename NRowsBlockXpr<N>::Type bottomRows() const
|
||||
inline typename ConstNRowsBlockXpr<N>::Type bottomRows() const
|
||||
{
|
||||
return typename NRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols());
|
||||
return typename ConstNRowsBlockXpr<N>::Type(derived(), rows() - N, 0, N, cols());
|
||||
}
|
||||
|
||||
|
||||
@ -359,9 +365,9 @@ inline RowsBlockXpr middleRows(Index startRow, Index numRows)
|
||||
}
|
||||
|
||||
/** This is the const version of middleRows(Index,Index).*/
|
||||
inline const RowsBlockXpr middleRows(Index startRow, Index numRows) const
|
||||
inline ConstRowsBlockXpr middleRows(Index startRow, Index numRows) const
|
||||
{
|
||||
return RowsBlockXpr(derived(), startRow, 0, numRows, cols());
|
||||
return ConstRowsBlockXpr(derived(), startRow, 0, numRows, cols());
|
||||
}
|
||||
|
||||
/** \returns a block consisting of a range of rows of *this.
|
||||
@ -382,9 +388,9 @@ inline typename NRowsBlockXpr<N>::Type middleRows(Index startRow)
|
||||
|
||||
/** This is the const version of middleRows<int>().*/
|
||||
template<int N>
|
||||
inline const typename NRowsBlockXpr<N>::Type middleRows(Index startRow) const
|
||||
inline typename ConstNRowsBlockXpr<N>::Type middleRows(Index startRow) const
|
||||
{
|
||||
return typename NRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
|
||||
return typename ConstNRowsBlockXpr<N>::Type(derived(), startRow, 0, N, cols());
|
||||
}
|
||||
|
||||
|
||||
@ -404,9 +410,9 @@ inline ColsBlockXpr leftCols(Index n)
|
||||
}
|
||||
|
||||
/** This is the const version of leftCols(Index).*/
|
||||
inline const ColsBlockXpr leftCols(Index n) const
|
||||
inline ConstColsBlockXpr leftCols(Index n) const
|
||||
{
|
||||
return ColsBlockXpr(derived(), 0, 0, rows(), n);
|
||||
return ConstColsBlockXpr(derived(), 0, 0, rows(), n);
|
||||
}
|
||||
|
||||
/** \returns a block consisting of the left columns of *this.
|
||||
@ -426,9 +432,9 @@ inline typename NColsBlockXpr<N>::Type leftCols()
|
||||
|
||||
/** This is the const version of leftCols<int>().*/
|
||||
template<int N>
|
||||
inline const typename NColsBlockXpr<N>::Type leftCols() const
|
||||
inline typename ConstNColsBlockXpr<N>::Type leftCols() const
|
||||
{
|
||||
return typename NColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N);
|
||||
return typename ConstNColsBlockXpr<N>::Type(derived(), 0, 0, rows(), N);
|
||||
}
|
||||
|
||||
|
||||
@ -448,9 +454,9 @@ inline ColsBlockXpr rightCols(Index n)
|
||||
}
|
||||
|
||||
/** This is the const version of rightCols(Index).*/
|
||||
inline const ColsBlockXpr rightCols(Index n) const
|
||||
inline ConstColsBlockXpr rightCols(Index n) const
|
||||
{
|
||||
return ColsBlockXpr(derived(), 0, cols() - n, rows(), n);
|
||||
return ConstColsBlockXpr(derived(), 0, cols() - n, rows(), n);
|
||||
}
|
||||
|
||||
/** \returns a block consisting of the right columns of *this.
|
||||
@ -470,9 +476,9 @@ inline typename NColsBlockXpr<N>::Type rightCols()
|
||||
|
||||
/** This is the const version of rightCols<int>().*/
|
||||
template<int N>
|
||||
inline const typename NColsBlockXpr<N>::Type rightCols() const
|
||||
inline typename ConstNColsBlockXpr<N>::Type rightCols() const
|
||||
{
|
||||
return typename NColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N);
|
||||
return typename ConstNColsBlockXpr<N>::Type(derived(), 0, cols() - N, rows(), N);
|
||||
}
|
||||
|
||||
|
||||
@ -493,9 +499,9 @@ inline ColsBlockXpr middleCols(Index startCol, Index numCols)
|
||||
}
|
||||
|
||||
/** This is the const version of middleCols(Index,Index).*/
|
||||
inline const ColsBlockXpr middleCols(Index startCol, Index numCols) const
|
||||
inline ConstColsBlockXpr middleCols(Index startCol, Index numCols) const
|
||||
{
|
||||
return ColsBlockXpr(derived(), 0, startCol, rows(), numCols);
|
||||
return ConstColsBlockXpr(derived(), 0, startCol, rows(), numCols);
|
||||
}
|
||||
|
||||
/** \returns a block consisting of a range of columns of *this.
|
||||
@ -516,9 +522,9 @@ inline typename NColsBlockXpr<N>::Type middleCols(Index startCol)
|
||||
|
||||
/** This is the const version of middleCols<int>().*/
|
||||
template<int N>
|
||||
inline const typename NColsBlockXpr<N>::Type middleCols(Index startCol) const
|
||||
inline typename ConstNColsBlockXpr<N>::Type middleCols(Index startCol) const
|
||||
{
|
||||
return typename NColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
|
||||
return typename ConstNColsBlockXpr<N>::Type(derived(), 0, startCol, rows(), N);
|
||||
}
|
||||
|
||||
|
||||
@ -547,9 +553,9 @@ inline Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol
|
||||
|
||||
/** This is the const version of block<>(Index, Index). */
|
||||
template<int BlockRows, int BlockCols>
|
||||
inline const Block<Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) const
|
||||
inline const Block<const Derived, BlockRows, BlockCols> block(Index startRow, Index startCol) const
|
||||
{
|
||||
return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
|
||||
return Block<const Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
|
||||
}
|
||||
|
||||
/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.
|
||||
@ -564,9 +570,9 @@ inline ColXpr col(Index i)
|
||||
}
|
||||
|
||||
/** This is the const version of col(). */
|
||||
inline const ColXpr col(Index i) const
|
||||
inline ConstColXpr col(Index i) const
|
||||
{
|
||||
return ColXpr(derived(), i);
|
||||
return ConstColXpr(derived(), i);
|
||||
}
|
||||
|
||||
/** \returns an expression of the \a i-th row of *this. Note that the numbering starts at 0.
|
||||
@ -581,9 +587,9 @@ inline RowXpr row(Index i)
|
||||
}
|
||||
|
||||
/** This is the const version of row(). */
|
||||
inline const RowXpr row(Index i) const
|
||||
inline ConstRowXpr row(Index i) const
|
||||
{
|
||||
return RowXpr(derived(), i);
|
||||
return ConstRowXpr(derived(), i);
|
||||
}
|
||||
|
||||
#endif // EIGEN_BLOCKMETHODS_H
|
||||
|
@ -39,6 +39,7 @@ template<typename MatrixType> void block(const MatrixType& m)
|
||||
Index cols = m.cols();
|
||||
|
||||
MatrixType m1 = MatrixType::Random(rows, cols),
|
||||
m1_copy = m1,
|
||||
m2 = MatrixType::Random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::Zero(rows, cols),
|
||||
@ -58,8 +59,17 @@ template<typename MatrixType> void block(const MatrixType& m)
|
||||
//check row() and col()
|
||||
VERIFY_IS_EQUAL(m1.col(c1).transpose(), m1.transpose().row(c1));
|
||||
//check operator(), both constant and non-constant, on row() and col()
|
||||
m1.row(r1) += s1 * m1.row(r2);
|
||||
m1.col(c1) += s1 * m1.col(c2);
|
||||
m1 = m1_copy;
|
||||
m1.row(r1) += s1 * m1_copy.row(r2);
|
||||
VERIFY_IS_APPROX(m1.row(r1), m1_copy.row(r1) + s1 * m1_copy.row(r2));
|
||||
// check nested block xpr on lhs
|
||||
m1.row(r1).row(0) += s1 * m1_copy.row(r2);
|
||||
VERIFY_IS_APPROX(m1.row(r1), m1_copy.row(r1) + Scalar(2) * s1 * m1_copy.row(r2));
|
||||
m1 = m1_copy;
|
||||
m1.col(c1) += s1 * m1_copy.col(c2);
|
||||
VERIFY_IS_APPROX(m1.col(c1), m1_copy.col(c1) + s1 * m1_copy.col(c2));
|
||||
m1.col(c1).col(0) += s1 * m1_copy.col(c2);
|
||||
VERIFY_IS_APPROX(m1.col(c1), m1_copy.col(c1) + Scalar(2) * s1 * m1_copy.col(c2));
|
||||
|
||||
//check block()
|
||||
Matrix<Scalar,Dynamic,Dynamic> b1(1,1); b1(0,0) = m1(r1,c1);
|
||||
|
@ -24,7 +24,13 @@
|
||||
|
||||
static int nb_temporaries;
|
||||
|
||||
#define EIGEN_DEBUG_MATRIX_CTOR { if(size!=0) nb_temporaries++; }
|
||||
void on_temporary_creation(int size) {
|
||||
// here's a great place to set a breakpoint when debugging failures in this test!
|
||||
if(size!=0) nb_temporaries++;
|
||||
}
|
||||
|
||||
|
||||
#define EIGEN_DEBUG_MATRIX_CTOR { on_temporary_creation(size); }
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
@ -163,7 +163,7 @@ class MatrixFunction<MatrixType, 1>
|
||||
void permuteSchur();
|
||||
void swapEntriesInSchur(Index index);
|
||||
void computeBlockAtomic();
|
||||
Block<MatrixType> block(const MatrixType& A, Index i, Index j);
|
||||
Block<MatrixType> block(MatrixType& A, Index i, Index j);
|
||||
void computeOffDiagonal();
|
||||
DynMatrixType solveTriangularSylvester(const DynMatrixType& A, const DynMatrixType& B, const DynMatrixType& C);
|
||||
|
||||
@ -385,7 +385,7 @@ void MatrixFunction<MatrixType,1>::computeBlockAtomic()
|
||||
|
||||
/** \brief Return block of matrix according to blocking given by #m_blockStart */
|
||||
template <typename MatrixType>
|
||||
Block<MatrixType> MatrixFunction<MatrixType,1>::block(const MatrixType& A, Index i, Index j)
|
||||
Block<MatrixType> MatrixFunction<MatrixType,1>::block(MatrixType& A, Index i, Index j)
|
||||
{
|
||||
return A.block(m_blockStart(i), m_blockStart(j), m_clusterSize(i), m_clusterSize(j));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user