aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r--Eigen/src/Core/AnyMatrixBase.h13
-rw-r--r--Eigen/src/Core/Assign.h15
-rw-r--r--Eigen/src/Core/Block.h75
-rw-r--r--Eigen/src/Core/Coeffs.h42
-rw-r--r--Eigen/src/Core/CommaInitializer.h8
-rw-r--r--Eigen/src/Core/Cwise.h211
-rw-r--r--Eigen/src/Core/CwiseBinaryOp.h213
-rw-r--r--Eigen/src/Core/CwiseNullaryOp.h118
-rw-r--r--Eigen/src/Core/CwiseUnaryOp.h232
-rw-r--r--Eigen/src/Core/CwiseUnaryView.h81
-rw-r--r--Eigen/src/Core/DenseBase.h496
-rw-r--r--Eigen/src/Core/DenseStorageBase.h601
-rw-r--r--Eigen/src/Core/Diagonal.h2
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h6
-rw-r--r--Eigen/src/Core/DiagonalProduct.h1
-rw-r--r--Eigen/src/Core/Dot.h2
-rw-r--r--Eigen/src/Core/Flagged.h149
-rw-r--r--Eigen/src/Core/ForceAlignedAccess.h151
-rw-r--r--Eigen/src/Core/Fuzzy.h33
-rw-r--r--Eigen/src/Core/GenericPacketMath.h22
-rw-r--r--Eigen/src/Core/IO.h22
-rw-r--r--Eigen/src/Core/Map.h24
-rw-r--r--Eigen/src/Core/MapBase.h73
-rw-r--r--Eigen/src/Core/Matrix.h556
-rw-r--r--Eigen/src/Core/MatrixBase.h621
-rw-r--r--Eigen/src/Core/Minor.h8
-rw-r--r--Eigen/src/Core/NoAlias.h14
-rw-r--r--Eigen/src/Core/Product.h6
-rw-r--r--Eigen/src/Core/ProductBase.h38
-rw-r--r--Eigen/src/Core/Redux.h14
-rw-r--r--Eigen/src/Core/ReturnByValue.h2
-rw-r--r--Eigen/src/Core/SelfAdjointView.h8
-rw-r--r--Eigen/src/Core/SelfCwiseBinaryOp.h141
-rw-r--r--Eigen/src/Core/SolveTriangular.h8
-rw-r--r--Eigen/src/Core/StableNorm.h10
-rw-r--r--Eigen/src/Core/Swap.h20
-rw-r--r--Eigen/src/Core/Transpose.h90
-rw-r--r--Eigen/src/Core/TriangularMatrix.h4
-rw-r--r--Eigen/src/Core/VectorBlock.h49
-rw-r--r--Eigen/src/Core/Visitor.h24
-rw-r--r--Eigen/src/Core/arch/SSE/PacketMath.h26
-rw-r--r--Eigen/src/Core/products/GeneralUnrolled.h7
-rw-r--r--Eigen/src/Core/products/TriangularMatrixVector.h2
-rw-r--r--Eigen/src/Core/util/Constants.h16
-rw-r--r--Eigen/src/Core/util/ForwardDeclarations.h24
-rw-r--r--Eigen/src/Core/util/Macros.h118
-rw-r--r--Eigen/src/Core/util/XprHelper.h70
47 files changed, 2217 insertions, 2249 deletions
diff --git a/Eigen/src/Core/AnyMatrixBase.h b/Eigen/src/Core/AnyMatrixBase.h
index eddf2d232..d1c16923b 100644
--- a/Eigen/src/Core/AnyMatrixBase.h
+++ b/Eigen/src/Core/AnyMatrixBase.h
@@ -37,11 +37,16 @@
*/
template<typename Derived> struct AnyMatrixBase
{
- typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
+// typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
+ /** \returns a reference to the derived object */
Derived& derived() { return *static_cast<Derived*>(this); }
+ /** \returns a const reference to the derived object */
const Derived& derived() const { return *static_cast<const Derived*>(this); }
+ inline Derived& const_cast_derived() const
+ { return *static_cast<Derived*>(const_cast<AnyMatrixBase*>(this)); }
+
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
inline int rows() const { return derived().rows(); }
/** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
@@ -99,7 +104,7 @@ template<typename Derived> struct AnyMatrixBase
* special matrix without having to modify MatrixBase */
template<typename Derived>
template<typename OtherDerived>
-Derived& MatrixBase<Derived>::operator=(const AnyMatrixBase<OtherDerived> &other)
+Derived& DenseBase<Derived>::operator=(const AnyMatrixBase<OtherDerived> &other)
{
other.derived().evalTo(derived());
return derived();
@@ -107,7 +112,7 @@ Derived& MatrixBase<Derived>::operator=(const AnyMatrixBase<OtherDerived> &other
template<typename Derived>
template<typename OtherDerived>
-Derived& MatrixBase<Derived>::operator+=(const AnyMatrixBase<OtherDerived> &other)
+Derived& DenseBase<Derived>::operator+=(const AnyMatrixBase<OtherDerived> &other)
{
other.derived().addTo(derived());
return derived();
@@ -115,7 +120,7 @@ Derived& MatrixBase<Derived>::operator+=(const AnyMatrixBase<OtherDerived> &othe
template<typename Derived>
template<typename OtherDerived>
-Derived& MatrixBase<Derived>::operator-=(const AnyMatrixBase<OtherDerived> &other)
+Derived& DenseBase<Derived>::operator-=(const AnyMatrixBase<OtherDerived> &other)
{
other.derived().subTo(derived());
return derived();
diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h
index 48a432128..e5c17b3f4 100644
--- a/Eigen/src/Core/Assign.h
+++ b/Eigen/src/Core/Assign.h
@@ -470,13 +470,13 @@ struct ei_assign_impl<Derived1, Derived2, SliceVectorizedTraversal, NoUnrolling>
};
/***************************************************************************
-* Part 4 : implementation of MatrixBase methods
+* Part 4 : implementation of DenseBase methods
***************************************************************************/
template<typename Derived>
template<typename OtherDerived>
-EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>
- ::lazyAssign(const MatrixBase<OtherDerived>& other)
+EIGEN_STRONG_INLINE Derived& DenseBase<Derived>
+ ::lazyAssign(const DenseBase<OtherDerived>& other)
{
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
EIGEN_STATIC_ASSERT((ei_is_same_type<typename Derived::Scalar, typename OtherDerived::Scalar>::ret),
@@ -522,16 +522,21 @@ struct ei_assign_selector<Derived,OtherDerived,true,true> {
template<typename Derived>
template<typename OtherDerived>
-EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase<OtherDerived>& other)
+EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
{
return ei_assign_selector<Derived,OtherDerived>::run(derived(), other.derived());
}
template<typename Derived>
-EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other)
+EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase& other)
{
return ei_assign_selector<Derived,Derived>::run(derived(), other.derived());
}
+template<typename Derived>
+EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::operator=(const MatrixBase& other)
+{
+ return ei_assign_selector<Derived,Derived>::run(derived(), other.derived());
+}
#endif // EIGEN_ASSIGN_H
diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h
index f9bbf473d..461652410 100644
--- a/Eigen/src/Core/Block.h
+++ b/Eigen/src/Core/Block.h
@@ -33,14 +33,10 @@
* \param MatrixType the type of the object in which we are taking a block
* \param BlockRows the number of rows of the block we are taking at compile time (optional)
* \param BlockCols the number of columns of the block we are taking at compile time (optional)
- * \param _PacketAccess \internal used to enforce aligned loads in expressions such as
- * \code mat.block() += other; \endcode. Possible values are
- * \c AsRequested (default) and \c EnforceAlignedAccess.
- * See class MapBase for more details.
* \param _DirectAccessStatus \internal used for partial specialization
*
* This class represents an expression of either a fixed-size or dynamic-size block. It is the return
- * type of MatrixBase::block(int,int,int,int) and MatrixBase::block<int,int>(int,int) and
+ * type of DenseBase::block(int,int,int,int) and DenseBase::block<int,int>(int,int) and
* most of the time this is the only way it is used.
*
* However, if you want to directly maniputate block expressions,
@@ -59,10 +55,10 @@
* \include class_FixedBlock.cpp
* Output: \verbinclude class_FixedBlock.out
*
- * \sa MatrixBase::block(int,int,int,int), MatrixBase::block(int,int), class VectorBlock
+ * \sa DenseBase::block(int,int,int,int), DenseBase::block(int,int), class VectorBlock
*/
-template<typename MatrixType, int BlockRows, int BlockCols, int _PacketAccess, int _DirectAccessStatus>
-struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _PacketAccess, _DirectAccessStatus> >
+template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessStatus>
+struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> > : ei_traits<MatrixType>
{
typedef typename ei_traits<MatrixType>::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
@@ -80,17 +76,12 @@ struct ei_traits<Block<MatrixType, BlockRows, BlockCols, _PacketAccess, _DirectA
MaskPacketAccessBit = (InnerMaxSize == Dynamic || (InnerSize >= ei_packet_traits<Scalar>::size))
? PacketAccessBit : 0,
FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
- Flags = (ei_traits<MatrixType>::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit)) | FlagsLinearAccessBit,
- CoeffReadCost = ei_traits<MatrixType>::CoeffReadCost,
- PacketAccess = _PacketAccess
+ Flags = (ei_traits<MatrixType>::Flags & (HereditaryBits | MaskPacketAccessBit | DirectAccessBit)) | FlagsLinearAccessBit
};
- typedef typename ei_meta_if<int(PacketAccess)==EnforceAlignedAccess,
- Block<MatrixType, BlockRows, BlockCols, _PacketAccess, _DirectAccessStatus>&,
- Block<MatrixType, BlockRows, BlockCols, EnforceAlignedAccess, _DirectAccessStatus> >::ret AlignedDerivedType;
};
-template<typename MatrixType, int BlockRows, int BlockCols, int PacketAccess, int _DirectAccessStatus> class Block
- : public MatrixBase<Block<MatrixType, BlockRows, BlockCols, PacketAccess, _DirectAccessStatus> >
+template<typename MatrixType, int BlockRows, int BlockCols, int _DirectAccessStatus> class Block
+ :public MatrixType::template MakeBase< Block<MatrixType, BlockRows, BlockCols, _DirectAccessStatus> >::Type
{
public:
@@ -218,26 +209,18 @@ template<typename MatrixType, int BlockRows, int BlockCols, int PacketAccess, in
};
/** \internal */
-template<typename MatrixType, int BlockRows, int BlockCols, int PacketAccess>
-class Block<MatrixType,BlockRows,BlockCols,PacketAccess,HasDirectAccess>
- : public MapBase<Block<MatrixType, BlockRows, BlockCols,PacketAccess,HasDirectAccess> >
+template<typename MatrixType, int BlockRows, int BlockCols>
+class Block<MatrixType,BlockRows,BlockCols,HasDirectAccess>
+ : public MapBase<Block<MatrixType, BlockRows, BlockCols,HasDirectAccess>,
+ typename MatrixType::template MakeBase< Block<MatrixType, BlockRows, BlockCols,HasDirectAccess> >::Type>
{
public:
- _EIGEN_GENERIC_PUBLIC_INTERFACE(Block, MapBase<Block>)
-
- class InnerIterator;
- typedef typename ei_traits<Block>::AlignedDerivedType AlignedDerivedType;
- friend class Block<MatrixType,BlockRows,BlockCols,PacketAccess==int(EnforceAlignedAccess)?AsRequested:EnforceAlignedAccess,HasDirectAccess>;
+ typedef MapBase<Block, typename MatrixType::template MakeBase<Block>::Type> Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Block)
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
- AlignedDerivedType _convertToEnforceAlignedAccess()
- {
- return Block<MatrixType,BlockRows,BlockCols,EnforceAlignedAccess,HasDirectAccess>
- (m_matrix, Base::m_data, Base::m_rows.value(), Base::m_cols.value());
- }
-
/** Column or Row constructor
*/
inline Block(const MatrixType& matrix, int i)
@@ -318,7 +301,7 @@ class Block<MatrixType,BlockRows,BlockCols,PacketAccess,HasDirectAccess>
* \sa class Block, block(int,int)
*/
template<typename Derived>
-inline typename BlockReturnType<Derived>::Type MatrixBase<Derived>
+inline typename BlockReturnType<Derived>::Type DenseBase<Derived>
::block(int startRow, int startCol, int blockRows, int blockCols)
{
return typename BlockReturnType<Derived>::Type(derived(), startRow, startCol, blockRows, blockCols);
@@ -326,7 +309,7 @@ inline typename BlockReturnType<Derived>::Type MatrixBase<Derived>
/** This is the const version of block(int,int,int,int). */
template<typename Derived>
-inline const typename BlockReturnType<Derived>::Type MatrixBase<Derived>
+inline const typename BlockReturnType<Derived>::Type DenseBase<Derived>
::block(int startRow, int startCol, int blockRows, int blockCols) const
{
return typename BlockReturnType<Derived>::Type(derived(), startRow, startCol, blockRows, blockCols);
@@ -349,7 +332,7 @@ inline const typename BlockReturnType<Derived>::Type MatrixBase<Derived>
* \sa class Block, block(int,int,int,int)
*/
template<typename Derived>
-inline typename BlockReturnType<Derived>::Type MatrixBase<Derived>
+inline typename BlockReturnType<Derived>::Type DenseBase<Derived>
::corner(CornerType type, int cRows, int cCols)
{
switch(type)
@@ -370,7 +353,7 @@ inline typename BlockReturnType<Derived>::Type MatrixBase<Derived>
/** This is the const version of corner(CornerType, int, int).*/
template<typename Derived>
inline const typename BlockReturnType<Derived>::Type
-MatrixBase<Derived>::corner(CornerType type, int cRows, int cCols) const
+DenseBase<Derived>::corner(CornerType type, int cRows, int cCols) const
{
switch(type)
{
@@ -402,7 +385,7 @@ MatrixBase<Derived>::corner(CornerType type, int cRows, int cCols) const
template<typename Derived>
template<int CRows, int CCols>
inline typename BlockReturnType<Derived, CRows, CCols>::Type
-MatrixBase<Derived>::corner(CornerType type)
+DenseBase<Derived>::corner(CornerType type)
{
switch(type)
{
@@ -423,7 +406,7 @@ MatrixBase<Derived>::corner(CornerType type)
template<typename Derived>
template<int CRows, int CCols>
inline const typename BlockReturnType<Derived, CRows, CCols>::Type
-MatrixBase<Derived>::corner(CornerType type) const
+DenseBase<Derived>::corner(CornerType type) const
{
switch(type)
{
@@ -459,7 +442,7 @@ MatrixBase<Derived>::corner(CornerType type) const
template<typename Derived>
template<int BlockRows, int BlockCols>
inline typename BlockReturnType<Derived, BlockRows, BlockCols>::Type
-MatrixBase<Derived>::block(int startRow, int startCol)
+DenseBase<Derived>::block(int startRow, int startCol)
{
return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
}
@@ -468,7 +451,7 @@ MatrixBase<Derived>::block(int startRow, int startCol)
template<typename Derived>
template<int BlockRows, int BlockCols>
inline const typename BlockReturnType<Derived, BlockRows, BlockCols>::Type
-MatrixBase<Derived>::block(int startRow, int startCol) const
+DenseBase<Derived>::block(int startRow, int startCol) const
{
return Block<Derived, BlockRows, BlockCols>(derived(), startRow, startCol);
}
@@ -480,16 +463,16 @@ MatrixBase<Derived>::block(int startRow, int startCol) const
*
* \sa row(), class Block */
template<typename Derived>
-inline typename MatrixBase<Derived>::ColXpr
-MatrixBase<Derived>::col(int i)
+inline typename DenseBase<Derived>::ColXpr
+DenseBase<Derived>::col(int i)
{
return ColXpr(derived(), i);
}
/** This is the const version of col(). */
template<typename Derived>
-inline const typename MatrixBase<Derived>::ColXpr
-MatrixBase<Derived>::col(int i) const
+inline const typename DenseBase<Derived>::ColXpr
+DenseBase<Derived>::col(int i) const
{
return ColXpr(derived(), i);
}
@@ -501,16 +484,16 @@ MatrixBase<Derived>::col(int i) const
*
* \sa col(), class Block */
template<typename Derived>
-inline typename MatrixBase<Derived>::RowXpr
-MatrixBase<Derived>::row(int i)
+inline typename DenseBase<Derived>::RowXpr
+DenseBase<Derived>::row(int i)
{
return RowXpr(derived(), i);
}
/** This is the const version of row(). */
template<typename Derived>
-inline const typename MatrixBase<Derived>::RowXpr
-MatrixBase<Derived>::row(int i) const
+inline const typename DenseBase<Derived>::RowXpr
+DenseBase<Derived>::row(int i) const
{
return RowXpr(derived(), i);
}
diff --git a/Eigen/src/Core/Coeffs.h b/Eigen/src/Core/Coeffs.h
index 9a954babc..ebfd0c80e 100644
--- a/Eigen/src/Core/Coeffs.h
+++ b/Eigen/src/Core/Coeffs.h
@@ -40,7 +40,7 @@
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::CoeffReturnType DenseBase<Derived>
::coeff(int row, int col) const
{
ei_internal_assert(row >= 0 && row < rows()
@@ -53,7 +53,7 @@ EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBa
* \sa operator()(int,int), operator[](int) const
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::CoeffReturnType DenseBase<Derived>
::operator()(int row, int col) const
{
ei_assert(row >= 0 && row < rows()
@@ -76,7 +76,7 @@ EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBa
* \sa operator()(int,int), coeff(int, int) const, coeffRef(int)
*/
template<typename Derived>
-EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
+EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& DenseBase<Derived>
::coeffRef(int row, int col)
{
ei_internal_assert(row >= 0 && row < rows()
@@ -89,7 +89,7 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
* \sa operator()(int,int) const, operator[](int)
*/
template<typename Derived>
-EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
+EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& DenseBase<Derived>
::operator()(int row, int col)
{
ei_assert(row >= 0 && row < rows()
@@ -112,7 +112,7 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::CoeffReturnType DenseBase<Derived>
::coeff(int index) const
{
ei_internal_assert(index >= 0 && index < size());
@@ -127,7 +127,7 @@ EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBa
* z() const, w() const
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::CoeffReturnType DenseBase<Derived>
::operator[](int index) const
{
ei_assert(index >= 0 && index < size());
@@ -144,7 +144,7 @@ EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBa
* z() const, w() const
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBase<Derived>
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::CoeffReturnType DenseBase<Derived>
::operator()(int index) const
{
ei_assert(index >= 0 && index < size());
@@ -166,7 +166,7 @@ EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::CoeffReturnType MatrixBa
* \sa operator[](int), coeff(int) const, coeffRef(int,int)
*/
template<typename Derived>
-EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
+EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& DenseBase<Derived>
::coeffRef(int index)
{
ei_internal_assert(index >= 0 && index < size());
@@ -180,7 +180,7 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
*/
template<typename Derived>
-EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
+EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& DenseBase<Derived>
::operator[](int index)
{
ei_assert(index >= 0 && index < size());
@@ -196,7 +196,7 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
*/
template<typename Derived>
-EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
+EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& DenseBase<Derived>
::operator()(int index)
{
ei_assert(index >= 0 && index < size());
@@ -254,7 +254,7 @@ EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
template<typename Derived>
template<int LoadMode>
EIGEN_STRONG_INLINE typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type
-MatrixBase<Derived>::packet(int row, int col) const
+DenseBase<Derived>::packet(int row, int col) const
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
@@ -271,7 +271,7 @@ MatrixBase<Derived>::packet(int row, int col) const
*/
template<typename Derived>
template<int StoreMode>
-EIGEN_STRONG_INLINE void MatrixBase<Derived>::writePacket
+EIGEN_STRONG_INLINE void DenseBase<Derived>::writePacket
(int row, int col, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x)
{
ei_internal_assert(row >= 0 && row < rows()
@@ -290,7 +290,7 @@ EIGEN_STRONG_INLINE void MatrixBase<Derived>::writePacket
template<typename Derived>
template<int LoadMode>
EIGEN_STRONG_INLINE typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type
-MatrixBase<Derived>::packet(int index) const
+DenseBase<Derived>::packet(int index) const
{
ei_internal_assert(index >= 0 && index < size());
return derived().template packet<LoadMode>(index);
@@ -306,7 +306,7 @@ MatrixBase<Derived>::packet(int index) const
*/
template<typename Derived>
template<int StoreMode>
-EIGEN_STRONG_INLINE void MatrixBase<Derived>::writePacket
+EIGEN_STRONG_INLINE void DenseBase<Derived>::writePacket
(int index, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x)
{
ei_internal_assert(index >= 0 && index < size());
@@ -324,7 +324,7 @@ EIGEN_STRONG_INLINE void MatrixBase<Derived>::writePacket
*/
template<typename Derived>
template<typename OtherDerived>
-EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyCoeff(int row, int col, const MatrixBase<OtherDerived>& other)
+EIGEN_STRONG_INLINE void DenseBase<Derived>::copyCoeff(int row, int col, const DenseBase<OtherDerived>& other)
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
@@ -340,7 +340,7 @@ EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyCoeff(int row, int col, const
*/
template<typename Derived>
template<typename OtherDerived>
-EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyCoeff(int index, const MatrixBase<OtherDerived>& other)
+EIGEN_STRONG_INLINE void DenseBase<Derived>::copyCoeff(int index, const DenseBase<OtherDerived>& other)
{
ei_internal_assert(index >= 0 && index < size());
derived().coeffRef(index) = other.derived().coeff(index);
@@ -355,7 +355,7 @@ EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyCoeff(int index, const MatrixB
*/
template<typename Derived>
template<typename OtherDerived, int StoreMode, int LoadMode>
-EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyPacket(int row, int col, const MatrixBase<OtherDerived>& other)
+EIGEN_STRONG_INLINE void DenseBase<Derived>::copyPacket(int row, int col, const DenseBase<OtherDerived>& other)
{
ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols());
@@ -372,7 +372,7 @@ EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyPacket(int row, int col, const
*/
template<typename Derived>
template<typename OtherDerived, int StoreMode, int LoadMode>
-EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyPacket(int index, const MatrixBase<OtherDerived>& other)
+EIGEN_STRONG_INLINE void DenseBase<Derived>::copyPacket(int index, const DenseBase<OtherDerived>& other)
{
ei_internal_assert(index >= 0 && index < size());
derived().template writePacket<StoreMode>(index,
@@ -382,14 +382,14 @@ EIGEN_STRONG_INLINE void MatrixBase<Derived>::copyPacket(int index, const Matrix
template<typename Derived, bool JustReturnZero>
struct ei_first_aligned_impl
{
- inline static int run(const MatrixBase<Derived>&)
+ inline static int run(const DenseBase<Derived>&)
{ return 0; }
};
template<typename Derived>
struct ei_first_aligned_impl<Derived, false>
{
- inline static int run(const MatrixBase<Derived>& m)
+ inline static int run(const DenseBase<Derived>& m)
{
return ei_first_aligned(&m.const_cast_derived().coeffRef(0,0), m.size());
}
@@ -401,7 +401,7 @@ struct ei_first_aligned_impl<Derived, false>
* documentation.
*/
template<typename Derived>
-inline static int ei_first_aligned(const MatrixBase<Derived>& m)
+inline static int ei_first_aligned(const DenseBase<Derived>& m)
{
return ei_first_aligned_impl
<Derived, (Derived::Flags & AlignedBit) || !(Derived::Flags & DirectAccessBit)>
diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h
index e86f47ad0..a312b40f5 100644
--- a/Eigen/src/Core/CommaInitializer.h
+++ b/Eigen/src/Core/CommaInitializer.h
@@ -47,7 +47,7 @@ struct CommaInitializer
}
template<typename OtherDerived>
- inline CommaInitializer(MatrixType& mat, const MatrixBase<OtherDerived>& other)
+ inline CommaInitializer(MatrixType& mat, const DenseBase<OtherDerived>& other)
: m_matrix(mat), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
{
m_matrix.block(0, 0, other.rows(), other.cols()) = other;
@@ -73,7 +73,7 @@ struct CommaInitializer
/* inserts a matrix expression in the target matrix */
template<typename OtherDerived>
- CommaInitializer& operator,(const MatrixBase<OtherDerived>& other)
+ CommaInitializer& operator,(const DenseBase<OtherDerived>& other)
{
if (m_col==m_matrix.cols())
{
@@ -130,7 +130,7 @@ struct CommaInitializer
* \sa CommaInitializer::finished(), class CommaInitializer
*/
template<typename Derived>
-inline CommaInitializer<Derived> MatrixBase<Derived>::operator<< (const Scalar& s)
+inline CommaInitializer<Derived> DenseBase<Derived>::operator<< (const Scalar& s)
{
return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);
}
@@ -139,7 +139,7 @@ inline CommaInitializer<Derived> MatrixBase<Derived>::operator<< (const Scalar&
template<typename Derived>
template<typename OtherDerived>
inline CommaInitializer<Derived>
-MatrixBase<Derived>::operator<<(const MatrixBase<OtherDerived>& other)
+DenseBase<Derived>::operator<<(const DenseBase<OtherDerived>& other)
{
return CommaInitializer<Derived>(*static_cast<Derived *>(this), other);
}
diff --git a/Eigen/src/Core/Cwise.h b/Eigen/src/Core/Cwise.h
deleted file mode 100644
index 4f3d641cb..000000000
--- a/Eigen/src/Core/Cwise.h
+++ /dev/null
@@ -1,211 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// Eigen is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 3 of the License, or (at your option) any later version.
-//
-// Alternatively, you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of
-// the License, or (at your option) any later version.
-//
-// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License and a copy of the GNU General Public License along with
-// Eigen. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef EIGEN_CWISE_H
-#define EIGEN_CWISE_H
-
-/** \internal
- * convenient macro to defined the return type of a cwise binary operation */
-#define EIGEN_CWISE_BINOP_RETURN_TYPE(OP) \
- CwiseBinaryOp<OP<typename ei_traits<ExpressionType>::Scalar>, ExpressionType, OtherDerived>
-
-#define EIGEN_CWISE_PRODUCT_RETURN_TYPE \
- CwiseBinaryOp< \
- ei_scalar_product_op< \
- typename ei_scalar_product_traits< \
- typename ei_traits<ExpressionType>::Scalar, \
- typename ei_traits<OtherDerived>::Scalar \
- >::ReturnType \
- >, \
- ExpressionType, \
- OtherDerived \
- >
-
-/** \internal
- * convenient macro to defined the return type of a cwise unary operation */
-#define EIGEN_CWISE_UNOP_RETURN_TYPE(OP) \
- CwiseUnaryOp<OP<typename ei_traits<ExpressionType>::Scalar>, ExpressionType>
-
-/** \internal
- * convenient macro to defined the return type of a cwise comparison to a scalar */
-#define EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(OP) \
- CwiseBinaryOp<OP<typename ei_traits<ExpressionType>::Scalar>, ExpressionType, \
- typename ExpressionType::ConstantReturnType >
-
-/** \class Cwise
- *
- * \brief Pseudo expression providing additional coefficient-wise operations
- *
- * \param ExpressionType the type of the object on which to do coefficient-wise operations
- *
- * This class represents an expression with additional coefficient-wise features.
- * It is the return type of MatrixBase::cwise()
- * and most of the time this is the only way it is used.
- *
- * Note that some methods are defined in the \ref Array_Module array module.
- *
- * Example: \include MatrixBase_cwise_const.cpp
- * Output: \verbinclude MatrixBase_cwise_const.out
- *
- * \sa MatrixBase::cwise() const, MatrixBase::cwise()
- */
-template<typename ExpressionType> class Cwise
-{
- public:
-
- typedef typename ei_traits<ExpressionType>::Scalar Scalar;
- typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
- ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
- typedef CwiseUnaryOp<ei_scalar_add_op<Scalar>, ExpressionType> ScalarAddReturnType;
-
- inline Cwise(const ExpressionType& matrix) : m_matrix(matrix) {}
-
- /** \internal */
- inline const ExpressionType& _expression() const { return m_matrix; }
-
- template<typename OtherDerived>
- const EIGEN_CWISE_PRODUCT_RETURN_TYPE
- operator*(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
- operator/(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
- min(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
- max(const MatrixBase<OtherDerived> &other) const;
-
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) abs() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) abs2() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) square() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) cube() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) inverse() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) sqrt() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) exp() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) log() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) cos() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) sin() const;
- const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) pow(const Scalar& exponent) const;
-
- const ScalarAddReturnType
- operator+(const Scalar& scalar) const;
-
- /** \relates Cwise */
- friend const ScalarAddReturnType
- operator+(const Scalar& scalar, const Cwise& mat)
- { return mat + scalar; }
-
- ExpressionType& operator+=(const Scalar& scalar);
-
- const ScalarAddReturnType
- operator-(const Scalar& scalar) const;
-
- ExpressionType& operator-=(const Scalar& scalar);
-
- template<typename OtherDerived>
- inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived>
- inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
- operator<(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
- operator<=(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
- operator>(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
- operator>=(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
- operator==(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
- operator!=(const MatrixBase<OtherDerived>& other) const;
-
- // comparisons to a scalar value
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
- operator<(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
- operator<=(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
- operator>(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
- operator>=(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
- operator==(Scalar s) const;
-
- const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
- operator!=(Scalar s) const;
-
- // allow to extend Cwise outside Eigen
- #ifdef EIGEN_CWISE_PLUGIN
- #include EIGEN_CWISE_PLUGIN
- #endif
-
- protected:
- ExpressionTypeNested m_matrix;
-};
-
-/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
- *
- * Example: \include MatrixBase_cwise_const.cpp
- * Output: \verbinclude MatrixBase_cwise_const.out
- *
- * \sa class Cwise, cwise()
- */
-template<typename Derived>
-inline const Cwise<Derived>
-MatrixBase<Derived>::cwise() const
-{
- return derived();
-}
-
-/** \returns a Cwise wrapper of *this providing additional coefficient-wise operations
- *
- * Example: \include MatrixBase_cwise.cpp
- * Output: \verbinclude MatrixBase_cwise.out
- *
- * \sa class Cwise, cwise() const
- */
-template<typename Derived>
-inline Cwise<Derived>
-MatrixBase<Derived>::cwise()
-{
- return derived();
-}
-
-#endif // EIGEN_CWISE_H
diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h
index 4bea0425f..4d7ab6598 100644
--- a/Eigen/src/Core/CwiseBinaryOp.h
+++ b/Eigen/src/Core/CwiseBinaryOp.h
@@ -1,7 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
-// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
+// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
@@ -44,7 +44,7 @@
* \sa MatrixBase::binaryExpr(const MatrixBase<OtherDerived> &,const CustomBinaryOp &) const, class CwiseUnaryOp, class CwiseNullaryOp
*/
template<typename BinaryOp, typename Lhs, typename Rhs>
-struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
+struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > : ei_traits<Lhs>
{
// even though we require Lhs and Rhs to have the same scalar type (see CwiseBinaryOp constructor),
// we still want to handle the case when the result type is different.
@@ -54,6 +54,8 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
typename Rhs::Scalar
)
>::type Scalar;
+ typedef typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType,
+ typename ei_traits<Rhs>::StorageType>::ret StorageType;
typedef typename Lhs::Nested LhsNested;
typedef typename Rhs::Nested RhsNested;
typedef typename ei_unref<LhsNested>::type _LhsNested;
@@ -63,10 +65,6 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
RhsCoeffReadCost = _RhsNested::CoeffReadCost,
LhsFlags = _LhsNested::Flags,
RhsFlags = _RhsNested::Flags,
- RowsAtCompileTime = Lhs::RowsAtCompileTime,
- ColsAtCompileTime = Lhs::ColsAtCompileTime,
- MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
- MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime,
StorageOrdersAgree = (int(Lhs::Flags)&RowMajorBit)==(int(Rhs::Flags)&RowMajorBit),
Flags = (int(LhsFlags) | int(RhsFlags)) & (
HereditaryBits
@@ -81,13 +79,24 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
};
};
+template<typename BinaryOp, typename Lhs, typename Rhs, typename StorageType>
+class CwiseBinaryOpImpl;
+
template<typename BinaryOp, typename Lhs, typename Rhs>
class CwiseBinaryOp : ei_no_assignment_operator,
- public MatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
+ public CwiseBinaryOpImpl<
+ BinaryOp, Lhs, Rhs,
+ typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType,
+ typename ei_traits<Rhs>::StorageType>::ret>
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp)
+ typedef typename CwiseBinaryOpImpl<
+ BinaryOp, Lhs, Rhs,
+ typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType,
+ typename ei_traits<Rhs>::StorageType>::ret>::Base Base;
+ EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseBinaryOp)
+
typedef typename ei_traits<CwiseBinaryOp>::LhsNested LhsNested;
typedef typename ei_traits<CwiseBinaryOp>::RhsNested RhsNested;
typedef typename ei_traits<CwiseBinaryOp>::_LhsNested _LhsNested;
@@ -115,54 +124,53 @@ class CwiseBinaryOp : ei_no_assignment_operator,
EIGEN_STRONG_INLINE int rows() const { return m_lhs.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_lhs.cols(); }
+ const _LhsNested& lhs() const { return m_lhs; }
+ const _RhsNested& rhs() const { return m_rhs; }
+ const BinaryOp& functor() const { return m_functor; }
+
+ protected:
+ const LhsNested m_lhs;
+ const RhsNested m_rhs;
+ const BinaryOp m_functor;
+};
+
+template<typename BinaryOp, typename Lhs, typename Rhs>
+class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Dense>
+ : public Lhs::template MakeBase< CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::Type
+{
+ public:
+
+ typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> Derived;
+ typedef typename Lhs::template MakeBase< CwiseBinaryOp<BinaryOp, Lhs, Rhs> >::Type Base;
+ _EIGEN_DENSE_PUBLIC_INTERFACE( Derived )
+
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const
{
- return m_functor(m_lhs.coeff(row, col), m_rhs.coeff(row, col));
+ return derived().functor()(derived().lhs().coeff(row, col),
+ derived().rhs().coeff(row, col));
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
{
- return m_functor.packetOp(m_lhs.template packet<LoadMode>(row, col), m_rhs.template packet<LoadMode>(row, col));
+ return derived().functor().packetOp(derived().lhs().template packet<LoadMode>(row, col),
+ derived().rhs().template packet<LoadMode>(row, col));
}
EIGEN_STRONG_INLINE const Scalar coeff(int index) const
{
- return m_functor(m_lhs.coeff(index), m_rhs.coeff(index));
+ return derived().functor()(derived().lhs().coeff(index),
+ derived().rhs().coeff(index));
}
template<int LoadMode>
EIGEN_STRONG_INLINE PacketScalar packet(int index) const
{
- return m_functor.packetOp(m_lhs.template packet<LoadMode>(index), m_rhs.template packet<LoadMode>(index));
+ return derived().functor().packetOp(derived().lhs().template packet<LoadMode>(index),
+ derived().rhs().template packet<LoadMode>(index));
}
-
- const _LhsNested& lhs() const { return m_lhs; }
- const _RhsNested& rhs() const { return m_rhs; }
- const BinaryOp& functor() const { return m_functor; }
-
- protected:
- const LhsNested m_lhs;
- const RhsNested m_rhs;
- const BinaryOp m_functor;
};
-/**\returns an expression of the difference of \c *this and \a other
- *
- * \note If you want to substract a given scalar from all coefficients, see Cwise::operator-().
- *
- * \sa class CwiseBinaryOp, MatrixBase::operator-=(), Cwise::operator-()
- */
-template<typename Derived>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>,
- Derived, OtherDerived>
-MatrixBase<Derived>::operator-(const MatrixBase<OtherDerived> &other) const
-{
- return CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
- Derived, OtherDerived>(derived(), other.derived());
-}
-
/** replaces \c *this by \c *this - \a other.
*
* \returns a reference to \c *this
@@ -172,23 +180,9 @@ template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
{
- return *this = *this - other;
-}
-
-/** \relates MatrixBase
- *
- * \returns an expression of the sum of \c *this and \a other
- *
- * \note If you want to add a given scalar to all coefficients, see Cwise::operator+().
- *
- * \sa class CwiseBinaryOp, MatrixBase::operator+=(), Cwise::operator+()
- */
-template<typename Derived>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
-MatrixBase<Derived>::operator+(const MatrixBase<OtherDerived> &other) const
-{
- return CwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived, OtherDerived>(derived(), other.derived());
+ SelfCwiseBinaryOp<ei_scalar_difference_op<Scalar>, Derived> tmp(derived());
+ tmp = other;
+ return derived();
}
/** replaces \c *this by \c *this + \a other.
@@ -200,114 +194,9 @@ template<typename OtherDerived>
EIGEN_STRONG_INLINE Derived &
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
{
- return *this = *this + other;
-}
-
-/** \returns an expression of the Schur product (coefficient wise product) of *this and \a other
- *
- * Example: \include Cwise_product.cpp
- * Output: \verbinclude Cwise_product.out
- *
- * \sa class CwiseBinaryOp, operator/(), square()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE
-Cwise<ExpressionType>::operator*(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived());
-}
-
-/** \returns an expression of the coefficient-wise quotient of *this and \a other
- *
- * Example: \include Cwise_quotient.cpp
- * Output: \verbinclude Cwise_quotient.out
- *
- * \sa class CwiseBinaryOp, operator*(), inverse()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
-Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived());
-}
-
-/** Replaces this expression by its coefficient-wise product with \a other.
- *
- * Example: \include Cwise_times_equal.cpp
- * Output: \verbinclude Cwise_times_equal.out
- *
- * \sa operator*(), operator/=()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other)
-{
- return m_matrix.const_cast_derived() = *this * other;
-}
-
-/** Replaces this expression by its coefficient-wise quotient by \a other.
- *
- * Example: \include Cwise_slash_equal.cpp
- * Output: \verbinclude Cwise_slash_equal.out
- *
- * \sa operator/(), operator*=()
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other)
-{
- return m_matrix.const_cast_derived() = *this / other;
-}
-
-/** \returns an expression of the coefficient-wise min of *this and \a other
- *
- * Example: \include Cwise_min.cpp
- * Output: \verbinclude Cwise_min.out
- *
- * \sa class CwiseBinaryOp
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
-Cwise<ExpressionType>::min(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)(_expression(), other.derived());
-}
-
-/** \returns an expression of the coefficient-wise max of *this and \a other
- *
- * Example: \include Cwise_max.cpp
- * Output: \verbinclude Cwise_max.out
- *
- * \sa class CwiseBinaryOp
- */
-template<typename ExpressionType>
-template<typename OtherDerived>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
-Cwise<ExpressionType>::max(const MatrixBase<OtherDerived> &other) const
-{
- return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)(_expression(), other.derived());
-}
-
-/** \returns an expression of a custom coefficient-wise operator \a func of *this and \a other
- *
- * The template parameter \a CustomBinaryOp is the type of the functor
- * of the custom operator (see class CwiseBinaryOp for an example)
- *
- * Here is an example illustrating the use of custom functors:
- * \include class_CwiseBinaryOp.cpp
- * Output: \verbinclude class_CwiseBinaryOp.out
- *
- * \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, Cwise::operator*, Cwise::operator/
- */
-template<typename Derived>
-template<typename CustomBinaryOp, typename OtherDerived>
-EIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
-MatrixBase<Derived>::binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func) const
-{
- return CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>(derived(), other.derived(), func);
+ SelfCwiseBinaryOp<ei_scalar_sum_op<Scalar>, Derived> tmp(derived());
+ tmp = other.derived();
+ return derived();
}
#endif // EIGEN_CWISE_BINARY_OP_H
diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h
index 7c1984be6..c326ebae2 100644
--- a/Eigen/src/Core/CwiseNullaryOp.h
+++ b/Eigen/src/Core/CwiseNullaryOp.h
@@ -38,7 +38,7 @@
* However, if you want to write a function returning such an expression, you
* will need to use this class.
*
- * \sa class CwiseUnaryOp, class CwiseBinaryOp, MatrixBase::NullaryExpr()
+ * \sa class CwiseUnaryOp, class CwiseBinaryOp, DenseBase::NullaryExpr()
*/
template<typename NullaryOp, typename MatrixType>
struct ei_traits<CwiseNullaryOp<NullaryOp, MatrixType> > : ei_traits<MatrixType>
@@ -121,7 +121,7 @@ class CwiseNullaryOp : ei_no_assignment_operator,
template<typename Derived>
template<typename CustomNullaryOp>
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
-MatrixBase<Derived>::NullaryExpr(int rows, int cols, const CustomNullaryOp& func)
+DenseBase<Derived>::NullaryExpr(int rows, int cols, const CustomNullaryOp& func)
{
return CwiseNullaryOp<CustomNullaryOp, Derived>(rows, cols, func);
}
@@ -144,7 +144,7 @@ MatrixBase<Derived>::NullaryExpr(int rows, int cols, const CustomNullaryOp& func
template<typename Derived>
template<typename CustomNullaryOp>
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
-MatrixBase<Derived>::NullaryExpr(int size, const CustomNullaryOp& func)
+DenseBase<Derived>::NullaryExpr(int size, const CustomNullaryOp& func)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, Derived>(1, size, func);
@@ -153,7 +153,7 @@ MatrixBase<Derived>::NullaryExpr(int size, const CustomNullaryOp& func)
/** \returns an expression of a matrix defined by a custom functor \a func
*
- * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
+ * This variant is only for fixed-size DenseBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
@@ -163,7 +163,7 @@ MatrixBase<Derived>::NullaryExpr(int size, const CustomNullaryOp& func)
template<typename Derived>
template<typename CustomNullaryOp>
EIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
-MatrixBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
+DenseBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
{
return CwiseNullaryOp<CustomNullaryOp, Derived>(RowsAtCompileTime, ColsAtCompileTime, func);
}
@@ -171,7 +171,7 @@ MatrixBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
/** \returns an expression of a constant matrix of value \a value
*
* The parameters \a rows and \a cols are the number of rows and of columns of
- * the returned matrix. Must be compatible with this MatrixBase type.
+ * the returned matrix. Must be compatible with this DenseBase type.
*
* This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
* it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
@@ -182,8 +182,8 @@ MatrixBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
* \sa class CwiseNullaryOp
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Constant(int rows, int cols, const Scalar& value)
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Constant(int rows, int cols, const Scalar& value)
{
return NullaryExpr(rows, cols, ei_scalar_constant_op<Scalar>(value));
}
@@ -191,7 +191,7 @@ MatrixBase<Derived>::Constant(int rows, int cols, const Scalar& value)
/** \returns an expression of a constant matrix of value \a value
*
* The parameter \a size is the size of the returned vector.
- * Must be compatible with this MatrixBase type.
+ * Must be compatible with this DenseBase type.
*
* \only_for_vectors
*
@@ -204,15 +204,15 @@ MatrixBase<Derived>::Constant(int rows, int cols, const Scalar& value)
* \sa class CwiseNullaryOp
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Constant(int size, const Scalar& value)
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Constant(int size, const Scalar& value)
{
return NullaryExpr(size, ei_scalar_constant_op<Scalar>(value));
}
/** \returns an expression of a constant matrix of value \a value
*
- * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
+ * This variant is only for fixed-size DenseBase types. For dynamic-size types, you
* need to use the variants taking size arguments.
*
* The template parameter \a CustomNullaryOp is the type of the functor.
@@ -220,8 +220,8 @@ MatrixBase<Derived>::Constant(int size, const Scalar& value)
* \sa class CwiseNullaryOp
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Constant(const Scalar& value)
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Constant(const Scalar& value)
{
EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value));
@@ -229,12 +229,12 @@ MatrixBase<Derived>::Constant(const Scalar& value)
/** \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
template<typename Derived>
-bool MatrixBase<Derived>::isApproxToConstant
+bool DenseBase<Derived>::isApproxToConstant
(const Scalar& value, RealScalar prec) const
{
for(int j = 0; j < cols(); ++j)
for(int i = 0; i < rows(); ++i)
- if(!ei_isApprox(coeff(i, j), value, prec))
+ if(!ei_isApprox(this->coeff(i, j), value, prec))
return false;
return true;
}
@@ -243,7 +243,7 @@ bool MatrixBase<Derived>::isApproxToConstant
*
* \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
template<typename Derived>
-bool MatrixBase<Derived>::isConstant
+bool DenseBase<Derived>::isConstant
(const Scalar& value, RealScalar prec) const
{
return isApproxToConstant(value, prec);
@@ -254,7 +254,7 @@ bool MatrixBase<Derived>::isConstant
* \sa setConstant(), Constant(), class CwiseNullaryOp
*/
template<typename Derived>
-EIGEN_STRONG_INLINE void MatrixBase<Derived>::fill(const Scalar& value)
+EIGEN_STRONG_INLINE void DenseBase<Derived>::fill(const Scalar& value)
{
setConstant(value);
}
@@ -264,7 +264,7 @@ EIGEN_STRONG_INLINE void MatrixBase<Derived>::fill(const Scalar& value)
* \sa fill(), setConstant(int,const Scalar&), setConstant(int,int,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes()
*/
template<typename Derived>
-EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setConstant(const Scalar& value)
+EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& value)
{
return derived() = Constant(rows(), cols(), value);
}
@@ -278,9 +278,9 @@ EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setConstant(const Scalar& valu
*
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int size, const Scalar& value)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setConstant(int size, const Scalar& value)
{
resize(size);
return setConstant(value);
@@ -296,9 +296,9 @@ Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int siz
*
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int rows, int cols, const Scalar& value)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setConstant(int rows, int cols, const Scalar& value)
{
resize(rows, cols);
return setConstant(value);
@@ -322,8 +322,8 @@ Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setConstant(int row
* \sa Zero(), Zero(int)
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Zero(int rows, int cols)
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Zero(int rows, int cols)
{
return Constant(rows, cols, Scalar(0));
}
@@ -345,8 +345,8 @@ MatrixBase<Derived>::Zero(int rows, int cols)
* \sa Zero(), Zero(int,int)
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Zero(int size)
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Zero(int size)
{
return Constant(size, Scalar(0));
}
@@ -362,8 +362,8 @@ MatrixBase<Derived>::Zero(int size)
* \sa Zero(int), Zero(int,int)
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Zero()
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Zero()
{
return Constant(Scalar(0));
}
@@ -377,11 +377,11 @@ MatrixBase<Derived>::Zero()
* \sa class CwiseNullaryOp, Zero()
*/
template<typename Derived>
-bool MatrixBase<Derived>::isZero(RealScalar prec) const
+bool DenseBase<Derived>::isZero(RealScalar prec) const
{
for(int j = 0; j < cols(); ++j)
for(int i = 0; i < rows(); ++i)
- if(!ei_isMuchSmallerThan(coeff(i, j), static_cast<Scalar>(1), prec))
+ if(!ei_isMuchSmallerThan(this->coeff(i, j), static_cast<Scalar>(1), prec))
return false;
return true;
}
@@ -394,7 +394,7 @@ bool MatrixBase<Derived>::isZero(RealScalar prec) const
* \sa class CwiseNullaryOp, Zero()
*/
template<typename Derived>
-EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setZero()
+EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero()
{
return setConstant(Scalar(0));
}
@@ -406,11 +406,11 @@ EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setZero()
* Example: \include Matrix_setZero_int.cpp
* Output: \verbinclude Matrix_setZero_int.out
*
- * \sa MatrixBase::setZero(), setZero(int,int), class CwiseNullaryOp, MatrixBase::Zero()
+ * \sa DenseBase::setZero(), setZero(int,int), class CwiseNullaryOp, DenseBase::Zero()
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int size)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setZero(int size)
{
resize(size);
return setConstant(Scalar(0));
@@ -424,11 +424,11 @@ Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int size)
* Example: \include Matrix_setZero_int_int.cpp
* Output: \verbinclude Matrix_setZero_int_int.out
*
- * \sa MatrixBase::setZero(), setZero(int), class CwiseNullaryOp, MatrixBase::Zero()
+ * \sa DenseBase::setZero(), setZero(int), class CwiseNullaryOp, DenseBase::Zero()
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int rows, int cols)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setZero(int rows, int cols)
{
resize(rows, cols);
return setConstant(Scalar(0));
@@ -451,8 +451,8 @@ Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setZero(int rows, i
* \sa Ones(), Ones(int), isOnes(), class Ones
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Ones(int rows, int cols)
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Ones(int rows, int cols)
{
return Constant(rows, cols, Scalar(1));
}
@@ -474,8 +474,8 @@ MatrixBase<Derived>::Ones(int rows, int cols)
* \sa Ones(), Ones(int,int), isOnes(), class Ones
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Ones(int size)
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Ones(int size)
{
return Constant(size, Scalar(1));
}
@@ -491,8 +491,8 @@ MatrixBase<Derived>::Ones(int size)
* \sa Ones(int), Ones(int,int), isOnes(), class Ones
*/
template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ConstantReturnType
-MatrixBase<Derived>::Ones()
+EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
+DenseBase<Derived>::Ones()
{
return Constant(Scalar(1));
}
@@ -506,7 +506,7 @@ MatrixBase<Derived>::Ones()
* \sa class CwiseNullaryOp, Ones()
*/
template<typename Derived>
-bool MatrixBase<Derived>::isOnes
+bool DenseBase<Derived>::isOnes
(RealScalar prec) const
{
return isApproxToConstant(Scalar(1), prec);
@@ -520,7 +520,7 @@ bool MatrixBase<Derived>::isOnes
* \sa class CwiseNullaryOp, Ones()
*/
template<typename Derived>
-EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setOnes()
+EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes()
{
return setConstant(Scalar(1));
}
@@ -534,9 +534,9 @@ EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setOnes()
*
* \sa MatrixBase::setOnes(), setOnes(int,int), class CwiseNullaryOp, MatrixBase::Ones()
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int size)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setOnes(int size)
{
resize(size);
return setConstant(Scalar(1));
@@ -552,9 +552,9 @@ Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int size)
*
* \sa MatrixBase::setOnes(), setOnes(int), class CwiseNullaryOp, MatrixBase::Ones()
*/
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
-Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setOnes(int rows, int cols)
+template<typename Derived, template<typename> class _Base, int _Options>
+EIGEN_STRONG_INLINE Derived&
+DenseStorageBase<Derived,_Base,_Options>::setOnes(int rows, int cols)
{
resize(rows, cols);
return setConstant(Scalar(1));
@@ -620,12 +620,12 @@ bool MatrixBase<Derived>::isIdentity
{
if(i == j)
{
- if(!ei_isApprox(coeff(i, j), static_cast<Scalar>(1), prec))
+ if(!ei_isApprox(this->coeff(i, j), static_cast<Scalar>(1), prec))
return false;
}
else
{
- if(!ei_isMuchSmallerThan(coeff(i, j), static_cast<RealScalar>(1), prec))
+ if(!ei_isMuchSmallerThan(this->coeff(i, j), static_cast<RealScalar>(1), prec))
return false;
}
}
@@ -681,7 +681,7 @@ template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int
EIGEN_STRONG_INLINE Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>&
Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::setIdentity(int rows, int cols)
{
- resize(rows, cols);
+ Base::resize(rows, cols);
return setIdentity();
}
diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h
index 03011800c..1abf0fffb 100644
--- a/Eigen/src/Core/CwiseUnaryOp.h
+++ b/Eigen/src/Core/CwiseUnaryOp.h
@@ -56,13 +56,17 @@ struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
};
};
+template<typename UnaryOp, typename MatrixType, typename StorageType>
+class CwiseUnaryOpImpl;
+
template<typename UnaryOp, typename MatrixType>
class CwiseUnaryOp : ei_no_assignment_operator,
- public MatrixBase<CwiseUnaryOp<UnaryOp, MatrixType> >
+ public CwiseUnaryOpImpl<UnaryOp, MatrixType, typename ei_traits<MatrixType>::StorageType>
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp)
+ typedef typename CwiseUnaryOpImpl<UnaryOp, MatrixType,typename ei_traits<MatrixType>::StorageType>::Base Base;
+ EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseUnaryOp)
inline CwiseUnaryOp(const MatrixType& mat, const UnaryOp& func = UnaryOp())
: m_matrix(mat), m_functor(func) {}
@@ -70,28 +74,6 @@ class CwiseUnaryOp : ei_no_assignment_operator,
EIGEN_STRONG_INLINE int rows() const { return m_matrix.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_matrix.cols(); }
- EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const
- {
- return m_functor(m_matrix.coeff(row, col));
- }
-
- template<int LoadMode>
- EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
- {
- return m_functor.packetOp(m_matrix.template packet<LoadMode>(row, col));
- }
-
- EIGEN_STRONG_INLINE const Scalar coeff(int index) const
- {
- return m_functor(m_matrix.coeff(index));
- }
-
- template<int LoadMode>
- EIGEN_STRONG_INLINE PacketScalar packet(int index) const
- {
- return m_functor.packetOp(m_matrix.template packet<LoadMode>(index));
- }
-
/** \internal used for introspection */
const UnaryOp& _functor() const { return m_functor; }
@@ -99,179 +81,55 @@ class CwiseUnaryOp : ei_no_assignment_operator,
const typename ei_cleantype<typename MatrixType::Nested>::type&
_expression() const { return m_matrix; }
+ const typename ei_cleantype<typename MatrixType::Nested>::type&
+ nestedExpression() const { return m_matrix; }
+
+ typename ei_cleantype<typename MatrixType::Nested>::type&
+ nestedExpression() { return m_matrix.const_cast_derived(); }
+
protected:
const typename MatrixType::Nested m_matrix;
const UnaryOp m_functor;
};
-/** \returns an expression of a custom coefficient-wise unary operator \a func of *this
- *
- * The template parameter \a CustomUnaryOp is the type of the functor
- * of the custom unary operator.
- *
- * Example:
- * \include class_CwiseUnaryOp.cpp
- * Output: \verbinclude class_CwiseUnaryOp.out
- *
- * \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, Cwise::abs
- */
-template<typename Derived>
-template<typename CustomUnaryOp>
-EIGEN_STRONG_INLINE const CwiseUnaryOp<CustomUnaryOp, Derived>
-MatrixBase<Derived>::unaryExpr(const CustomUnaryOp& func) const
-{
- return CwiseUnaryOp<CustomUnaryOp, Derived>(derived(), func);
-}
-
-/** \returns an expression of the opposite of \c *this
- */
-template<typename Derived>
-EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_opposite_op<typename ei_traits<Derived>::Scalar>,Derived>
-MatrixBase<Derived>::operator-() const
-{
- return derived();
-}
-
-/** \returns an expression of the coefficient-wise absolute value of \c *this
- *
- * Example: \include Cwise_abs.cpp
- * Output: \verbinclude Cwise_abs.out
- *
- * \sa abs2()
- */
-template<typename ExpressionType>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op)
-Cwise<ExpressionType>::abs() const
-{
- return _expression();
-}
-
-/** \returns an expression of the coefficient-wise squared absolute value of \c *this
- *
- * Example: \include Cwise_abs2.cpp
- * Output: \verbinclude Cwise_abs2.out
- *
- * \sa abs(), square()
- */
-template<typename ExpressionType>
-EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op)
-Cwise<ExpressionType>::abs2() const
-{
- return _expression();
-}
-
-/** \returns an expression of the complex conjugate of \c *this.
- *
- * \sa adjoint() */
-template<typename Derived>
-EIGEN_STRONG_INLINE typename MatrixBase<Derived>::ConjugateReturnType
-MatrixBase<Derived>::conjugate() const
-{
- return ConjugateReturnType(derived());
-}
-
-/** \returns a read-only expression of the real part of \c *this.
- *
- * \sa imag() */
-template<typename Derived>
-EIGEN_STRONG_INLINE typename MatrixBase<Derived>::RealReturnType
-MatrixBase<Derived>::real() const { return derived(); }
-
-/** \returns an read-only expression of the imaginary part of \c *this.
- *
- * \sa real() */
-template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ImagReturnType
-MatrixBase<Derived>::imag() const { return derived(); }
-
-/** \returns an expression of *this with the \a Scalar type casted to
- * \a NewScalar.
- *
- * The template parameter \a NewScalar is the type we are casting the scalars to.
- *
- * \sa class CwiseUnaryOp
- */
-template<typename Derived>
-template<typename NewType>
-EIGEN_STRONG_INLINE
-typename ei_cast_return_type<
- Derived,
- const CwiseUnaryOp<ei_scalar_cast_op<typename ei_traits<Derived>::Scalar, NewType>, Derived>
- >::type
-MatrixBase<Derived>::cast() const
-{
- return derived();
-}
-
-/** \returns an expression of the coefficient-wise exponential of *this.
- *
- * Example: \include Cwise_exp.cpp
- * Output: \verbinclude Cwise_exp.out
- *
- * \sa pow(), log(), sin(), cos()
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)
-Cwise<ExpressionType>::exp() const
-{
- return _expression();
-}
-
-/** \returns an expression of the coefficient-wise logarithm of *this.
- *
- * Example: \include Cwise_log.cpp
- * Output: \verbinclude Cwise_log.out
- *
- * \sa exp()
- */
-template<typename ExpressionType>
-inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op)
-Cwise<ExpressionType>::log() const
-{
- return _expression();
-}
+// This is the generic implementation for dense storage.
+// It can be used for any matrix types implementing the dense concept.
+template<typename UnaryOp, typename MatrixType>
+class CwiseUnaryOpImpl<UnaryOp,MatrixType,Dense>
+ : public MatrixType::template MakeBase< CwiseUnaryOp<UnaryOp, MatrixType> >::Type
+ {
+ const typename ei_cleantype<typename MatrixType::Nested>::type& nestedExpression() const
+ { return derived().nestedExpression(); }
+ typename ei_cleantype<typename MatrixType::Nested>::type& nestedExpression()
+ { return derived().nestedExpression(); }
+ public:
-/** \returns an expression of \c *this scaled by the scalar factor \a scalar */
-template<typename Derived>
-EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::ScalarMultipleReturnType
-MatrixBase<Derived>::operator*(const Scalar& scalar) const
-{
- return CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, Derived>
- (derived(), ei_scalar_multiple_op<Scalar>(scalar));
-}
+ typedef CwiseUnaryOp<UnaryOp, MatrixType> Derived;
+ typedef typename MatrixType::template MakeBase< CwiseUnaryOp<UnaryOp, MatrixType> >::Type Base;
+ _EIGEN_DENSE_PUBLIC_INTERFACE( Derived )
-/** Overloaded for efficient real matrix times complex scalar value */
-template<typename Derived>
-EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_multiple2_op<typename ei_traits<Derived>::Scalar,
- std::complex<typename ei_traits<Derived>::Scalar> >, Derived>
-MatrixBase<Derived>::operator*(const std::complex<Scalar>& scalar) const
-{
- return CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,std::complex<Scalar> >, Derived>
- (*static_cast<const Derived*>(this), ei_scalar_multiple2_op<Scalar,std::complex<Scalar> >(scalar));
-}
+ EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const
+ {
+ return derived()._functor()(nestedExpression().coeff(row, col));
+ }
-/** \returns an expression of \c *this divided by the scalar value \a scalar */
-template<typename Derived>
-EIGEN_STRONG_INLINE const CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>, Derived>
-MatrixBase<Derived>::operator/(const Scalar& scalar) const
-{
- return CwiseUnaryOp<ei_scalar_quotient1_op<Scalar>, Derived>
- (derived(), ei_scalar_quotient1_op<Scalar>(scalar));
-}
+ template<int LoadMode>
+ EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
+ {
+ return derived()._functor().packetOp(nestedExpression().template packet<LoadMode>(row, col));
+ }
-template<typename Derived>
-EIGEN_STRONG_INLINE Derived&
-MatrixBase<Derived>::operator*=(const Scalar& other)
-{
- return *this = *this * other;
-}
+ EIGEN_STRONG_INLINE const Scalar coeff(int index) const
+ {
+ return derived()._functor()(nestedExpression().coeff(index));
+ }
-template<typename Derived>
-EIGEN_STRONG_INLINE Derived&
-MatrixBase<Derived>::operator/=(const Scalar& other)
-{
- return *this = *this / other;
-}
+ template<int LoadMode>
+ EIGEN_STRONG_INLINE PacketScalar packet(int index) const
+ {
+ return derived()._functor().packetOp(nestedExpression().template packet<LoadMode>(index));
+ }
+};
#endif // EIGEN_CWISE_UNARY_OP_H
diff --git a/Eigen/src/Core/CwiseUnaryView.h b/Eigen/src/Core/CwiseUnaryView.h
index 580344379..2ff5d3d45 100644
--- a/Eigen/src/Core/CwiseUnaryView.h
+++ b/Eigen/src/Core/CwiseUnaryView.h
@@ -52,12 +52,17 @@ struct ei_traits<CwiseUnaryView<ViewOp, MatrixType> >
};
};
+template<typename ViewOp, typename MatrixType, typename StorageType>
+class CwiseUnaryViewImpl;
+
template<typename ViewOp, typename MatrixType>
-class CwiseUnaryView : public MatrixBase<CwiseUnaryView<ViewOp, MatrixType> >
+class CwiseUnaryView : ei_no_assignment_operator,
+ public CwiseUnaryViewImpl<ViewOp, MatrixType, typename ei_traits<MatrixType>::StorageType>
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView)
+ typedef typename CwiseUnaryViewImpl<ViewOp, MatrixType,typename ei_traits<MatrixType>::StorageType>::Base Base;
+ EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseUnaryView)
inline CwiseUnaryView(const MatrixType& mat, const ViewOp& func = ViewOp())
: m_matrix(mat), m_functor(func) {}
@@ -67,63 +72,55 @@ class CwiseUnaryView : public MatrixBase<CwiseUnaryView<ViewOp, MatrixType> >
EIGEN_STRONG_INLINE int rows() const { return m_matrix.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_matrix.cols(); }
+ /** \internal used for introspection */
+ const ViewOp& _functor() const { return m_functor; }
+
+ const typename ei_cleantype<typename MatrixType::Nested>::type&
+ nestedExpression() const { return m_matrix; }
+
+ typename ei_cleantype<typename MatrixType::Nested>::type&
+ nestedExpression() { return m_matrix.const_cast_derived(); }
+
+ protected:
+ // FIXME changed from MatrixType::Nested because of a weird compilation error with sun CC
+ const typename ei_nested<MatrixType>::type m_matrix;
+ const ViewOp m_functor;
+};
+
+template<typename ViewOp, typename MatrixType>
+class CwiseUnaryViewImpl<ViewOp,MatrixType,Dense> : public MatrixBase<CwiseUnaryView<ViewOp, MatrixType> >
+{
+ const typename ei_cleantype<typename MatrixType::Nested>::type& nestedExpression() const
+ { return derived().nestedExpression(); }
+ typename ei_cleantype<typename MatrixType::Nested>::type& nestedExpression()
+ { return derived().nestedExpression(); }
+
+ public:
+
+ typedef CwiseUnaryView<ViewOp, MatrixType> Derived;
+ EIGEN_DENSE_PUBLIC_INTERFACE( Derived )
+
EIGEN_STRONG_INLINE const Scalar coeff(int row, int col) const
{
- return m_functor(m_matrix.coeff(row, col));
+ return derived()._functor()(nestedExpression().coeff(row, col));
}
EIGEN_STRONG_INLINE const Scalar coeff(int index) const
{
- return m_functor(m_matrix.coeff(index));
+ return derived()._functor()(nestedExpression().coeff(index));
}
EIGEN_STRONG_INLINE Scalar& coeffRef(int row, int col)
{
- return m_functor(m_matrix.const_cast_derived().coeffRef(row, col));
+ return derived()._functor()(nestedExpression().const_cast_derived().coeffRef(row, col));
}
EIGEN_STRONG_INLINE Scalar& coeffRef(int index)
{
- return m_functor(m_matrix.const_cast_derived().coeffRef(index));
+ return derived()._functor()(nestedExpression().const_cast_derived().coeffRef(index));
}
-
- protected:
- // FIXME changed from MatrixType::Nested because of a weird compilation error with sun CC
- const typename ei_nested<MatrixType>::type m_matrix;
- const ViewOp m_functor;
};
-/** \returns an expression of a custom coefficient-wise unary operator \a func of *this
- *
- * The template parameter \a CustomUnaryOp is the type of the functor
- * of the custom unary operator.
- *
- * Example:
- * \include class_CwiseUnaryOp.cpp
- * Output: \verbinclude class_CwiseUnaryOp.out
- *
- * \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, Cwise::abs
- */
-template<typename Derived>
-template<typename CustomViewOp>
-EIGEN_STRONG_INLINE const CwiseUnaryView<CustomViewOp, Derived>
-MatrixBase<Derived>::unaryViewExpr(const CustomViewOp& func) const
-{
- return CwiseUnaryView<CustomViewOp, Derived>(derived(), func);
-}
-
-/** \returns a non const expression of the real part of \c *this.
- *
- * \sa imag() */
-template<typename Derived>
-EIGEN_STRONG_INLINE typename MatrixBase<Derived>::NonConstRealReturnType
-MatrixBase<Derived>::real() { return derived(); }
-/** \returns a non const expression of the imaginary part of \c *this.
- *
- * \sa real() */
-template<typename Derived>
-EIGEN_STRONG_INLINE typename MatrixBase<Derived>::NonConstImagReturnType
-MatrixBase<Derived>::imag() { return derived(); }
#endif // EIGEN_CWISE_UNARY_VIEW_H
diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h
new file mode 100644
index 000000000..e07b02a51
--- /dev/null
+++ b/Eigen/src/Core/DenseBase.h
@@ -0,0 +1,496 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2006-2009 Benoit Jacob <jacob.benoit.1@gmail.com>
+// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_DENSEBASE_H
+#define EIGEN_DENSEBASE_H
+
+/** \class DenseBase
+ *
+ * \brief Base class for all dense matrices, vectors, and arrays
+ *
+ * This class is the base that is inherited by all dense objects (matrix, vector, arrays,
+ * and related expression types). The common Eigen API for dense objects is contained in this class.
+ *
+ * \param Derived is the derived type, e.g., a matrix type or an expression.
+ */
+template<typename Derived> class DenseBase
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ : public ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
+ typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>
+#else
+ : public AnyMatrixBase<Derived>
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+{
+ public:
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
+ typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*;
+
+ class InnerIterator;
+
+ typedef typename ei_traits<Derived>::Scalar Scalar;
+ typedef typename ei_packet_traits<Scalar>::type PacketScalar;
+
+ using AnyMatrixBase<Derived>::derived;
+ using AnyMatrixBase<Derived>::const_cast_derived;
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+ enum {
+
+ RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
+ /**< The number of rows at compile-time. This is just a copy of the value provided
+ * by the \a Derived type. If a value is not known at compile-time,
+ * it is set to the \a Dynamic constant.
+ * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
+
+ ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
+ /**< The number of columns at compile-time. This is just a copy of the value provided
+ * by the \a Derived type. If a value is not known at compile-time,
+ * it is set to the \a Dynamic constant.
+ * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
+
+
+ SizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::RowsAtCompileTime,
+ ei_traits<Derived>::ColsAtCompileTime>::ret),
+ /**< This is equal to the number of coefficients, i.e. the number of
+ * rows times the number of columns, or to \a Dynamic if this is not
+ * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
+
+ MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime,
+ /**< This value is equal to the maximum possible number of rows that this expression
+ * might have. If this expression might have an arbitrarily high number of rows,
+ * this value is set to \a Dynamic.
+ *
+ * This value is useful to know when evaluating an expression, in order to determine
+ * whether it is possible to avoid doing a dynamic memory allocation.
+ *
+ * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
+ */
+
+ MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime,
+ /**< This value is equal to the maximum possible number of columns that this expression
+ * might have. If this expression might have an arbitrarily high number of columns,
+ * this value is set to \a Dynamic.
+ *
+ * This value is useful to know when evaluating an expression, in order to determine
+ * whether it is possible to avoid doing a dynamic memory allocation.
+ *
+ * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
+ */
+
+ MaxSizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::MaxRowsAtCompileTime,
+ ei_traits<Derived>::MaxColsAtCompileTime>::ret),
+ /**< This value is equal to the maximum possible number of coefficients that this expression
+ * might have. If this expression might have an arbitrarily high number of coefficients,
+ * this value is set to \a Dynamic.
+ *
+ * This value is useful to know when evaluating an expression, in order to determine
+ * whether it is possible to avoid doing a dynamic memory allocation.
+ *
+ * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
+ */
+
+ IsVectorAtCompileTime = ei_traits<Derived>::RowsAtCompileTime == 1
+ || ei_traits<Derived>::ColsAtCompileTime == 1,
+ /**< This is set to true if either the number of rows or the number of
+ * columns is known at compile-time to be equal to 1. Indeed, in that case,
+ * we are dealing with a column-vector (if there is only one column) or with
+ * a row-vector (if there is only one row). */
+
+ Flags = ei_traits<Derived>::Flags,
+ /**< This stores expression \ref flags flags which may or may not be inherited by new expressions
+ * constructed from this one. See the \ref flags "list of flags".
+ */
+
+ CoeffReadCost = ei_traits<Derived>::CoeffReadCost,
+ /**< This is a rough measure of how expensive it is to read one coefficient from
+ * this expression.
+ */
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ _HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
+#endif
+ };
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ /** This is the "real scalar" type; if the \a Scalar type is already real numbers
+ * (e.g. int, float or double) then \a RealScalar is just the same as \a Scalar. If
+ * \a Scalar is \a std::complex<T> then RealScalar is \a T.
+ *
+ * \sa class NumTraits
+ */
+ typedef typename NumTraits<Scalar>::Real RealScalar;
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+ /** \returns the number of rows. \sa cols(), RowsAtCompileTime */
+ inline int rows() const { return derived().rows(); }
+ /** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
+ inline int cols() const { return derived().cols(); }
+ /** \returns the number of coefficients, which is rows()*cols().
+ * \sa rows(), cols(), SizeAtCompileTime. */
+ inline int size() const { return rows() * cols(); }
+ /** \returns the number of nonzero coefficients which is in practice the number
+ * of stored coefficients. */
+ inline int nonZeros() const { return size(); }
+ /** \returns true if either the number of rows or the number of columns is equal to 1.
+ * In other words, this function returns
+ * \code rows()==1 || cols()==1 \endcode
+ * \sa rows(), cols(), IsVectorAtCompileTime. */
+ inline bool isVector() const { return rows()==1 || cols()==1; }
+ /** \returns the size of the storage major dimension,
+ * i.e., the number of columns for a columns major matrix, and the number of rows otherwise */
+ int outerSize() const { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }
+ /** \returns the size of the inner dimension according to the storage order,
+ * i.e., the number of rows for a columns major matrix, and the number of cols otherwise */
+ int innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }
+
+ /** Only plain matrices, not expressions may be resized; therefore the only useful resize method is
+ * Matrix::resize(). The present method only asserts that the new size equals the old size, and does
+ * nothing else.
+ */
+ void resize(int size)
+ {
+ ei_assert(size == this->size()
+ && "MatrixBase::resize() does not actually allow to resize.");
+ }
+ /** Only plain matrices, not expressions may be resized; therefore the only useful resize method is
+ * Matrix::resize(). The present method only asserts that the new size equals the old size, and does
+ * nothing else.
+ */
+ void resize(int rows, int cols)
+ {
+ ei_assert(rows == this->rows() && cols == this->cols()
+ && "MatrixBase::resize() does not actually allow to resize.");
+ }
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ /** \internal the return type of coeff()
+ */
+ typedef typename ei_meta_if<_HasDirectAccess, const Scalar&, Scalar>::ret CoeffReturnType;
+
+ /** \internal Represents a matrix with all coefficients equal to one another*/
+ typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
+ /** \internal the return type of MatrixBase::eigenvalues() */
+ typedef Matrix<typename NumTraits<typename ei_traits<Derived>::Scalar>::Real, ei_traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
+ /** \internal expression tyepe of a column */
+ typedef Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1> ColXpr;
+ /** \internal expression tyepe of a column */
+ typedef Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime> RowXpr;
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+ /** Copies \a other into *this. \returns a reference to *this. */
+ template<typename OtherDerived>
+ Derived& operator=(const DenseBase<OtherDerived>& other);
+
+ /** Special case of the template operator=, in order to prevent the compiler
+ * from generating a default operator= (issue hit with g++ 4.1)
+ */
+ Derived& operator=(const DenseBase& other);
+
+ template<typename OtherDerived>
+ Derived& operator=(const AnyMatrixBase<OtherDerived> &other);
+
+ template<typename OtherDerived>
+ Derived& operator+=(const AnyMatrixBase<OtherDerived> &other);
+
+ template<typename OtherDerived>
+ Derived& operator-=(const AnyMatrixBase<OtherDerived> &other);
+
+ template<typename OtherDerived>
+ Derived& operator=(const ReturnByValue<OtherDerived>& func);
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ /** Copies \a other into *this without evaluating other. \returns a reference to *this. */
+ template<typename OtherDerived>
+ Derived& lazyAssign(const DenseBase<OtherDerived>& other);
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+ CommaInitializer<Derived> operator<< (const Scalar& s);
+
+ template<typename OtherDerived>
+ CommaInitializer<Derived> operator<< (const DenseBase<OtherDerived>& other);
+
+ const CoeffReturnType coeff(int row, int col) const;
+ const CoeffReturnType operator()(int row, int col) const;
+
+ Scalar& coeffRef(int row, int col);
+ Scalar& operator()(int row, int col);
+
+ const CoeffReturnType coeff(int index) const;
+ const CoeffReturnType operator[](int index) const;
+ const CoeffReturnType operator()(int index) const;
+
+ Scalar& coeffRef(int index);
+ Scalar& operator[](int index);
+ Scalar& operator()(int index);
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ template<typename OtherDerived>
+ void copyCoeff(int row, int col, const DenseBase<OtherDerived>& other);
+ template<typename OtherDerived>
+ void copyCoeff(int index, const DenseBase<OtherDerived>& other);
+ template<typename OtherDerived, int StoreMode, int LoadMode>
+ void copyPacket(int row, int col, const DenseBase<OtherDerived>& other);
+ template<typename OtherDerived, int StoreMode, int LoadMode>
+ void copyPacket(int index, const DenseBase<OtherDerived>& other);
+#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+ template<int LoadMode>
+ PacketScalar packet(int row, int col) const;
+ template<int StoreMode>
+ void writePacket(int row, int col, const PacketScalar& x);
+
+ template<int LoadMode>
+ PacketScalar packet(int index) const;
+ template<int StoreMode>
+ void writePacket(int index, const PacketScalar& x);
+
+ Eigen::Transpose<Derived> transpose();
+ const Eigen::Transpose<Derived> transpose() const;
+ void transposeInPlace();
+#ifndef EIGEN_NO_DEBUG
+ protected:
+ template<typename OtherDerived>
+ void checkTransposeAliasing(const OtherDerived& other) const;
+ public:
+#endif
+
+ RowXpr row(int i);
+ const RowXpr row(int i) const;
+
+ ColXpr col(int i);
+ const ColXpr col(int i) const;
+
+ typename BlockReturnType<Derived>::Type block(int startRow, int startCol, int blockRows, int blockCols);
+ const typename BlockReturnType<Derived>::Type
+ block(int startRow, int startCol, int blockRows, int blockCols) const;
+
+ VectorBlock<Derived> segment(int start, int size);
+ const VectorBlock<Derived> segment(int start, int size) const;
+
+ VectorBlock<Derived> head(int size);
+ const VectorBlock<Derived> head(int size) const;
+
+ VectorBlock<Derived> tail(int size);
+ const VectorBlock<Derived> tail(int size) const;
+
+ typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols);
+ const typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols) const;
+
+ template<int BlockRows, int BlockCols>
+ typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol);
+ template<int BlockRows, int BlockCols>
+ const typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol) const;
+
+ template<int CRows, int CCols>
+ typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type);
+ template<int CRows, int CCols>
+ const typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type) const;
+
+ template<int Size> VectorBlock<Derived,Size> head(void);
+ template<int Size> const VectorBlock<Derived,Size> head() const;
+
+ template<int Size> VectorBlock<Derived,Size> tail();
+ template<int Size> const VectorBlock<Derived,Size> tail() const;
+
+ template<int Size> VectorBlock<Derived,Size> segment(int start);
+ template<int Size> const VectorBlock<Derived,Size> segment(int 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(int index);
+ const Diagonal<Derived, Dynamic> diagonal(int 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;
+
+ static const ConstantReturnType
+ Constant(int rows, int cols, const Scalar& value);
+ static const ConstantReturnType
+ Constant(int size, const Scalar& value);
+ static const ConstantReturnType
+ Constant(const Scalar& value);
+
+ template<typename CustomNullaryOp>
+ static const CwiseNullaryOp<CustomNullaryOp, Derived>
+ NullaryExpr(int rows, int cols, const CustomNullaryOp& func);
+ template<typename CustomNullaryOp>
+ static const CwiseNullaryOp<CustomNullaryOp, Derived>
+ NullaryExpr(int size, const CustomNullaryOp& func);
+ template<typename CustomNullaryOp>
+ static const CwiseNullaryOp<CustomNullaryOp, Derived>
+ NullaryExpr(const CustomNullaryOp& func);
+
+ static const ConstantReturnType Zero(int rows, int cols);
+ static const ConstantReturnType Zero(int size);
+ static const ConstantReturnType Zero();
+ static const ConstantReturnType Ones(int rows, int cols);
+ static const ConstantReturnType Ones(int size);
+ static const ConstantReturnType Ones();
+
+ void fill(const Scalar& value);
+ Derived& setConstant(const Scalar& value);
+ Derived& setZero();
+ Derived& setOnes();
+ Derived& setRandom();
+
+
+ template<typename OtherDerived>
+ bool isApprox(const DenseBase<OtherDerived>& other,
+ RealScalar prec = dummy_precision<Scalar>()) const;
+ bool isMuchSmallerThan(const RealScalar& other,
+ RealScalar prec = dummy_precision<Scalar>()) const;
+ template<typename OtherDerived>
+ bool isMuchSmallerThan(const DenseBase<OtherDerived>& other,
+ RealScalar prec = dummy_precision<Scalar>()) const;
+
+ bool isApproxToConstant(const Scalar& value, RealScalar prec = dummy_precision<Scalar>()) const;
+ bool isConstant(const Scalar& value, RealScalar prec = dummy_precision<Scalar>()) const;
+ bool isZero(RealScalar prec = dummy_precision<Scalar>()) const;
+ bool isOnes(RealScalar prec = dummy_precision<Scalar>()) const;
+
+ inline Derived& operator*=(const Scalar& other);
+ inline Derived& operator/=(const Scalar& other);
+
+ /** \returns the matrix or vector obtained by evaluating this expression.
+ *
+ * Notice that in the case of a plain matrix or vector (not an expression) this function just returns
+ * a const reference, in order to avoid a useless copy.
+ */
+ EIGEN_STRONG_INLINE const typename ei_eval<Derived>::type eval() const
+ { return typename ei_eval<Derived>::type(derived()); }
+
+ template<typename OtherDerived>
+ void swap(DenseBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
+
+ /** \returns number of elements to skip to pass from one row (resp. column) to another
+ * for a row-major (resp. column-major) matrix.
+ * Combined with coeffRef() and the \ref flags flags, it allows a direct access to the data
+ * of the underlying matrix.
+ */
+ inline int stride() const { return derived().stride(); }
+
+ inline const NestByValue<Derived> nestByValue() const;
+ inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;
+ inline ForceAlignedAccess<Derived> forceAlignedAccess();
+ template<bool Enable> inline const typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf() const;
+ template<bool Enable> inline typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf();
+
+ Scalar sum() const;
+ Scalar mean() const;
+ Scalar trace() const;
+
+ Scalar prod() const;
+
+ typename ei_traits<Derived>::Scalar minCoeff() const;
+ typename ei_traits<Derived>::Scalar maxCoeff() const;
+
+ typename ei_traits<Derived>::Scalar minCoeff(int* row, int* col) const;
+ typename ei_traits<Derived>::Scalar maxCoeff(int* row, int* col) const;
+
+ typename ei_traits<Derived>::Scalar minCoeff(int* index) const;
+ typename ei_traits<Derived>::Scalar maxCoeff(int* index) const;
+
+ template<typename BinaryOp>
+ typename ei_result_of<BinaryOp(typename ei_traits<Derived>::Scalar)>::type
+ redux(const BinaryOp& func) const;
+
+ template<typename Visitor>
+ void visit(Visitor& func) const;
+
+ inline const WithFormat<Derived> format(const IOFormat& fmt) const;
+
+/////////// Array module ///////////
+
+ bool all(void) const;
+ bool any(void) const;
+ int count() const;
+
+ const VectorwiseOp<Derived,Horizontal> rowwise() const;
+ VectorwiseOp<Derived,Horizontal> rowwise();
+ const VectorwiseOp<Derived,Vertical> colwise() const;
+ VectorwiseOp<Derived,Vertical> colwise();
+
+ static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int rows, int cols);
+ static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int size);
+ static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random();
+
+ template<typename ThenDerived,typename ElseDerived>
+ const Select<Derived,ThenDerived,ElseDerived>
+ select(const DenseBase<ThenDerived>& thenMatrix,
+ const DenseBase<ElseDerived>& elseMatrix) const;
+
+ template<typename ThenDerived>
+ inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
+ select(const DenseBase<ThenDerived>& thenMatrix, typename ThenDerived::Scalar elseScalar) const;
+
+ template<typename ElseDerived>
+ inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
+ select(typename ElseDerived::Scalar thenScalar, const DenseBase<ElseDerived>& elseMatrix) const;
+
+ template<int p> RealScalar lpNorm() const;
+
+ template<int RowFactor, int ColFactor>
+ const Replicate<Derived,RowFactor,ColFactor> replicate() const;
+ const Replicate<Derived,Dynamic,Dynamic> replicate(int rowFacor,int colFactor) const;
+
+ Eigen::Reverse<Derived, BothDirections> reverse();
+ const Eigen::Reverse<Derived, BothDirections> reverse() const;
+ void reverseInPlace();
+
+ #ifdef EIGEN_DENSEBASE_PLUGIN
+ #include EIGEN_DENSEBASE_PLUGIN
+ #endif
+
+ protected:
+ /** Default constructor. Do nothing. */
+ DenseBase()
+ {
+ /* Just checks for self-consistency of the flags.
+ * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down
+ */
+#ifdef EIGEN_INTERNAL_DEBUGGING
+ EIGEN_STATIC_ASSERT(ei_are_flags_consistent<Flags>::ret,
+ INVALID_MATRIXBASE_TEMPLATE_PARAMETERS)
+#endif
+ }
+
+ private:
+ explicit DenseBase(int);
+ DenseBase(int,int);
+ template<typename OtherDerived> explicit DenseBase(const DenseBase<OtherDerived>&);
+};
+
+#endif // EIGEN_DENSEBASE_H
diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h
new file mode 100644
index 000000000..7dc8d38c4
--- /dev/null
+++ b/Eigen/src/Core/DenseStorageBase.h
@@ -0,0 +1,601 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr>
+// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_DENSESTORAGEBASE_H
+#define EIGEN_DENSESTORAGEBASE_H
+
+#ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
+# define EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED for(int i=0;i<base().size();++i) coeffRef(i)=Scalar(0);
+#else
+# define EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+#endif
+
+template <typename Derived, typename OtherDerived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct ei_conservative_resize_like_impl;
+template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct ei_matrix_swap_impl;
+
+template<typename Derived, template<typename> class _Base, int _Options>
+class DenseStorageBase : public _Base<Derived>
+{
+ public:
+ enum { Options = _Options };
+ typedef _Base<Derived> Base;
+ typedef typename Base::PlainMatrixType PlainMatrixType;
+ typedef typename Base::Scalar Scalar;
+ typedef typename Base::PacketScalar PacketScalar;
+ using Base::RowsAtCompileTime;
+ using Base::ColsAtCompileTime;
+ using Base::SizeAtCompileTime;
+ using Base::MaxRowsAtCompileTime;
+ using Base::MaxColsAtCompileTime;
+ using Base::MaxSizeAtCompileTime;
+ using Base::IsVectorAtCompileTime;
+ using Base::Flags;
+
+ friend class Eigen::Map<Derived, Unaligned>;
+ typedef class Eigen::Map<Derived, Unaligned> UnalignedMapType;
+ friend class Eigen::Map<Derived, Aligned>;
+ typedef class Eigen::Map<Derived, Aligned> AlignedMapType;
+
+ protected:
+ ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime, Options> m_storage;
+
+ public:
+ enum { NeedsToAlign = (!(Options&DontAlign))
+ && SizeAtCompileTime!=Dynamic && ((sizeof(Scalar)*SizeAtCompileTime)%16)==0 };
+ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
+
+ Base& base() { return *static_cast<Base*>(this); }
+ const Base& base() const { return *static_cast<const Base*>(this); }
+
+ EIGEN_STRONG_INLINE int rows() const { return m_storage.rows(); }
+ EIGEN_STRONG_INLINE int cols() const { return m_storage.cols(); }
+
+ /** Returns the leading dimension (for matrices) or the increment (for vectors) to be used with data().
+ *
+ * More precisely:
+ * - for a column major matrix it returns the number of elements between two successive columns
+ * - for a row major matrix it returns the number of elements between two successive rows
+ * - for a vector it returns the number of elements between two successive coefficients
+ * This function has to be used together with the MapBase::data() function.
+ *
+ * \sa data() */
+ EIGEN_STRONG_INLINE int stride() const
+ {
+ if(IsVectorAtCompileTime)
+ return 1;
+ else
+ return (Flags & RowMajorBit) ? m_storage.cols() : m_storage.rows();
+ }
+
+ EIGEN_STRONG_INLINE const Scalar& coeff(int row, int 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& coeff(int index) const
+ {
+ return m_storage.data()[index];
+ }
+
+ EIGEN_STRONG_INLINE Scalar& coeffRef(int row, int col)
+ {
+ 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 Scalar& coeffRef(int index)
+ {
+ return m_storage.data()[index];
+ }
+
+ template<int LoadMode>
+ EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
+ {
+ return ei_ploadt<Scalar, LoadMode>
+ (m_storage.data() + (Flags & RowMajorBit
+ ? col + row * m_storage.cols()
+ : row + col * m_storage.rows()));
+ }
+
+ template<int LoadMode>
+ EIGEN_STRONG_INLINE PacketScalar packet(int index) const
+ {
+ return ei_ploadt<Scalar, LoadMode>(m_storage.data() + index);
+ }
+
+ template<int StoreMode>
+ EIGEN_STRONG_INLINE void writePacket(int row, int col, const PacketScalar& x)
+ {
+ ei_pstoret<Scalar, PacketScalar, StoreMode>
+ (m_storage.data() + (Flags & RowMajorBit
+ ? col + row * m_storage.cols()
+ : row + col * m_storage.rows()), x);
+ }
+
+ template<int StoreMode>
+ EIGEN_STRONG_INLINE void writePacket(int index, const PacketScalar& x)
+ {
+ ei_pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, x);
+ }
+
+ /** \returns a const pointer to the data array of this matrix */
+ EIGEN_STRONG_INLINE const Scalar *data() const
+ { return m_storage.data(); }
+
+ /** \returns a pointer to the data array of this matrix */
+ EIGEN_STRONG_INLINE Scalar *data()
+ { return m_storage.data(); }
+
+ /** Resizes \c *this to a \a rows x \a cols matrix.
+ *
+ * This method is intended for dynamic-size matrices, although it is legal to call it on any
+ * matrix as long as fixed dimensions are left unchanged. If you only want to change the number
+ * of rows and/or of columns, you can use resize(NoChange_t, int), resize(int, NoChange_t).
+ *
+ * If the current number of coefficients of \c *this exactly matches the
+ * product \a rows * \a cols, then no memory allocation is performed and
+ * the current values are left unchanged. In all other cases, including
+ * shrinking, the data is reallocated and all previous values are lost.
+ *
+ * Example: \include Matrix_resize_int_int.cpp
+ * Output: \verbinclude Matrix_resize_int_int.out
+ *
+ * \sa resize(int) for vectors, resize(NoChange_t, int), resize(int, NoChange_t)
+ */
+ inline void resize(int rows, int cols)
+ {
+ ei_assert((MaxRowsAtCompileTime == Dynamic || MaxRowsAtCompileTime >= rows)
+ && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
+ && (MaxColsAtCompileTime == Dynamic || MaxColsAtCompileTime >= cols)
+ && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
+ #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
+ int size = rows*cols;
+ bool size_changed = size != this->size();
+ m_storage.resize(size, rows, cols);
+ if(size_changed) EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ #else
+ m_storage.resize(rows*cols, rows, cols);
+ #endif
+ }
+
+ /** Resizes \c *this to a vector of length \a size
+ *
+ * \only_for_vectors. This method does not work for
+ * partially dynamic matrices when the static dimension is anything other
+ * than 1. For example it will not work with Matrix<double, 2, Dynamic>.
+ *
+ * Example: \include Matrix_resize_int.cpp
+ * Output: \verbinclude Matrix_resize_int.out
+ *
+ * \sa resize(int,int), resize(NoChange_t, int), resize(int, NoChange_t)
+ */
+ inline void resize(int size)
+ {
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(DenseStorageBase)
+ ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size);
+ #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
+ bool size_changed = size != this->size();
+ #endif
+ if(RowsAtCompileTime == 1)
+ m_storage.resize(size, 1, size);
+ else
+ m_storage.resize(size, size, 1);
+ #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
+ if(size_changed) EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ #endif
+ }
+
+ /** Resizes the matrix, changing only the number of columns. For the parameter of type NoChange_t, just pass the special value \c NoChange
+ * as in the example below.
+ *
+ * Example: \include Matrix_resize_NoChange_int.cpp
+ * Output: \verbinclude Matrix_resize_NoChange_int.out
+ *
+ * \sa resize(int,int)
+ */
+ inline void resize(NoChange_t, int cols)
+ {
+ resize(rows(), cols);
+ }
+
+ /** Resizes the matrix, changing only the number of rows. For the parameter of type NoChange_t, just pass the special value \c NoChange
+ * as in the example below.
+ *
+ * Example: \include Matrix_resize_int_NoChange.cpp
+ * Output: \verbinclude Matrix_resize_int_NoChange.out
+ *
+ * \sa resize(int,int)
+ */
+ inline void resize(int rows, NoChange_t)
+ {
+ resize(rows, cols());
+ }
+
+ /** Resizes \c *this to have the same dimensions as \a other.
+ * Takes care of doing all the checking that's needed.
+ *
+ * Note that copying a row-vector into a vector (and conversely) is allowed.
+ * The resizing, if any, is then done in the appropriate way so that row-vectors
+ * remain row-vectors and vectors remain vectors.
+ */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE void resizeLike(const DenseBase<OtherDerived>& other)
+ {
+ if(RowsAtCompileTime == 1)
+ {
+ ei_assert(other.isVector());
+ resize(1, other.size());
+ }
+ else if(ColsAtCompileTime == 1)
+ {
+ ei_assert(other.isVector());
+ resize(other.size(), 1);
+ }
+ else resize(other.rows(), other.cols());
+ }
+
+ /** Resizes \c *this to a \a rows x \a cols matrix while leaving old values of \c *this untouched.
+ *
+ * This method is intended for dynamic-size matrices. If you only want to change the number
+ * of rows and/or of columns, you can use conservativeResize(NoChange_t, int),
+ * conservativeResize(int, NoChange_t).
+ *
+ * The top-left part of the resized matrix will be the same as the overlapping top-left corner
+ * of \c *this. In case values need to be appended to the matrix they will be uninitialized.
+ */
+ EIGEN_STRONG_INLINE void conservativeResize(int rows, int cols)
+ {
+ // FIXME THIS IS VERY BAD !!!
+ conservativeResizeLike(PlainMatrixType(rows, cols));
+ }
+
+ EIGEN_STRONG_INLINE void conservativeResize(int rows, NoChange_t)
+ {
+ // Note: see the comment in conservativeResize(int,int)
+ conservativeResize(rows, cols());
+ }
+
+ EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, int cols)
+ {
+ // Note: see the comment in conservativeResize(int,int)
+ conservativeResize(rows(), cols);
+ }
+
+ /** Resizes \c *this to a vector of length \a size while retaining old values of *this.
+ *
+ * \only_for_vectors. This method does not work for
+ * partially dynamic matrices when the static dimension is anything other
+ * than 1. For example it will not work with Matrix<double, 2, Dynamic>.
+ *
+ * When values are appended, they will be uninitialized.
+ */
+ EIGEN_STRONG_INLINE void conservativeResize(int size)
+ {
+ // FIXME THIS IS VERY BAD (unless we mark PlainMatrixType(size) as a temporary to simply swap it)!!!
+ conservativeResizeLike(PlainMatrixType(size));
+ }
+
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE void conservativeResizeLike(const DenseBase<OtherDerived>& other)
+ {
+ ei_conservative_resize_like_impl<Derived, OtherDerived>::run(*this, other);
+ }
+
+ /** This is a special case of the templated operator=. Its purpose is to
+ * prevent a default operator= from hiding the templated operator=.
+ */
+ EIGEN_STRONG_INLINE Derived& operator=(const DenseStorageBase& other)
+ {
+ return _set(other);
+ }
+
+ /** \sa MatrixBase::lazyAssign() */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE Derived& lazyAssign(const DenseBase<OtherDerived>& other)
+ {
+ _resize_to_match(other);
+ return Base::lazyAssign(other.derived());
+ }
+
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE Derived& operator=(const ReturnByValue<OtherDerived>& func)
+ {
+ resize(func.rows(), func.cols());
+ return Base::operator=(func);
+ }
+
+ using Base::operator +=;
+ using Base::operator -=;
+ using Base::operator *=;
+ using Base::operator /=;
+
+ EIGEN_STRONG_INLINE explicit DenseStorageBase() : m_storage()
+ {
+// _check_template_params();
+// EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ }
+
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ // FIXME is it still needed ?
+ /** \internal */
+ DenseStorageBase(ei_constructor_without_unaligned_array_assert)
+ : m_storage(ei_constructor_without_unaligned_array_assert())
+ {
+// _check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ }
+#endif
+
+ EIGEN_STRONG_INLINE DenseStorageBase(int size, int rows, int cols)
+ : m_storage(size, rows, cols)
+ {
+// _check_template_params();
+// EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ }
+
+ /** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE Derived& operator=(const AnyMatrixBase<OtherDerived> &other)
+ {
+ resize(other.derived().rows(), other.derived().cols());
+ Base::operator=(other.derived());
+ return this->derived();
+ }
+
+ /** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE DenseStorageBase(const AnyMatrixBase<OtherDerived> &other)
+ : m_storage(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
+ {
+ _check_template_params();
+ resize(other.rows(), other.cols());
+ *this = other;
+ }
+
+ /** \name Map
+ * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects,
+ * while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned
+ * \a data pointers.
+ *
+ * \see class Map
+ */
+ //@{
+ inline static const UnalignedMapType Map(const Scalar* data)
+ { return UnalignedMapType(data); }
+ inline static UnalignedMapType Map(Scalar* data)
+ { return UnalignedMapType(data); }
+ inline static const UnalignedMapType Map(const Scalar* data, int size)
+ { return UnalignedMapType(data, size); }
+ inline static UnalignedMapType Map(Scalar* data, int size)
+ { return UnalignedMapType(data, size); }
+ inline static const UnalignedMapType Map(const Scalar* data, int rows, int cols)
+ { return UnalignedMapType(data, rows, cols); }
+ inline static UnalignedMapType Map(Scalar* data, int rows, int cols)
+ { return UnalignedMapType(data, rows, cols); }
+
+ inline static const AlignedMapType MapAligned(const Scalar* data)
+ { return AlignedMapType(data); }
+ inline static AlignedMapType MapAligned(Scalar* data)
+ { return AlignedMapType(data); }
+ inline static const AlignedMapType MapAligned(const Scalar* data, int size)
+ { return AlignedMapType(data, size); }
+ inline static AlignedMapType MapAligned(Scalar* data, int size)
+ { return AlignedMapType(data, size); }
+ inline static const AlignedMapType MapAligned(const Scalar* data, int rows, int cols)
+ { return AlignedMapType(data, rows, cols); }
+ inline static AlignedMapType MapAligned(Scalar* data, int rows, int cols)
+ { return AlignedMapType(data, rows, cols); }
+ //@}
+
+ using Base::setConstant;
+ Derived& setConstant(int size, const Scalar& value);
+ Derived& setConstant(int rows, int cols, const Scalar& value);
+
+ using Base::setZero;
+ Derived& setZero(int size);
+ Derived& setZero(int rows, int cols);
+
+ using Base::setOnes;
+ Derived& setOnes(int size);
+ Derived& setOnes(int rows, int cols);
+
+ using Base::setRandom;
+ Derived& setRandom(int size);
+ Derived& setRandom(int rows, int cols);
+
+ #ifdef EIGEN_DENSESTORAGEBASE_PLUGIN
+ #include EIGEN_DENSESTORAGEBASE_PLUGIN
+ #endif
+
+ protected:
+ /** \internal Resizes *this in preparation for assigning \a other to it.
+ * Takes care of doing all the checking that's needed.
+ *
+ * Note that copying a row-vector into a vector (and conversely) is allowed.
+ * The resizing, if any, is then done in the appropriate way so that row-vectors
+ * remain row-vectors and vectors remain vectors.
+ */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE void _resize_to_match(const DenseBase<OtherDerived>& other)
+ {
+ #ifdef EIGEN_NO_AUTOMATIC_RESIZING
+ ei_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size())
+ : (rows() == other.rows() && cols() == other.cols())))
+ && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
+ #endif
+ resizeLike(other);
+ }
+
+ /** \internal Copies the value of the expression \a other into \c *this with automatic resizing.
+ *
+ * *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized),
+ * it will be initialized.
+ *
+ * Note that copying a row-vector into a vector (and conversely) is allowed.
+ * The resizing, if any, is then done in the appropriate way so that row-vectors
+ * remain row-vectors and vectors remain vectors.
+ *
+ * \sa operator=(const MatrixBase<OtherDerived>&), _set_noalias()
+ */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE Derived& _set(const DenseBase<OtherDerived>& other)
+ {
+ _set_selector(other.derived(), typename ei_meta_if<static_cast<bool>(int(OtherDerived::Flags) & EvalBeforeAssigningBit), ei_meta_true, ei_meta_false>::ret());
+ return this->derived();
+ }
+
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_true&) { _set_noalias(other.eval()); }
+
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_false&) { _set_noalias(other); }
+
+ /** \internal Like _set() but additionally makes the assumption that no aliasing effect can happen (which
+ * is the case when creating a new matrix) so one can enforce lazy evaluation.
+ *
+ * \sa operator=(const MatrixBase<OtherDerived>&), _set()
+ */
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE Derived& _set_noalias(const DenseBase<OtherDerived>& other)
+ {
+ _resize_to_match(other);
+ // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
+ // it wouldn't allow to copy a row-vector into a column-vector.
+ return ei_assign_selector<Derived,OtherDerived,false>::run(this->derived(), other.derived());
+ }
+
+ static EIGEN_STRONG_INLINE void _check_template_params()
+ {
+ #ifdef EIGEN_DEBUG_MATRIX_CTOR
+ EIGEN_DEBUG_MATRIX_CTOR;
+ #endif
+
+ EIGEN_STATIC_ASSERT(((RowsAtCompileTime >= MaxRowsAtCompileTime)
+ && (ColsAtCompileTime >= MaxColsAtCompileTime)
+ && (MaxRowsAtCompileTime >= 0)
+ && (MaxColsAtCompileTime >= 0)
+ && (RowsAtCompileTime <= Dynamic)
+ && (ColsAtCompileTime <= Dynamic)
+ && (MaxRowsAtCompileTime == RowsAtCompileTime || RowsAtCompileTime==Dynamic)
+ && (MaxColsAtCompileTime == ColsAtCompileTime || ColsAtCompileTime==Dynamic)
+ && ((MaxRowsAtCompileTime==Dynamic?1:MaxRowsAtCompileTime)*(MaxColsAtCompileTime==Dynamic?1:MaxColsAtCompileTime)<Dynamic)
+ && (_Options & (DontAlign|RowMajor)) == _Options),
+ INVALID_MATRIX_TEMPLATE_PARAMETERS)
+ }
+
+
+ template<typename T0, typename T1>
+ EIGEN_STRONG_INLINE void _init2(int rows, int cols, typename ei_enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
+ {
+ ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
+ && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
+ m_storage.resize(rows*cols,rows,cols);
+ EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+ }
+ template<typename T0, typename T1>
+ EIGEN_STRONG_INLINE void _init2(const Scalar& x, const Scalar& y, typename ei_enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)
+ {
+ EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(DenseStorageBase, 2)
+ m_storage.data()[0] = x;
+ m_storage.data()[1] = y;
+ }
+
+ template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
+ friend struct ei_matrix_swap_impl;
+
+ /** \internal generic implemention of swap for dense storage since for dynamic-sized matrices of same type it is enough to swap the
+ * data pointers.
+ */
+ template<typename OtherDerived>
+ void _swap(DenseBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
+ {
+ enum { SwapPointers = ei_is_same_type<Derived, OtherDerived>::ret && Base::SizeAtCompileTime==Dynamic };
+ ei_matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.const_cast_derived());
+ }
+};
+
+
+
+template <typename Derived, typename OtherDerived, bool IsVector>
+struct ei_conservative_resize_like_impl
+{
+ static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)
+ {
+ if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
+
+ // Note: Here is space for improvement. Basically, for conservativeResize(int,int),
+ // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
+ // dimensions is dynamic, one could use either conservativeResize(int rows, NoChange_t) or
+ // conservativeResize(NoChange_t, int cols). For these methods new static asserts like
+ // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
+ EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
+ EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
+
+ typename Derived::PlainMatrixType tmp(other);
+ const int common_rows = std::min(tmp.rows(), _this.rows());
+ const int common_cols = std::min(tmp.cols(), _this.cols());
+ tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
+ _this.derived().swap(tmp);
+ }
+};
+
+template <typename Derived, typename OtherDerived>
+struct ei_conservative_resize_like_impl<Derived,OtherDerived,true>
+{
+ static void run(DenseBase<Derived>& _this, const DenseBase<OtherDerived>& other)
+ {
+ if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
+
+ // segment(...) will check whether Derived/OtherDerived are vectors!
+ typename Derived::PlainMatrixType tmp(other);
+ const int common_size = std::min<int>(_this.size(),tmp.size());
+ tmp.segment(0,common_size) = _this.segment(0,common_size);
+ _this.derived().swap(tmp);
+ }
+};
+
+template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers>
+struct ei_matrix_swap_impl
+{
+ static inline void run(MatrixTypeA& a, MatrixTypeB& b)
+ {
+ a.base().swap(b);
+ }
+};
+
+template<typename MatrixTypeA, typename MatrixTypeB>
+struct ei_matrix_swap_impl<MatrixTypeA, MatrixTypeB, true>
+{
+ static inline void run(MatrixTypeA& a, MatrixTypeB& b)
+ {
+ a.m_storage.swap(b.m_storage);
+ }
+};
+
+#endif // EIGEN_DENSESTORAGEBASE_H
diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h
index f2bc8566e..344dbca40 100644
--- a/Eigen/src/Core/Diagonal.h
+++ b/Eigen/src/Core/Diagonal.h
@@ -44,8 +44,8 @@
*/
template<typename MatrixType, int Index>
struct ei_traits<Diagonal<MatrixType,Index> >
+ : ei_traits<MatrixType>
{
- typedef typename MatrixType::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h
index 360f03dd2..bd23b2e09 100644
--- a/Eigen/src/Core/DiagonalMatrix.h
+++ b/Eigen/src/Core/DiagonalMatrix.h
@@ -67,6 +67,12 @@ class DiagonalBase : public AnyMatrixBase<Derived>
template<typename MatrixDerived>
const DiagonalProduct<MatrixDerived, Derived, OnTheLeft>
operator*(const MatrixBase<MatrixDerived> &matrix) const;
+
+ inline const DiagonalWrapper<NestByValue<CwiseUnaryOp<ei_scalar_inverse_op<Scalar>, DiagonalVectorType> > >
+ inverse() const
+ {
+ return diagonal().cwiseInverse().nestByValue();
+ }
};
template<typename Derived>
diff --git a/Eigen/src/Core/DiagonalProduct.h b/Eigen/src/Core/DiagonalProduct.h
index fb3b11bdd..87068d9ba 100644
--- a/Eigen/src/Core/DiagonalProduct.h
+++ b/Eigen/src/Core/DiagonalProduct.h
@@ -28,6 +28,7 @@
template<typename MatrixType, typename DiagonalType, int ProductOrder>
struct ei_traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> >
+ : ei_traits<MatrixType>
{
typedef typename ei_scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar;
enum {
diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h
index a8983d4ce..f0c520b1f 100644
--- a/Eigen/src/Core/Dot.h
+++ b/Eigen/src/Core/Dot.h
@@ -279,7 +279,7 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
template<typename Derived>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const
{
- return ei_real((*this).cwise().abs2().sum());
+ return ei_real((*this).cwiseAbs2().sum());
}
/** \returns the \em l2 norm of *this, i.e., for vectors, the square root of the dot product of *this with itself.
diff --git a/Eigen/src/Core/Flagged.h b/Eigen/src/Core/Flagged.h
deleted file mode 100644
index 754eaf6c5..000000000
--- a/Eigen/src/Core/Flagged.h
+++ /dev/null
@@ -1,149 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra.
-//
-// Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
-//
-// Eigen is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 3 of the License, or (at your option) any later version.
-//
-// Alternatively, you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of
-// the License, or (at your option) any later version.
-//
-// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License and a copy of the GNU General Public License along with
-// Eigen. If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef EIGEN_FLAGGED_H
-#define EIGEN_FLAGGED_H
-
-/** \deprecated it is only used by lazy() which is deprecated
- *
- * \class Flagged
- *
- * \brief Expression with modified flags
- *
- * \param ExpressionType the type of the object of which we are modifying the flags
- * \param Added the flags added to the expression
- * \param Removed the flags removed from the expression (has priority over Added).
- *
- * This class represents an expression whose flags have been modified.
- * It is the return type of MatrixBase::flagged()
- * and most of the time this is the only way it is used.
- *
- * \sa MatrixBase::flagged()
- */
-template<typename ExpressionType, unsigned int Added, unsigned int Removed>
-struct ei_traits<Flagged<ExpressionType, Added, Removed> > : ei_traits<ExpressionType>
-{
- enum { Flags = (ExpressionType::Flags | Added) & ~Removed };
-};
-
-template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged
- : public MatrixBase<Flagged<ExpressionType, Added, Removed> >
-{
- public:
-
- EIGEN_GENERIC_PUBLIC_INTERFACE(Flagged)
- typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
- ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
- typedef typename ExpressionType::InnerIterator InnerIterator;
-
- inline Flagged(const ExpressionType& matrix) : m_matrix(matrix) {}
-
- inline int rows() const { return m_matrix.rows(); }
- inline int cols() const { return m_matrix.cols(); }
- inline int stride() const { return m_matrix.stride(); }
-
- inline const Scalar coeff(int row, int col) const
- {
- return m_matrix.coeff(row, col);
- }
-
- inline Scalar& coeffRef(int row, int col)
- {
- return m_matrix.const_cast_derived().coeffRef(row, col);
- }
-
- inline const Scalar coeff(int index) const
- {
- return m_matrix.coeff(index);
- }
-
- inline Scalar& coeffRef(int index)
- {
- return m_matrix.const_cast_derived().coeffRef(index);
- }
-
- template<int LoadMode>
- inline const PacketScalar packet(int row, int col) const
- {
- return m_matrix.template packet<LoadMode>(row, col);
- }
-
- template<int LoadMode>
- inline void writePacket(int row, int col, const PacketScalar& x)
- {
- m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x);
- }
-
- template<int LoadMode>
- inline const PacketScalar packet(int index) const
- {
- return m_matrix.template packet<LoadMode>(index);
- }
-
- template<int LoadMode>
- inline void writePacket(int index, const PacketScalar& x)
- {
- m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
- }
-
- const ExpressionType& _expression() const { return m_matrix; }
-
- protected:
- ExpressionTypeNested m_matrix;
-};
-
-/** \deprecated it is only used by lazy() which is deprecated
- *
- * \returns an expression of *this with added flags
- *
- * Example: \include MatrixBase_marked.cpp
- * Output: \verbinclude MatrixBase_marked.out
- *
- * \sa class Flagged, extract(), part()
- */
-template<typename Derived>
-template<unsigned int Added>
-inline const Flagged<Derived, Added, 0>
-MatrixBase<Derived>::marked() const
-{
- return derived();
-}
-
-/** \deprecated use MatrixBase::noalias()
- *
- * \returns an expression of *this with the EvalBeforeAssigningBit flag removed.
- *
- * Example: \include MatrixBase_lazy.cpp
- * Output: \verbinclude MatrixBase_lazy.out
- *
- * \sa class Flagged, marked()
- */
-template<typename Derived>
-inline const Flagged<Derived, 0, EvalBeforeAssigningBit>
-MatrixBase<Derived>::lazy() const
-{
- return derived();
-}
-
-#endif // EIGEN_FLAGGED_H
diff --git a/Eigen/src/Core/ForceAlignedAccess.h b/Eigen/src/Core/ForceAlignedAccess.h
new file mode 100644
index 000000000..b3fbb3c5c
--- /dev/null
+++ b/Eigen/src/Core/ForceAlignedAccess.h
@@ -0,0 +1,151 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_FORCEALIGNEDACCESS_H
+#define EIGEN_FORCEALIGNEDACCESS_H
+
+/** \class ForceAlignedAccess
+ *
+ * \brief Enforce aligned packet loads and stores regardless of what is requested
+ *
+ * \param ExpressionType the type of the object of which we are forcing aligned packet access
+ *
+ * This class is the return type of MatrixBase::forceAlignedAccess()
+ * and most of the time this is the only way it is used.
+ *
+ * \sa MatrixBase::forceAlignedAccess()
+ */
+template<typename ExpressionType>
+struct ei_traits<ForceAlignedAccess<ExpressionType> > : public ei_traits<ExpressionType>
+{};
+
+template<typename ExpressionType> class ForceAlignedAccess
+ : public MatrixBase<ForceAlignedAccess<ExpressionType> >
+{
+ public:
+
+ EIGEN_GENERIC_PUBLIC_INTERFACE(ForceAlignedAccess)
+
+ inline ForceAlignedAccess(const ExpressionType& matrix) : m_expression(matrix) {}
+
+ inline int rows() const { return m_expression.rows(); }
+ inline int cols() const { return m_expression.cols(); }
+ inline int stride() const { return m_expression.stride(); }
+
+ inline const CoeffReturnType coeff(int row, int col) const
+ {
+ return m_expression.coeff(row, col);
+ }
+
+ inline Scalar& coeffRef(int row, int col)
+ {
+ return m_expression.const_cast_derived().coeffRef(row, col);
+ }
+
+ inline const CoeffReturnType coeff(int index) const
+ {
+ return m_expression.coeff(index);
+ }
+
+ inline Scalar& coeffRef(int index)
+ {
+ return m_expression.const_cast_derived().coeffRef(index);
+ }
+
+ template<int LoadMode>
+ inline const PacketScalar packet(int row, int col) const
+ {
+ return m_expression.template packet<Aligned>(row, col);
+ }
+
+ template<int LoadMode>
+ inline void writePacket(int row, int col, const PacketScalar& x)
+ {
+ m_expression.const_cast_derived().template writePacket<Aligned>(row, col, x);
+ }
+
+ template<int LoadMode>
+ inline const PacketScalar packet(int index) const
+ {
+ return m_expression.template packet<Aligned>(index);
+ }
+
+ template<int LoadMode>
+ inline void writePacket(int index, const PacketScalar& x)
+ {
+ m_expression.const_cast_derived().template writePacket<Aligned>(index, x);
+ }
+
+ operator const ExpressionType&() const { return m_expression; }
+
+ protected:
+ const ExpressionType& m_expression;
+
+ private:
+ ForceAlignedAccess& operator=(const ForceAlignedAccess&);
+};
+
+/** \returns an expression of *this with forced aligned access
+ * \sa forceAlignedAccessIf(),class ForceAlignedAccess
+ */
+template<typename Derived>
+inline const ForceAlignedAccess<Derived>
+MatrixBase<Derived>::forceAlignedAccess() const
+{
+ return ForceAlignedAccess<Derived>(derived());
+}
+
+/** \returns an expression of *this with forced aligned access
+ * \sa forceAlignedAccessIf(), class ForceAlignedAccess
+ */
+template<typename Derived>
+inline ForceAlignedAccess<Derived>
+MatrixBase<Derived>::forceAlignedAccess()
+{
+ return ForceAlignedAccess<Derived>(derived());
+}
+
+/** \returns an expression of *this with forced aligned access if \a Enable is true.
+ * \sa forceAlignedAccess(), class ForceAlignedAccess
+ */
+template<typename Derived>
+template<bool Enable>
+inline const typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret
+MatrixBase<Derived>::forceAlignedAccessIf() const
+{
+ return derived();
+}
+
+/** \returns an expression of *this with forced aligned access if \a Enable is true.
+ * \sa forceAlignedAccess(), class ForceAlignedAccess
+ */
+template<typename Derived>
+template<bool Enable>
+inline typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret
+MatrixBase<Derived>::forceAlignedAccessIf()
+{
+ return derived();
+}
+
+#endif // EIGEN_FORCEALIGNEDACCESS_H
diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h
index e10446398..dfa042377 100644
--- a/Eigen/src/Core/Fuzzy.h
+++ b/Eigen/src/Core/Fuzzy.h
@@ -47,14 +47,17 @@
*/
template<typename Derived>
template<typename OtherDerived>
-bool MatrixBase<Derived>::isApprox(
- const MatrixBase<OtherDerived>& other,
+bool DenseBase<Derived>::isApprox(
+ const DenseBase<OtherDerived>& other,
RealScalar prec
) const
{
const typename ei_nested<Derived,2>::type nested(derived());
const typename ei_nested<OtherDerived,2>::type otherNested(other.derived());
- return (nested - otherNested).cwise().abs2().sum() <= prec * prec * std::min(nested.cwise().abs2().sum(), otherNested.cwise().abs2().sum());
+// std::cerr << typeid(Derived).name() << " => " << typeid(typename ei_nested<Derived,2>::type).name() << "\n";
+// std::cerr << typeid(OtherDerived).name() << " => " << typeid(typename ei_nested<OtherDerived,2>::type).name() << "\n";
+// return false;
+ return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * std::min(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
}
/** \returns \c true if the norm of \c *this is much smaller than \a other,
@@ -68,15 +71,15 @@ bool MatrixBase<Derived>::isApprox(
* the value of the reference scalar \a other should come from the Hilbert-Schmidt norm
* of a reference matrix of same dimensions.
*
- * \sa isApprox(), isMuchSmallerThan(const MatrixBase<OtherDerived>&, RealScalar) const
+ * \sa isApprox(), isMuchSmallerThan(const DenseBase<OtherDerived>&, RealScalar) const
*/
template<typename Derived>
-bool MatrixBase<Derived>::isMuchSmallerThan(
+bool DenseBase<Derived>::isMuchSmallerThan(
const typename NumTraits<Scalar>::Real& other,
RealScalar prec
) const
{
- return cwise().abs2().sum() <= prec * prec * other * other;
+ return derived().cwiseAbs2().sum() <= prec * prec * other * other;
}
/** \returns \c true if the norm of \c *this is much smaller than the norm of \a other,
@@ -91,12 +94,12 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
*/
template<typename Derived>
template<typename OtherDerived>
-bool MatrixBase<Derived>::isMuchSmallerThan(
- const MatrixBase<OtherDerived>& other,
+bool DenseBase<Derived>::isMuchSmallerThan(
+ const DenseBase<OtherDerived>& other,
RealScalar prec
) const
{
- return this->cwise().abs2().sum() <= prec * prec * other.cwise().abs2().sum();
+ return derived().cwiseAbs2().sum() <= prec * prec * other.derived().cwiseAbs2().sum();
}
#else
@@ -122,8 +125,8 @@ struct ei_fuzzy_selector;
*/
template<typename Derived>
template<typename OtherDerived>
-bool MatrixBase<Derived>::isApprox(
- const MatrixBase<OtherDerived>& other,
+bool DenseBase<Derived>::isApprox(
+ const DenseBase<OtherDerived>& other,
RealScalar prec
) const
{
@@ -138,10 +141,10 @@ bool MatrixBase<Derived>::isApprox(
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
* For matrices, the comparison is done on all columns.
*
- * \sa isApprox(), isMuchSmallerThan(const MatrixBase<OtherDerived>&, RealScalar) const
+ * \sa isApprox(), isMuchSmallerThan(const DenseBase<OtherDerived>&, RealScalar) const
*/
template<typename Derived>
-bool MatrixBase<Derived>::isMuchSmallerThan(
+bool DenseBase<Derived>::isMuchSmallerThan(
const typename NumTraits<Scalar>::Real& other,
RealScalar prec
) const
@@ -161,8 +164,8 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
*/
template<typename Derived>
template<typename OtherDerived>
-bool MatrixBase<Derived>::isMuchSmallerThan(
- const MatrixBase<OtherDerived>& other,
+bool DenseBase<Derived>::isMuchSmallerThan(
+ const DenseBase<OtherDerived>& other,
RealScalar prec
) const
{
diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h
index 77e5641ff..ae1720eca 100644
--- a/Eigen/src/Core/GenericPacketMath.h
+++ b/Eigen/src/Core/GenericPacketMath.h
@@ -34,6 +34,22 @@
* of generic vectorized code.
*/
+#ifndef EIGEN_DEBUG_ALIGNED_LOAD
+#define EIGEN_DEBUG_ALIGNED_LOAD
+#endif
+
+#ifndef EIGEN_DEBUG_UNALIGNED_LOAD
+#define EIGEN_DEBUG_UNALIGNED_LOAD
+#endif
+
+#ifndef EIGEN_DEBUG_ALIGNED_STORE
+#define EIGEN_DEBUG_ALIGNED_STORE
+#endif
+
+#ifndef EIGEN_DEBUG_UNALIGNED_STORE
+#define EIGEN_DEBUG_UNALIGNED_STORE
+#endif
+
struct ei_default_packet_traits
{
enum {
@@ -44,13 +60,13 @@ struct ei_default_packet_traits
HasAbs = 1,
HasMin = 1,
HasMax = 1,
-
+
HasDiv = 0,
HasSqrt = 0,
HasExp = 0,
HasLog = 0,
HasPow = 0,
-
+
HasSin = 0,
HasCos = 0,
HasTan = 0,
@@ -128,7 +144,7 @@ ei_pxor(const Packet& a, const Packet& b) { return a ^ b; }
/** \internal \returns the bitwise andnot of \a a and \a b */
template<typename Packet> inline Packet
ei_pandnot(const Packet& a, const Packet& b) { return a & (!b); }
-
+
/** \internal \returns a packet version of \a *from, from must be 16 bytes aligned */
template<typename Scalar> inline typename ei_packet_traits<Scalar>::type
ei_pload(const Scalar* from) { return *from; }
diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h
index a44802ed2..d132064a6 100644
--- a/Eigen/src/Core/IO.h
+++ b/Eigen/src/Core/IO.h
@@ -52,7 +52,7 @@ enum { StreamPrecision = -1,
* Example: \include IOFormat.cpp
* Output: \verbinclude IOFormat.out
*
- * \sa MatrixBase::format(), class WithFormat
+ * \sa DenseBase::format(), class WithFormat
*/
struct IOFormat
{
@@ -86,12 +86,12 @@ struct IOFormat
* \param ExpressionType the type of the object on which IO stream operations are performed
*
* This class represents an expression with stream operators controlled by a given IOFormat.
- * It is the return type of MatrixBase::format()
+ * It is the return type of DenseBase::format()
* and most of the time this is the only way it is used.
*
* See class IOFormat for some examples.
*
- * \sa MatrixBase::format(), class IOFormat
+ * \sa DenseBase::format(), class IOFormat
*/
template<typename ExpressionType>
class WithFormat
@@ -121,7 +121,7 @@ class WithFormat
*/
template<typename Derived>
inline const WithFormat<Derived>
-MatrixBase<Derived>::format(const IOFormat& fmt) const
+DenseBase<Derived>::format(const IOFormat& fmt) const
{
return WithFormat<Derived>(derived(), fmt);
}
@@ -133,9 +133,9 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm
{
const typename Derived::Nested m = _m;
typedef typename Derived::Scalar Scalar;
-
+
int width = 0;
-
+
std::streamsize explicit_precision;
if(fmt.precision == StreamPrecision)
{
@@ -151,7 +151,7 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm
{
explicit_precision = fmt.precision;
}
-
+
bool align_cols = !(fmt.flags & DontAlignCols);
if(align_cols)
{
@@ -190,21 +190,21 @@ std::ostream & ei_print_matrix(std::ostream & s, const Derived& _m, const IOForm
return s;
}
-/** \relates MatrixBase
+/** \relates DenseBase
*
* Outputs the matrix, to the given stream.
*
- * If you wish to print the matrix with a format different than the default, use MatrixBase::format().
+ * If you wish to print the matrix with a format different than the default, use DenseBase::format().
*
* It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers.
* If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters.
*
- * \sa MatrixBase::format()
+ * \sa DenseBase::format()
*/
template<typename Derived>
std::ostream & operator <<
(std::ostream & s,
- const MatrixBase<Derived> & m)
+ const DenseBase<Derived> & m)
{
return ei_print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);
}
diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h
index dba7e20e4..18fafdece 100644
--- a/Eigen/src/Core/Map.h
+++ b/Eigen/src/Core/Map.h
@@ -31,8 +31,8 @@
* \brief A matrix or vector expression mapping an existing array of data.
*
* \param MatrixType the equivalent matrix type of the mapped data
- * \param PointerAlignment specifies whether the pointer is \c Aligned, or \c Unaligned.
- * The default is \c Unaligned.
+ * \param Options specifies whether the pointer is \c Aligned, or \c Unaligned.
+ * The default is \c Unaligned.
*
* This class represents a matrix or vector expression mapping an existing array of data.
* It can be used to let Eigen interface without any overhead with non-Eigen data structures,
@@ -46,40 +46,28 @@
*
* This class is the return type of Matrix::Map() but can also be used directly.
*
- * \b Note \b to \b Eigen \b developers: The template parameter \c PointerAlignment
- * can also be or-ed with \c EnforceAlignedAccess in order to enforce aligned read
- * in expressions such as \code A += B; \endcode. See class MapBase for further details.
- *
* \sa Matrix::Map()
*/
template<typename MatrixType, int Options>
struct ei_traits<Map<MatrixType, Options> > : public ei_traits<MatrixType>
{
enum {
- PacketAccess = Options & EnforceAlignedAccess,
Flags = (Options&Aligned)==Aligned ? ei_traits<MatrixType>::Flags | AlignedBit
: ei_traits<MatrixType>::Flags & ~AlignedBit
};
- typedef typename ei_meta_if<int(PacketAccess)==EnforceAlignedAccess,
- Map<MatrixType, Options>&,
- Map<MatrixType, Options|EnforceAlignedAccess> >::ret AlignedDerivedType;
};
template<typename MatrixType, int Options> class Map
- : public MapBase<Map<MatrixType, Options> >
+ : public MapBase<Map<MatrixType, Options>,
+ typename MatrixType::template MakeBase< Map<MatrixType, Options> >::Type>
{
public:
- _EIGEN_GENERIC_PUBLIC_INTERFACE(Map, MapBase<Map>)
- typedef typename ei_traits<Map>::AlignedDerivedType AlignedDerivedType;
+ typedef MapBase<Map,typename MatrixType::template MakeBase<Map>::Type> Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Map)
inline int stride() const { return this->innerSize(); }
- AlignedDerivedType _convertToEnforceAlignedAccess()
- {
- return AlignedDerivedType(Base::m_data, Base::m_rows.value(), Base::m_cols.value());
- }
-
inline Map(const Scalar* data) : Base(data) {}
inline Map(const Scalar* data, int size) : Base(data, size) {}
diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h
index 8770732de..0067fbe16 100644
--- a/Eigen/src/Core/MapBase.h
+++ b/Eigen/src/Core/MapBase.h
@@ -30,37 +30,21 @@
*
* \brief Base class for Map and Block expression with direct access
*
- * Expression classes inheriting MapBase must define the constant \c PacketAccess,
- * and type \c AlignedDerivedType in their respective ei_traits<> specialization structure.
- * The value of \c PacketAccess can be either \b AsRequested, or set to \b EnforceAlignedAccess which
- * enforces both aligned loads and stores.
- *
- * \c EnforceAlignedAccess is automatically set in expressions such as
- * \code A += B; \endcode where A is either a Block or a Map. Here,
- * this expression is transfomed into \code A = A_with_EnforceAlignedAccess + B; \endcode
- * avoiding unaligned loads from A. Indeed, since Eigen's packet evaluation mechanism
- * automatically align to the destination matrix, we know that loads to A will be aligned too.
- *
- * The type \c AlignedDerivedType should correspond to the equivalent expression type
- * with \c PacketAccess set to \c EnforceAlignedAccess.
- *
* \sa class Map, class Block
*/
-template<typename Derived> class MapBase
- : public MatrixBase<Derived>
+template<typename Derived, typename Base> class MapBase
+ : public Base
{
public:
- typedef MatrixBase<Derived> Base;
+// typedef MatrixBase<Derived> Base;
enum {
IsRowMajor = (int(ei_traits<Derived>::Flags) & RowMajorBit) ? 1 : 0,
- PacketAccess = ei_traits<Derived>::PacketAccess,
RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
SizeAtCompileTime = Base::SizeAtCompileTime
};
- typedef typename ei_traits<Derived>::AlignedDerivedType AlignedDerivedType;
typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename Base::PacketScalar PacketScalar;
using Base::derived;
@@ -85,21 +69,6 @@ template<typename Derived> class MapBase
* \sa MapBase::stride() */
inline const Scalar* data() const { return m_data; }
- template<bool IsEnforceAlignedAccess,typename Dummy> struct force_aligned_impl {
- static AlignedDerivedType run(MapBase& a) { return a.derived(); }
- };
-
- template<typename Dummy> struct force_aligned_impl<false,Dummy> {
- static AlignedDerivedType run(MapBase& a) { return a.derived()._convertToEnforceAlignedAccess(); }
- };
-
- /** \returns an expression equivalent to \c *this but having the \c PacketAccess constant
- * set to \c EnforceAlignedAccess. Must be reimplemented by the derived class. */
- AlignedDerivedType forceAligned()
- {
- return force_aligned_impl<int(PacketAccess)==int(EnforceAlignedAccess),Derived>::run(*this);
- }
-
inline const Scalar& coeff(int row, int col) const
{
if(IsRowMajor)
@@ -137,7 +106,7 @@ template<typename Derived> class MapBase
template<int LoadMode>
inline PacketScalar packet(int row, int col) const
{
- return ei_ploadt<Scalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : LoadMode>
+ return ei_ploadt<Scalar, LoadMode>
(m_data + (IsRowMajor ? col + row * stride()
: row + col * stride()));
}
@@ -145,13 +114,13 @@ template<typename Derived> class MapBase
template<int LoadMode>
inline PacketScalar packet(int index) const
{
- return ei_ploadt<Scalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : LoadMode>(m_data + index);
+ return ei_ploadt<Scalar, LoadMode>(m_data + index);
}
template<int StoreMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
- ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : StoreMode>
+ ei_pstoret<Scalar, PacketScalar, StoreMode>
(const_cast<Scalar*>(m_data) + (IsRowMajor ? col + row * stride()
: row + col * stride()), x);
}
@@ -159,7 +128,7 @@ template<typename Derived> class MapBase
template<int StoreMode>
inline void writePacket(int index, const PacketScalar& x)
{
- ei_pstoret<Scalar, PacketScalar, int(PacketAccess) == EnforceAlignedAccess ? Aligned : StoreMode>
+ ei_pstoret<Scalar, PacketScalar, StoreMode>
(const_cast<Scalar*>(m_data) + index, x);
}
@@ -197,32 +166,6 @@ template<typename Derived> class MapBase
using Base::operator=;
using Base::operator*=;
- // FIXME it seems VS does not allow to do "using Base::operator+="
- // and to overload operator+= at the same time, therefore we have to
- // explicitly add these two overloads.
- // Maybe there exists a better solution though.
- template<typename ProductDerived, typename Lhs,typename Rhs>
- Derived& operator+=(const Flagged<ProductBase<ProductDerived,Lhs,Rhs>, 0, EvalBeforeAssigningBit>& other)
- { return Base::operator+=(other); }
-
- template<typename ProductDerived, typename Lhs,typename Rhs>
- Derived& operator-=(const Flagged<ProductBase<ProductDerived,Lhs,Rhs>, 0, EvalBeforeAssigningBit>& other)
- { return Base::operator-=(other); }
-
- template<typename OtherDerived>
- Derived& operator+=(const MatrixBase<OtherDerived>& other)
- { return derived() = forceAligned() + other; }
-
- template<typename OtherDerived>
- Derived& operator-=(const MatrixBase<OtherDerived>& other)
- { return derived() = forceAligned() - other; }
-
- Derived& operator*=(const Scalar& other)
- { return derived() = forceAligned() * other; }
-
- Derived& operator/=(const Scalar& other)
- { return derived() = forceAligned() / other; }
-
protected:
void checkDataAlignment() const
@@ -230,7 +173,7 @@ template<typename Derived> class MapBase
ei_assert( ((!(ei_traits<Derived>::Flags&AlignedBit))
|| ((std::size_t(m_data)&0xf)==0)) && "data is not aligned");
}
-
+
const Scalar* EIGEN_RESTRICT m_data;
const ei_int_if_dynamic<RowsAtCompileTime> m_rows;
const ei_int_if_dynamic<ColsAtCompileTime> m_cols;
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index c2680b71c..24c618549 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -2,6 +2,7 @@
// for linear algebra.
//
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
+// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -25,14 +26,6 @@
#ifndef EIGEN_MATRIX_H
#define EIGEN_MATRIX_H
-#ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
-# define EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED for(int i=0;i<base().size();++i) coeffRef(i)=Scalar(0);
-#else
-# define EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
-#endif
-
-template <typename Derived, typename OtherDerived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct ei_conservative_resize_like_impl;
-
/** \class Matrix
*
* \brief The matrix class, also used for vectors and row-vectors
@@ -118,6 +111,8 @@ template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int
struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
{
typedef _Scalar Scalar;
+ typedef Dense StorageType;
+ typedef DenseStorageMatrix DenseStorageType;
enum {
RowsAtCompileTime = _Rows,
ColsAtCompileTime = _Cols,
@@ -130,265 +125,32 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
class Matrix
- : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
+ : public DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Options>
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
+
+ typedef DenseStorageBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, MatrixBase, _Options> Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
enum { Options = _Options };
typedef typename Base::PlainMatrixType PlainMatrixType;
- friend class Eigen::Map<Matrix, Unaligned>;
- typedef class Eigen::Map<Matrix, Unaligned> UnalignedMapType;
- friend class Eigen::Map<Matrix, Aligned>;
- typedef class Eigen::Map<Matrix, Aligned> AlignedMapType;
+// friend class Eigen::Map<Matrix, Unaligned>;
+// typedef class Eigen::Map<Matrix, Unaligned> UnalignedMapType;
+// friend class Eigen::Map<Matrix, Aligned>;
+// typedef class Eigen::Map<Matrix, Aligned> AlignedMapType;
protected:
- ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime, Options> m_storage;
+ using Base::m_storage;
+// ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime, Options> m_storage;
public:
enum { NeedsToAlign = (!(Options&DontAlign))
&& SizeAtCompileTime!=Dynamic && ((sizeof(Scalar)*SizeAtCompileTime)%16)==0 };
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
- Base& base() { return *static_cast<Base*>(this); }
- const Base& base() const { return *static_cast<const Base*>(this); }
-
- EIGEN_STRONG_INLINE int rows() const { return m_storage.rows(); }
- EIGEN_STRONG_INLINE int cols() const { return m_storage.cols(); }
-
- /** Returns the leading dimension (for matrices) or the increment (for vectors) to be used with data().
- *
- * More precisely:
- * - for a column major matrix it returns the number of elements between two successive columns
- * - for a row major matrix it returns the number of elements between two successive rows
- * - for a vector it returns the number of elements between two successive coefficients
- * This function has to be used together with the MapBase::data() function.
- *
- * \sa Matrix::data() */
- EIGEN_STRONG_INLINE int stride() const
- {
- if(IsVectorAtCompileTime)
- return 1;
- else
- return (Flags & RowMajorBit) ? m_storage.cols() : m_storage.rows();
- }
-
- EIGEN_STRONG_INLINE const Scalar& coeff(int row, int 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& coeff(int index) const
- {
- return m_storage.data()[index];
- }
-
- EIGEN_STRONG_INLINE Scalar& coeffRef(int row, int col)
- {
- 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 Scalar& coeffRef(int index)
- {
- return m_storage.data()[index];
- }
-
- template<int LoadMode>
- EIGEN_STRONG_INLINE PacketScalar packet(int row, int col) const
- {
- return ei_ploadt<Scalar, LoadMode>
- (m_storage.data() + (Flags & RowMajorBit
- ? col + row * m_storage.cols()
- : row + col * m_storage.rows()));
- }
-
- template<int LoadMode>
- EIGEN_STRONG_INLINE PacketScalar packet(int index) const
- {
- return ei_ploadt<Scalar, LoadMode>(m_storage.data() + index);
- }
-
- template<int StoreMode>
- EIGEN_STRONG_INLINE void writePacket(int row, int col, const PacketScalar& x)
- {
- ei_pstoret<Scalar, PacketScalar, StoreMode>
- (m_storage.data() + (Flags & RowMajorBit
- ? col + row * m_storage.cols()
- : row + col * m_storage.rows()), x);
- }
-
- template<int StoreMode>
- EIGEN_STRONG_INLINE void writePacket(int index, const PacketScalar& x)
- {
- ei_pstoret<Scalar, PacketScalar, StoreMode>(m_storage.data() + index, x);
- }
-
- /** \returns a const pointer to the data array of this matrix */
- EIGEN_STRONG_INLINE const Scalar *data() const
- { return m_storage.data(); }
-
- /** \returns a pointer to the data array of this matrix */
- EIGEN_STRONG_INLINE Scalar *data()
- { return m_storage.data(); }
-
- /** Resizes \c *this to a \a rows x \a cols matrix.
- *
- * This method is intended for dynamic-size matrices, although it is legal to call it on any
- * matrix as long as fixed dimensions are left unchanged. If you only want to change the number
- * of rows and/or of columns, you can use resize(NoChange_t, int), resize(int, NoChange_t).
- *
- * If the current number of coefficients of \c *this exactly matches the
- * product \a rows * \a cols, then no memory allocation is performed and
- * the current values are left unchanged. In all other cases, including
- * shrinking, the data is reallocated and all previous values are lost.
- *
- * Example: \include Matrix_resize_int_int.cpp
- * Output: \verbinclude Matrix_resize_int_int.out
- *
- * \sa resize(int) for vectors, resize(NoChange_t, int), resize(int, NoChange_t)
- */
- inline void resize(int rows, int cols)
- {
- ei_assert((MaxRowsAtCompileTime == Dynamic || MaxRowsAtCompileTime >= rows)
- && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
- && (MaxColsAtCompileTime == Dynamic || MaxColsAtCompileTime >= cols)
- && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
- #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
- int size = rows*cols;
- bool size_changed = size != this->size();
- m_storage.resize(size, rows, cols);
- if(size_changed) EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
- #else
- m_storage.resize(rows*cols, rows, cols);
- #endif
- }
-
- /** Resizes \c *this to a vector of length \a size
- *
- * \only_for_vectors. This method does not work for
- * partially dynamic matrices when the static dimension is anything other
- * than 1. For example it will not work with Matrix<double, 2, Dynamic>.
- *
- * Example: \include Matrix_resize_int.cpp
- * Output: \verbinclude Matrix_resize_int.out
- *
- * \sa resize(int,int), resize(NoChange_t, int), resize(int, NoChange_t)
- */
- inline void resize(int size)
- {
- EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
- ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == size);
- #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
- bool size_changed = size != this->size();
- #endif
- if(RowsAtCompileTime == 1)
- m_storage.resize(size, 1, size);
- else
- m_storage.resize(size, size, 1);
- #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
- if(size_changed) EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
- #endif
- }
-
- /** Resizes the matrix, changing only the number of columns. For the parameter of type NoChange_t, just pass the special value \c NoChange
- * as in the example below.
- *
- * Example: \include Matrix_resize_NoChange_int.cpp
- * Output: \verbinclude Matrix_resize_NoChange_int.out
- *
- * \sa resize(int,int)
- */
- inline void resize(NoChange_t, int cols)
- {
- resize(rows(), cols);
- }
-
- /** Resizes the matrix, changing only the number of rows. For the parameter of type NoChange_t, just pass the special value \c NoChange
- * as in the example below.
- *
- * Example: \include Matrix_resize_int_NoChange.cpp
- * Output: \verbinclude Matrix_resize_int_NoChange.out
- *
- * \sa resize(int,int)
- */
- inline void resize(int rows, NoChange_t)
- {
- resize(rows, cols());
- }
-
- /** Resizes *this to have the same dimensions as \a other.
- * Takes care of doing all the checking that's needed.
- *
- * Note that copying a row-vector into a vector (and conversely) is allowed.
- * The resizing, if any, is then done in the appropriate way so that row-vectors
- * remain row-vectors and vectors remain vectors.
- */
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE void resizeLike(const MatrixBase<OtherDerived>& other)
- {
- if(RowsAtCompileTime == 1)
- {
- ei_assert(other.isVector());
- resize(1, other.size());
- }
- else if(ColsAtCompileTime == 1)
- {
- ei_assert(other.isVector());
- resize(other.size(), 1);
- }
- else resize(other.rows(), other.cols());
- }
-
- /** Resizes \c *this to a \a rows x \a cols matrix while leaving old values of *this untouched.
- *
- * This method is intended for dynamic-size matrices. If you only want to change the number
- * of rows and/or of columns, you can use conservativeResize(NoChange_t, int),
- * conservativeResize(int, NoChange_t).
- *
- * The top-left part of the resized matrix will be the same as the overlapping top-left corner
- * of *this. In case values need to be appended to the matrix they will be uninitialized.
- */
- EIGEN_STRONG_INLINE void conservativeResize(int rows, int cols)
- {
- conservativeResizeLike(PlainMatrixType(rows, cols));
- }
-
- EIGEN_STRONG_INLINE void conservativeResize(int rows, NoChange_t)
- {
- // Note: see the comment in conservativeResize(int,int)
- conservativeResize(rows, cols());
- }
-
- EIGEN_STRONG_INLINE void conservativeResize(NoChange_t, int cols)
- {
- // Note: see the comment in conservativeResize(int,int)
- conservativeResize(rows(), cols);
- }
-
- /** Resizes \c *this to a vector of length \a size while retaining old values of *this.
- *
- * \only_for_vectors. This method does not work for
- * partially dynamic matrices when the static dimension is anything other
- * than 1. For example it will not work with Matrix<double, 2, Dynamic>.
- *
- * When values are appended, they will be uninitialized.
- */
- EIGEN_STRONG_INLINE void conservativeResize(int size)
- {
- conservativeResizeLike(PlainMatrixType(size));
- }
-
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE void conservativeResizeLike(const MatrixBase<OtherDerived>& other)
- {
- ei_conservative_resize_like_impl<Matrix, OtherDerived>::run(*this, other);
- }
+ using Base::base;
+ using Base::coeff;
+ using Base::coeffRef;
/** Copies the value of the expression \a other into \c *this with automatic resizing.
*
@@ -402,7 +164,7 @@ class Matrix
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix& operator=(const MatrixBase<OtherDerived>& other)
{
- return _set(other);
+ return Base::_set(other);
}
/** This is a special case of the templated operator=. Its purpose is to
@@ -410,24 +172,10 @@ class Matrix
*/
EIGEN_STRONG_INLINE Matrix& operator=(const Matrix& other)
{
- return _set(other);
- }
-
- /** \sa MatrixBase::lazyAssign() */
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE Matrix& lazyAssign(const MatrixBase<OtherDerived>& other)
- {
- _resize_to_match(other);
- return Base::lazyAssign(other.derived());
- }
-
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE Matrix& operator=(const ReturnByValue<OtherDerived>& func)
- {
- resize(func.rows(), func.cols());
- return Base::operator=(func);
+ return Base::_set(other);
}
+ using Base::operator =;
using Base::operator +=;
using Base::operator -=;
using Base::operator *=;
@@ -443,17 +191,18 @@ class Matrix
*
* \sa resize(int,int)
*/
- EIGEN_STRONG_INLINE explicit Matrix() : m_storage()
+ EIGEN_STRONG_INLINE explicit Matrix() : Base()
{
- _check_template_params();
+ Base::_check_template_params();
EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
+ // FIXME is it still needed
/** \internal */
Matrix(ei_constructor_without_unaligned_array_assert)
- : m_storage(ei_constructor_without_unaligned_array_assert())
- { _check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED }
+ : Base(ei_constructor_without_unaligned_array_assert())
+ { Base::_check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED }
#endif
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
@@ -463,9 +212,9 @@ class Matrix
* constructor Matrix() instead.
*/
EIGEN_STRONG_INLINE explicit Matrix(int dim)
- : m_storage(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
+ : Base(dim, RowsAtCompileTime == 1 ? 1 : dim, ColsAtCompileTime == 1 ? 1 : dim)
{
- _check_template_params();
+ Base::_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
ei_assert(dim > 0);
ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
@@ -476,8 +225,8 @@ class Matrix
template<typename T0, typename T1>
EIGEN_STRONG_INLINE Matrix(const T0& x, const T1& y)
{
- _check_template_params();
- _init2<T0,T1>(x, y);
+ Base::_check_template_params();
+ Base::template _init2<T0,T1>(x, y);
}
#else
/** constructs an uninitialized matrix with \a rows rows and \a cols columns.
@@ -493,7 +242,7 @@ class Matrix
/** constructs an initialized 3D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
{
- _check_template_params();
+ Base::_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 3)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
@@ -502,7 +251,7 @@ class Matrix
/** constructs an initialized 4D vector with given coefficients */
EIGEN_STRONG_INLINE Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
{
- _check_template_params();
+ Base::_check_template_params();
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 4)
m_storage.data()[0] = x;
m_storage.data()[1] = y;
@@ -515,43 +264,34 @@ class Matrix
/** Constructor copying the value of the expression \a other */
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix(const MatrixBase<OtherDerived>& other)
- : m_storage(other.rows() * other.cols(), other.rows(), other.cols())
+ : Base(other.rows() * other.cols(), other.rows(), other.cols())
{
- _check_template_params();
- _set_noalias(other);
+ Base::_check_template_params();
+ Base::_set_noalias(other);
}
/** Copy constructor */
EIGEN_STRONG_INLINE Matrix(const Matrix& other)
- : Base(), m_storage(other.rows() * other.cols(), other.rows(), other.cols())
+ : Base(other.rows() * other.cols(), other.rows(), other.cols())
{
- _check_template_params();
- _set_noalias(other);
+ Base::_check_template_params();
+ Base::_set_noalias(other);
}
/** Copy constructor with in-place evaluation */
template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix(const ReturnByValue<OtherDerived>& other)
{
- _check_template_params();
- resize(other.rows(), other.cols());
+ Base::_check_template_params();
+ Base::resize(other.rows(), other.cols());
other.evalTo(*this);
}
/** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */
template<typename OtherDerived>
- EIGEN_STRONG_INLINE Matrix& operator=(const AnyMatrixBase<OtherDerived> &other)
- {
- resize(other.derived().rows(), other.derived().cols());
- Base::operator=(other.derived());
- return *this;
- }
-
- /** \sa MatrixBase::operator=(const AnyMatrixBase<OtherDerived>&) */
- template<typename OtherDerived>
EIGEN_STRONG_INLINE Matrix(const AnyMatrixBase<OtherDerived> &other)
- : m_storage(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
+ : Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
{
- _check_template_params();
- resize(other.rows(), other.cols());
+ Base::_check_template_params();
+ Base::resize(other.rows(), other.cols());
*this = other;
}
@@ -559,58 +299,8 @@ class Matrix
* data pointers.
*/
template<typename OtherDerived>
- void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
-
- /** \name Map
- * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects,
- * while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned
- * \a data pointers.
- *
- * \see class Map
- */
- //@{
- inline static const UnalignedMapType Map(const Scalar* data)
- { return UnalignedMapType(data); }
- inline static UnalignedMapType Map(Scalar* data)
- { return UnalignedMapType(data); }
- inline static const UnalignedMapType Map(const Scalar* data, int size)
- { return UnalignedMapType(data, size); }
- inline static UnalignedMapType Map(Scalar* data, int size)
- { return UnalignedMapType(data, size); }
- inline static const UnalignedMapType Map(const Scalar* data, int rows, int cols)
- { return UnalignedMapType(data, rows, cols); }
- inline static UnalignedMapType Map(Scalar* data, int rows, int cols)
- { return UnalignedMapType(data, rows, cols); }
-
- inline static const AlignedMapType MapAligned(const Scalar* data)
- { return AlignedMapType(data); }
- inline static AlignedMapType MapAligned(Scalar* data)
- { return AlignedMapType(data); }
- inline static const AlignedMapType MapAligned(const Scalar* data, int size)
- { return AlignedMapType(data, size); }
- inline static AlignedMapType MapAligned(Scalar* data, int size)
- { return AlignedMapType(data, size); }
- inline static const AlignedMapType MapAligned(const Scalar* data, int rows, int cols)
- { return AlignedMapType(data, rows, cols); }
- inline static AlignedMapType MapAligned(Scalar* data, int rows, int cols)
- { return AlignedMapType(data, rows, cols); }
- //@}
-
- using Base::setConstant;
- Matrix& setConstant(int size, const Scalar& value);
- Matrix& setConstant(int rows, int cols, const Scalar& value);
-
- using Base::setZero;
- Matrix& setZero(int size);
- Matrix& setZero(int rows, int cols);
-
- using Base::setOnes;
- Matrix& setOnes(int size);
- Matrix& setOnes(int rows, int cols);
-
- using Base::setRandom;
- Matrix& setRandom(int size);
- Matrix& setRandom(int rows, int cols);
+ void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
+ { this->_swap(other.derived()); }
using Base::setIdentity;
Matrix& setIdentity(int rows, int cols);
@@ -626,168 +316,8 @@ class Matrix
#ifdef EIGEN_MATRIX_PLUGIN
#include EIGEN_MATRIX_PLUGIN
#endif
-
- private:
- /** \internal Resizes *this in preparation for assigning \a other to it.
- * Takes care of doing all the checking that's needed.
- *
- * Note that copying a row-vector into a vector (and conversely) is allowed.
- * The resizing, if any, is then done in the appropriate way so that row-vectors
- * remain row-vectors and vectors remain vectors.
- */
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE void _resize_to_match(const MatrixBase<OtherDerived>& other)
- {
- #ifdef EIGEN_NO_AUTOMATIC_RESIZING
- ei_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size())
- : (rows() == other.rows() && cols() == other.cols())))
- && "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
- #endif
- resizeLike(other);
- }
-
- /** \internal Copies the value of the expression \a other into \c *this with automatic resizing.
- *
- * *this might be resized to match the dimensions of \a other. If *this was a null matrix (not already initialized),
- * it will be initialized.
- *
- * Note that copying a row-vector into a vector (and conversely) is allowed.
- * The resizing, if any, is then done in the appropriate way so that row-vectors
- * remain row-vectors and vectors remain vectors.
- *
- * \sa operator=(const MatrixBase<OtherDerived>&), _set_noalias()
- */
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE Matrix& _set(const MatrixBase<OtherDerived>& other)
- {
- _set_selector(other.derived(), typename ei_meta_if<static_cast<bool>(int(OtherDerived::Flags) & EvalBeforeAssigningBit), ei_meta_true, ei_meta_false>::ret());
- return *this;
- }
-
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_true&) { _set_noalias(other.eval()); }
-
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE void _set_selector(const OtherDerived& other, const ei_meta_false&) { _set_noalias(other); }
-
- /** \internal Like _set() but additionally makes the assumption that no aliasing effect can happen (which
- * is the case when creating a new matrix) so one can enforce lazy evaluation.
- *
- * \sa operator=(const MatrixBase<OtherDerived>&), _set()
- */
- template<typename OtherDerived>
- EIGEN_STRONG_INLINE Matrix& _set_noalias(const MatrixBase<OtherDerived>& other)
- {
- _resize_to_match(other);
- // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
- // it wouldn't allow to copy a row-vector into a column-vector.
- return ei_assign_selector<Matrix,OtherDerived,false>::run(*this, other.derived());
- }
-
- static EIGEN_STRONG_INLINE void _check_template_params()
- {
- #ifdef EIGEN_DEBUG_MATRIX_CTOR
- EIGEN_DEBUG_MATRIX_CTOR(Matrix);
- #endif
-
- EIGEN_STATIC_ASSERT(((_Rows >= _MaxRows)
- && (_Cols >= _MaxCols)
- && (_MaxRows >= 0)
- && (_MaxCols >= 0)
- && (_Rows <= Dynamic)
- && (_Cols <= Dynamic)
- && (_MaxRows == _Rows || _Rows==Dynamic)
- && (_MaxCols == _Cols || _Cols==Dynamic)
- && ((_MaxRows==Dynamic?1:_MaxRows)*(_MaxCols==Dynamic?1:_MaxCols)<Dynamic)
- && (_Options & (DontAlign|RowMajor)) == _Options),
- INVALID_MATRIX_TEMPLATE_PARAMETERS)
- }
-
-
- template<typename T0, typename T1>
- EIGEN_STRONG_INLINE void _init2(int rows, int cols, typename ei_enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
- {
- ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
- && cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
- m_storage.resize(rows*cols,rows,cols);
- EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
- }
- template<typename T0, typename T1>
- EIGEN_STRONG_INLINE void _init2(const Scalar& x, const Scalar& y, typename ei_enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)
- {
- EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Matrix, 2)
- m_storage.data()[0] = x;
- m_storage.data()[1] = y;
- }
-
- template<typename MatrixType, typename OtherDerived, bool SwapPointers>
- friend struct ei_matrix_swap_impl;
};
-template <typename Derived, typename OtherDerived, bool IsVector>
-struct ei_conservative_resize_like_impl
-{
- static void run(MatrixBase<Derived>& _this, const MatrixBase<OtherDerived>& other)
- {
- if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
-
- // Note: Here is space for improvement. Basically, for conservativeResize(int,int),
- // neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
- // dimensions is dynamic, one could use either conservativeResize(int rows, NoChange_t) or
- // conservativeResize(NoChange_t, int cols). For these methods new static asserts like
- // EIGEN_STATIC_ASSERT_DYNAMIC_ROWS and EIGEN_STATIC_ASSERT_DYNAMIC_COLS would be good.
- EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(Derived)
- EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(OtherDerived)
-
- typename MatrixBase<Derived>::PlainMatrixType tmp(other);
- const int common_rows = std::min(tmp.rows(), _this.rows());
- const int common_cols = std::min(tmp.cols(), _this.cols());
- tmp.block(0,0,common_rows,common_cols) = _this.block(0,0,common_rows,common_cols);
- _this.derived().swap(tmp);
- }
-};
-
-template <typename Derived, typename OtherDerived>
-struct ei_conservative_resize_like_impl<Derived,OtherDerived,true>
-{
- static void run(MatrixBase<Derived>& _this, const MatrixBase<OtherDerived>& other)
- {
- if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
-
- // segment(...) will check whether Derived/OtherDerived are vectors!
- typename MatrixBase<Derived>::PlainMatrixType tmp(other);
- const int common_size = std::min<int>(_this.size(),tmp.size());
- tmp.segment(0,common_size) = _this.segment(0,common_size);
- _this.derived().swap(tmp);
- }
-};
-
-template<typename MatrixType, typename OtherDerived, bool SwapPointers>
-struct ei_matrix_swap_impl
-{
- static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
- {
- matrix.base().swap(other);
- }
-};
-
-template<typename MatrixType, typename OtherDerived>
-struct ei_matrix_swap_impl<MatrixType, OtherDerived, true>
-{
- static inline void run(MatrixType& matrix, MatrixBase<OtherDerived>& other)
- {
- matrix.m_storage.swap(other.derived().m_storage);
- }
-};
-
-template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
-template<typename OtherDerived>
-inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
-{
- enum { SwapPointers = ei_is_same_type<Matrix, OtherDerived>::ret && Base::SizeAtCompileTime==Dynamic };
- ei_matrix_swap_impl<Matrix, OtherDerived, bool(SwapPointers)>::run(*this, *const_cast<MatrixBase<OtherDerived>*>(&other));
-}
-
/** \defgroup matrixtypedefs Global matrix typedefs
*
* \ingroup Core_Module
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 467172777..4c30f30ad 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -28,11 +28,11 @@
/** \class MatrixBase
*
- * \brief Base class for all matrices, vectors, and expressions
+ * \brief Base class for all dense matrices, vectors, and expressions
*
- * This class is the base that is inherited by all matrix, vector, and expression
- * types. Most of the Eigen API is contained in this class. Other important classes for
- * the Eigen API are Matrix, Cwise, and VectorwiseOp.
+ * This class is the base that is inherited by all matrix, vector, and related expression
+ * types. Most of the Eigen API is contained in this class, and its base classes. Other important
+ * classes for the Eigen API are Matrix, and VectorwiseOp.
*
* Note that some methods are defined in the \ref Array_Module array module.
*
@@ -52,98 +52,52 @@
* \endcode
*/
template<typename Derived> class MatrixBase
-#ifndef EIGEN_PARSED_BY_DOXYGEN
- : public ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
- typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>
-#endif // not EIGEN_PARSED_BY_DOXYGEN
+ : public DenseBase<Derived>
{
public:
#ifndef EIGEN_PARSED_BY_DOXYGEN
- using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
- typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*;
-
- class InnerIterator;
+ /** The base class for a given storage type. */
+ typedef MatrixBase StorageBaseType;
+ /** Construct the base class type for the derived class OtherDerived */
+ template <typename OtherDerived> struct MakeBase { typedef MatrixBase<OtherDerived> Type; };
typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
+
+ typedef DenseBase<Derived> Base;
+
+ using Base::RowsAtCompileTime;
+ using Base::ColsAtCompileTime;
+ using Base::SizeAtCompileTime;
+ using Base::MaxRowsAtCompileTime;
+ using Base::MaxColsAtCompileTime;
+ using Base::MaxSizeAtCompileTime;
+ using Base::IsVectorAtCompileTime;
+ using Base::Flags;
+ using Base::CoeffReadCost;
+ using Base::_HasDirectAccess;
+
+ using Base::derived;
+ using Base::const_cast_derived;
+ using Base::rows;
+ using Base::cols;
+ using Base::size;
+ using Base::coeff;
+ using Base::coeffRef;
+ using Base::lazyAssign;
+ using Base::eval;
+ using Base::operator=;
+ using Base::operator+=;
+ using Base::operator-=;
+ using Base::operator*=;
+ using Base::operator/=;
+
+ typedef typename Base::CoeffReturnType CoeffReturnType;
+ typedef typename Base::RowXpr RowXpr;
+ typedef typename Base::ColXpr ColXpr;
#endif // not EIGEN_PARSED_BY_DOXYGEN
- enum {
- RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime,
- /**< The number of rows at compile-time. This is just a copy of the value provided
- * by the \a Derived type. If a value is not known at compile-time,
- * it is set to the \a Dynamic constant.
- * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
-
- ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime,
- /**< The number of columns at compile-time. This is just a copy of the value provided
- * by the \a Derived type. If a value is not known at compile-time,
- * it is set to the \a Dynamic constant.
- * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
-
-
- SizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::RowsAtCompileTime,
- ei_traits<Derived>::ColsAtCompileTime>::ret),
- /**< This is equal to the number of coefficients, i.e. the number of
- * rows times the number of columns, or to \a Dynamic if this is not
- * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
-
- MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime,
- /**< This value is equal to the maximum possible number of rows that this expression
- * might have. If this expression might have an arbitrarily high number of rows,
- * this value is set to \a Dynamic.
- *
- * This value is useful to know when evaluating an expression, in order to determine
- * whether it is possible to avoid doing a dynamic memory allocation.
- *
- * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
- */
-
- MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime,
- /**< This value is equal to the maximum possible number of columns that this expression
- * might have. If this expression might have an arbitrarily high number of columns,
- * this value is set to \a Dynamic.
- *
- * This value is useful to know when evaluating an expression, in order to determine
- * whether it is possible to avoid doing a dynamic memory allocation.
- *
- * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
- */
-
- MaxSizeAtCompileTime = (ei_size_at_compile_time<ei_traits<Derived>::MaxRowsAtCompileTime,
- ei_traits<Derived>::MaxColsAtCompileTime>::ret),
- /**< This value is equal to the maximum possible number of coefficients that this expression
- * might have. If this expression might have an arbitrarily high number of coefficients,
- * this value is set to \a Dynamic.
- *
- * This value is useful to know when evaluating an expression, in order to determine
- * whether it is possible to avoid doing a dynamic memory allocation.
- *
- * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
- */
-
- IsVectorAtCompileTime = ei_traits<Derived>::RowsAtCompileTime == 1
- || ei_traits<Derived>::ColsAtCompileTime == 1,
- /**< This is set to true if either the number of rows or the number of
- * columns is known at compile-time to be equal to 1. Indeed, in that case,
- * we are dealing with a column-vector (if there is only one column) or with
- * a row-vector (if there is only one row). */
-
- Flags = ei_traits<Derived>::Flags,
- /**< This stores expression \ref flags flags which may or may not be inherited by new expressions
- * constructed from this one. See the \ref flags "list of flags".
- */
-
- CoeffReadCost = ei_traits<Derived>::CoeffReadCost,
- /**< This is a rough measure of how expensive it is to read one coefficient from
- * this expression.
- */
-
-#ifndef EIGEN_PARSED_BY_DOXYGEN
- _HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
-#endif
- };
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** This is the "real scalar" type; if the \a Scalar type is already real numbers
@@ -159,49 +113,9 @@ template<typename Derived> class MatrixBase
EIGEN_ENUM_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
- /** \returns the number of rows. \sa cols(), RowsAtCompileTime */
- inline int rows() const { return derived().rows(); }
- /** \returns the number of columns. \sa rows(), ColsAtCompileTime*/
- inline int cols() const { return derived().cols(); }
- /** \returns the number of coefficients, which is rows()*cols().
- * \sa rows(), cols(), SizeAtCompileTime. */
- inline int size() const { return rows() * cols(); }
/** \returns the size of the main diagonal, which is min(rows(),cols()).
* \sa rows(), cols(), SizeAtCompileTime. */
inline int diagonalSize() const { return std::min(rows(),cols()); }
- /** \returns the number of nonzero coefficients which is in practice the number
- * of stored coefficients. */
- inline int nonZeros() const { return size(); }
- /** \returns true if either the number of rows or the number of columns is equal to 1.
- * In other words, this function returns
- * \code rows()==1 || cols()==1 \endcode
- * \sa rows(), cols(), IsVectorAtCompileTime. */
- inline bool isVector() const { return rows()==1 || cols()==1; }
- /** \returns the size of the storage major dimension,
- * i.e., the number of columns for a columns major matrix, and the number of rows otherwise */
- int outerSize() const { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }
- /** \returns the size of the inner dimension according to the storage order,
- * i.e., the number of rows for a columns major matrix, and the number of cols otherwise */
- int innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }
-
- /** Only plain matrices, not expressions may be resized; therefore the only useful resize method is
- * Matrix::resize(). The present method only asserts that the new size equals the old size, and does
- * nothing else.
- */
- void resize(int size)
- {
- ei_assert(size == this->size()
- && "MatrixBase::resize() does not actually allow to resize.");
- }
- /** Only plain matrices, not expressions may be resized; therefore the only useful resize method is
- * Matrix::resize(). The present method only asserts that the new size equals the old size, and does
- * nothing else.
- */
- void resize(int rows, int cols)
- {
- ei_assert(rows == this->rows() && cols == this->cols()
- && "MatrixBase::resize() does not actually allow to resize.");
- }
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** \internal the plain matrix type corresponding to this expression. Note that is not necessarily
@@ -209,43 +123,17 @@ template<typename Derived> class MatrixBase
* reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either
* PlainMatrixType or const PlainMatrixType&.
*/
- typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
- /** \internal the column-major plain matrix type corresponding to this expression. Note that is not necessarily
- * exactly the return type of eval(): in the case of plain matrices, the return type of eval() is a const
- * reference to a matrix, not a matrix!
- * The only difference from PlainMatrixType is that PlainMatrixType_ColMajor is guaranteed to be column-major.
- */
- typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType_ColMajor;
-
- /** \internal the return type of coeff()
- */
- typedef typename ei_meta_if<_HasDirectAccess, const Scalar&, Scalar>::ret CoeffReturnType;
+// typedef typename ei_plain_matrix_type<Derived>::type PlainMatrixType;
+ typedef Matrix<typename ei_traits<Derived>::Scalar,
+ ei_traits<Derived>::RowsAtCompileTime,
+ ei_traits<Derived>::ColsAtCompileTime,
+ AutoAlign | (ei_traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
+ ei_traits<Derived>::MaxRowsAtCompileTime,
+ ei_traits<Derived>::MaxColsAtCompileTime
+ > PlainMatrixType;
/** \internal Represents a matrix with all coefficients equal to one another*/
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
- /** \internal Represents a scalar multiple of a matrix */
- typedef CwiseUnaryOp<ei_scalar_multiple_op<Scalar>, Derived> ScalarMultipleReturnType;
- /** \internal Represents a quotient of a matrix by a scalar*/
- typedef CwiseUnaryOp<ei_scalar_quotient1_op<Scalar>, Derived> ScalarQuotient1ReturnType;
- /** \internal the return type of MatrixBase::conjugate() */
- typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
- const CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Derived>,
- const Derived&
- >::ret ConjugateReturnType;
- /** \internal the return type of MatrixBase::real() const */
- typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
- const CwiseUnaryOp<ei_scalar_real_op<Scalar>, Derived>,
- const Derived&
- >::ret RealReturnType;
- /** \internal the return type of MatrixBase::real() */
- typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
- CwiseUnaryView<ei_scalar_real_op<Scalar>, Derived>,
- Derived&
- >::ret NonConstRealReturnType;
- /** \internal the return type of MatrixBase::imag() const */
- typedef CwiseUnaryOp<ei_scalar_imag_op<Scalar>, Derived> ImagReturnType;
- /** \internal the return type of MatrixBase::imag() */
- typedef CwiseUnaryView<ei_scalar_imag_op<Scalar>, Derived> NonConstImagReturnType;
/** \internal the return type of MatrixBase::adjoint() */
typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<Derived> >,
@@ -253,10 +141,6 @@ template<typename Derived> class MatrixBase
>::ret AdjointReturnType;
/** \internal the return type of MatrixBase::eigenvalues() */
typedef Matrix<typename NumTraits<typename ei_traits<Derived>::Scalar>::Real, ei_traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
- /** \internal expression tyepe of a column */
- typedef Block<Derived, ei_traits<Derived>::RowsAtCompileTime, 1> ColXpr;
- /** \internal expression tyepe of a column */
- typedef Block<Derived, 1, ei_traits<Derived>::ColsAtCompileTime> RowXpr;
/** \internal the return type of identity */
typedef CwiseNullaryOp<ei_scalar_identity_op<Scalar>,Derived> IdentityReturnType;
/** \internal the return type of unit vectors */
@@ -265,91 +149,26 @@ template<typename Derived> class MatrixBase
ei_traits<Derived>::ColsAtCompileTime> BasisReturnType;
#endif // not EIGEN_PARSED_BY_DOXYGEN
-
- /** Copies \a other into *this. \returns a reference to *this. */
- template<typename OtherDerived>
- Derived& operator=(const MatrixBase<OtherDerived>& other);
+#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase
+# include "../plugins/CommonCwiseUnaryOps.h"
+# include "../plugins/CommonCwiseBinaryOps.h"
+# include "../plugins/MatrixCwiseUnaryOps.h"
+# include "../plugins/MatrixCwiseBinaryOps.h"
+# ifdef EIGEN_MATRIXBASE_PLUGIN
+# include EIGEN_MATRIXBASE_PLUGIN
+# endif
+#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
/** Special case of the template operator=, in order to prevent the compiler
* from generating a default operator= (issue hit with g++ 4.1)
*/
Derived& operator=(const MatrixBase& other);
- template<typename OtherDerived>
- Derived& operator=(const AnyMatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived>
- Derived& operator+=(const AnyMatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived>
- Derived& operator-=(const AnyMatrixBase<OtherDerived> &other);
-
- template<typename OtherDerived>
- Derived& operator=(const ReturnByValue<OtherDerived>& func);
-
#ifndef EIGEN_PARSED_BY_DOXYGEN
- /** Copies \a other into *this without evaluating other. \returns a reference to *this. */
- template<typename OtherDerived>
- Derived& lazyAssign(const MatrixBase<OtherDerived>& other);
-
- /** \deprecated because .lazy() is deprecated
- * Overloaded for cache friendly product evaluation */
- template<typename OtherDerived>
- Derived& lazyAssign(const Flagged<OtherDerived, 0, EvalBeforeAssigningBit>& other)
- { return lazyAssign(other._expression()); }
-
template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other);
-
- template<typename ProductDerived, typename Lhs, typename Rhs>
- Derived& operator+=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other);
-
- template<typename ProductDerived, typename Lhs, typename Rhs>
- Derived& operator-=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other);
#endif // not EIGEN_PARSED_BY_DOXYGEN
- CommaInitializer<Derived> operator<< (const Scalar& s);
-
- template<typename OtherDerived>
- CommaInitializer<Derived> operator<< (const MatrixBase<OtherDerived>& other);
-
- const CoeffReturnType coeff(int row, int col) const;
- const CoeffReturnType operator()(int row, int col) const;
-
- Scalar& coeffRef(int row, int col);
- Scalar& operator()(int row, int col);
-
- const CoeffReturnType coeff(int index) const;
- const CoeffReturnType operator[](int index) const;
- const CoeffReturnType operator()(int index) const;
-
- Scalar& coeffRef(int index);
- Scalar& operator[](int index);
- Scalar& operator()(int index);
-
-#ifndef EIGEN_PARSED_BY_DOXYGEN
- template<typename OtherDerived>
- void copyCoeff(int row, int col, const MatrixBase<OtherDerived>& other);
- template<typename OtherDerived>
- void copyCoeff(int index, const MatrixBase<OtherDerived>& other);
- template<typename OtherDerived, int StoreMode, int LoadMode>
- void copyPacket(int row, int col, const MatrixBase<OtherDerived>& other);
- template<typename OtherDerived, int StoreMode, int LoadMode>
- void copyPacket(int index, const MatrixBase<OtherDerived>& other);
-#endif // not EIGEN_PARSED_BY_DOXYGEN
-
- template<int LoadMode>
- PacketScalar packet(int row, int col) const;
- template<int StoreMode>
- void writePacket(int row, int col, const PacketScalar& x);
-
- template<int LoadMode>
- PacketScalar packet(int index) const;
- template<int StoreMode>
- void writePacket(int index, const PacketScalar& x);
-
const CoeffReturnType x() const;
const CoeffReturnType y() const;
const CoeffReturnType z() const;
@@ -359,43 +178,11 @@ template<typename Derived> class MatrixBase
Scalar& z();
Scalar& w();
-
- const CwiseUnaryOp<ei_scalar_opposite_op<typename ei_traits<Derived>::Scalar>,Derived> operator-() const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<ei_scalar_sum_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- operator+(const MatrixBase<OtherDerived> &other) const;
-
- template<typename OtherDerived>
- const CwiseBinaryOp<ei_scalar_difference_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
- operator-(const MatrixBase<OtherDerived> &other) const;
-
template<typename OtherDerived>
Derived& operator+=(const MatrixBase<OtherDerived>& other);
template<typename OtherDerived>
Derived& operator-=(const MatrixBase<OtherDerived>& other);
- Derived& operator*=(const Scalar& other);
- Derived& operator/=(const Scalar& other);
-
- const ScalarMultipleReturnType operator*(const Scalar& scalar) const;
- #ifdef EIGEN_PARSED_BY_DOXYGEN
- const ScalarMultipleReturnType operator*(const RealScalar& scalar) const;
- #endif
- const CwiseUnaryOp<ei_scalar_quotient1_op<typename ei_traits<Derived>::Scalar>, Derived>
- operator/(const Scalar& scalar) const;
-
- const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,std::complex<Scalar> >, Derived>
- operator*(const std::complex<Scalar>& scalar) const;
-
- inline friend const ScalarMultipleReturnType
- operator*(const Scalar& scalar, const MatrixBase& matrix)
- { return matrix*scalar; }
-
- inline friend const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,std::complex<Scalar> >, Derived>
- operator*(const std::complex<Scalar>& scalar, const MatrixBase& matrix)
- { return matrix*scalar; }
-
template<typename OtherDerived>
const typename ProductReturnType<Derived,OtherDerived>::Type
operator*(const MatrixBase<OtherDerived> &other) const;
@@ -414,14 +201,6 @@ template<typename Derived> class MatrixBase
operator*(const DiagonalBase<DiagonalDerived> &diagonal) const;
template<typename OtherDerived>
- typename ei_plain_matrix_type_column_major<OtherDerived>::type
- solveTriangular(const MatrixBase<OtherDerived>& other) const;
-
- template<typename OtherDerived>
- void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
-
-
- template<typename OtherDerived>
Scalar dot(const MatrixBase<OtherDerived>& other) const;
RealScalar squaredNorm() const;
RealScalar norm() const;
@@ -431,62 +210,12 @@ template<typename Derived> class MatrixBase
const PlainMatrixType normalized() const;
void normalize();
- Eigen::Transpose<Derived> transpose();
- const Eigen::Transpose<Derived> transpose() const;
- void transposeInPlace();
const AdjointReturnType adjoint() const;
void adjointInPlace();
-#ifndef EIGEN_NO_DEBUG
- protected:
- template<typename OtherDerived>
- void checkTransposeAliasing(const OtherDerived& other) const;
- public:
-#endif
-
- RowXpr row(int i);
- const RowXpr row(int i) const;
-
- ColXpr col(int i);
- const ColXpr col(int i) const;
Minor<Derived> minor(int row, int col);
const Minor<Derived> minor(int row, int col) const;
- typename BlockReturnType<Derived>::Type block(int startRow, int startCol, int blockRows, int blockCols);
- const typename BlockReturnType<Derived>::Type
- block(int startRow, int startCol, int blockRows, int blockCols) const;
-
- VectorBlock<Derived> segment(int start, int size);
- const VectorBlock<Derived> segment(int start, int size) const;
-
- VectorBlock<Derived> head(int size);
- const VectorBlock<Derived> head(int size) const;
-
- VectorBlock<Derived> tail(int size);
- const VectorBlock<Derived> tail(int size) const;
-
- typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols);
- const typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols) const;
-
- template<int BlockRows, int BlockCols>
- typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol);
- template<int BlockRows, int BlockCols>
- const typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol) const;
-
- template<int CRows, int CCols>
- typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type);
- template<int CRows, int CCols>
- const typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type) const;
-
- template<int Size> VectorBlock<Derived,Size> head(void);
- template<int Size> const VectorBlock<Derived,Size> head() const;
-
- template<int Size> VectorBlock<Derived,Size> tail();
- template<int Size> const VectorBlock<Derived,Size> tail() const;
-
- template<int Size> VectorBlock<Derived,Size> segment(int start);
- template<int Size> const VectorBlock<Derived,Size> segment(int start) const;
-
Diagonal<Derived,0> diagonal();
const Diagonal<Derived,0> diagonal() const;
@@ -505,29 +234,6 @@ template<typename Derived> class MatrixBase
template<unsigned int UpLo> SelfAdjointView<Derived, UpLo> selfadjointView();
template<unsigned int UpLo> const SelfAdjointView<Derived, UpLo> selfadjointView() const;
- static const ConstantReturnType
- Constant(int rows, int cols, const Scalar& value);
- static const ConstantReturnType
- Constant(int size, const Scalar& value);
- static const ConstantReturnType
- Constant(const Scalar& value);
-
- template<typename CustomNullaryOp>
- static const CwiseNullaryOp<CustomNullaryOp, Derived>
- NullaryExpr(int rows, int cols, const CustomNullaryOp& func);
- template<typename CustomNullaryOp>
- static const CwiseNullaryOp<CustomNullaryOp, Derived>
- NullaryExpr(int size, const CustomNullaryOp& func);
- template<typename CustomNullaryOp>
- static const CwiseNullaryOp<CustomNullaryOp, Derived>
- NullaryExpr(const CustomNullaryOp& func);
-
- static const ConstantReturnType Zero(int rows, int cols);
- static const ConstantReturnType Zero(int size);
- static const ConstantReturnType Zero();
- static const ConstantReturnType Ones(int rows, int cols);
- static const ConstantReturnType Ones(int size);
- static const ConstantReturnType Ones();
static const IdentityReturnType Identity();
static const IdentityReturnType Identity(int rows, int cols);
static const BasisReturnType Unit(int size, int i);
@@ -539,27 +245,8 @@ template<typename Derived> class MatrixBase
const DiagonalWrapper<Derived> asDiagonal() const;
- void fill(const Scalar& value);
- Derived& setConstant(const Scalar& value);
- Derived& setZero();
- Derived& setOnes();
- Derived& setRandom();
Derived& setIdentity();
-
- template<typename OtherDerived>
- bool isApprox(const MatrixBase<OtherDerived>& other,
- RealScalar prec = dummy_precision<Scalar>()) const;
- bool isMuchSmallerThan(const RealScalar& other,
- RealScalar prec = dummy_precision<Scalar>()) const;
- template<typename OtherDerived>
- bool isMuchSmallerThan(const MatrixBase<OtherDerived>& other,
- RealScalar prec = dummy_precision<Scalar>()) const;
-
- bool isApproxToConstant(const Scalar& value, RealScalar prec = dummy_precision<Scalar>()) const;
- bool isConstant(const Scalar& value, RealScalar prec = dummy_precision<Scalar>()) const;
- bool isZero(RealScalar prec = dummy_precision<Scalar>()) const;
- bool isOnes(RealScalar prec = dummy_precision<Scalar>()) const;
bool isIdentity(RealScalar prec = dummy_precision<Scalar>()) const;
bool isDiagonal(RealScalar prec = dummy_precision<Scalar>()) const;
@@ -571,135 +258,39 @@ template<typename Derived> class MatrixBase
RealScalar prec = dummy_precision<Scalar>()) const;
bool isUnitary(RealScalar prec = dummy_precision<Scalar>()) const;
+ /** \returns true if each coefficients of \c *this and \a other are all exactly equal.
+ * \warning When using floating point scalar values you probably should rather use a
+ * fuzzy comparison such as isApprox()
+ * \sa isApprox(), operator!= */
template<typename OtherDerived>
inline bool operator==(const MatrixBase<OtherDerived>& other) const
- { return (cwise() == other).all(); }
+ { return cwiseEqual(other).all(); }
+ /** \returns true if at least one pair of coefficients of \c *this and \a other are not exactly equal to each other.
+ * \warning When using floating point scalar values you probably should rather use a
+ * fuzzy comparison such as isApprox()
+ * \sa isApprox(), operator== */
template<typename OtherDerived>
inline bool operator!=(const MatrixBase<OtherDerived>& other) const
- { return (cwise() != other).any(); }
+ { return cwiseNotEqual(other).all(); }
-
- template<typename NewType>
- typename ei_cast_return_type<
- Derived,
- const CwiseUnaryOp<ei_scalar_cast_op<typename ei_traits<Derived>::Scalar, NewType>, Derived>
- >::type
- cast() const;
-
- /** \returns the matrix or vector obtained by evaluating this expression.
- *
- * Notice that in the case of a plain matrix or vector (not an expression) this function just returns
- * a const reference, in order to avoid a useless copy.
- */
- EIGEN_STRONG_INLINE const typename ei_eval<Derived>::type eval() const
- { return typename ei_eval<Derived>::type(derived()); }
-
- template<typename OtherDerived>
- void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
-
- template<unsigned int Added>
- const Flagged<Derived, Added, 0> marked() const;
- const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const;
-
- NoAlias<Derived> noalias();
-
- /** \returns number of elements to skip to pass from one row (resp. column) to another
- * for a row-major (resp. column-major) matrix.
- * Combined with coeffRef() and the \ref flags flags, it allows a direct access to the data
- * of the underlying matrix.
- */
- inline int stride(void) const { return derived().stride(); }
+ NoAlias<Derived,Eigen::MatrixBase > noalias();
inline const NestByValue<Derived> nestByValue() const;
+ inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;
+ inline ForceAlignedAccess<Derived> forceAlignedAccess();
+ template<bool Enable> inline const typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf() const;
+ template<bool Enable> inline typename ei_meta_if<Enable,ForceAlignedAccess<Derived>,Derived&>::ret forceAlignedAccessIf();
- ConjugateReturnType conjugate() const;
- RealReturnType real() const;
- NonConstRealReturnType real();
- const ImagReturnType imag() const;
- NonConstImagReturnType imag();
-
- template<typename CustomUnaryOp>
- const CwiseUnaryOp<CustomUnaryOp, Derived> unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const;
-
- template<typename CustomViewOp>
- const CwiseUnaryView<CustomViewOp, Derived> unaryViewExpr(const CustomViewOp& func = CustomViewOp()) const;
-
- template<typename CustomBinaryOp, typename OtherDerived>
- const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
- binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
-
-
- Scalar sum() const;
Scalar mean() const;
Scalar trace() const;
- Scalar prod() const;
-
- typename ei_traits<Derived>::Scalar minCoeff() const;
- typename ei_traits<Derived>::Scalar maxCoeff() const;
-
- typename ei_traits<Derived>::Scalar minCoeff(int* row, int* col) const;
- typename ei_traits<Derived>::Scalar maxCoeff(int* row, int* col) const;
-
- typename ei_traits<Derived>::Scalar minCoeff(int* index) const;
- typename ei_traits<Derived>::Scalar maxCoeff(int* index) const;
-
- template<typename BinaryOp>
- typename ei_result_of<BinaryOp(typename ei_traits<Derived>::Scalar)>::type
- redux(const BinaryOp& func) const;
-
- template<typename Visitor>
- void visit(Visitor& func) const;
-
-#ifndef EIGEN_PARSED_BY_DOXYGEN
- using AnyMatrixBase<Derived>::derived;
- inline Derived& const_cast_derived() const
- { return *static_cast<Derived*>(const_cast<MatrixBase*>(this)); }
-#endif // not EIGEN_PARSED_BY_DOXYGEN
-
- const Cwise<Derived> cwise() const;
- Cwise<Derived> cwise();
-
- inline const WithFormat<Derived> format(const IOFormat& fmt) const;
-
/////////// Array module ///////////
- bool all(void) const;
- bool any(void) const;
- int count() const;
-
- const VectorwiseOp<Derived,Horizontal> rowwise() const;
- VectorwiseOp<Derived,Horizontal> rowwise();
- const VectorwiseOp<Derived,Vertical> colwise() const;
- VectorwiseOp<Derived,Vertical> colwise();
-
- static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int rows, int cols);
- static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int size);
- static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random();
-
- template<typename ThenDerived,typename ElseDerived>
- const Select<Derived,ThenDerived,ElseDerived>
- select(const MatrixBase<ThenDerived>& thenMatrix,
- const MatrixBase<ElseDerived>& elseMatrix) const;
-
- template<typename ThenDerived>
- inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
- select(const MatrixBase<ThenDerived>& thenMatrix, typename ThenDerived::Scalar elseScalar) const;
-
- template<typename ElseDerived>
- inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
- select(typename ElseDerived::Scalar thenScalar, const MatrixBase<ElseDerived>& elseMatrix) const;
-
template<int p> RealScalar lpNorm() const;
- template<int RowFactor, int ColFactor>
- const Replicate<Derived,RowFactor,ColFactor> replicate() const;
- const Replicate<Derived,Dynamic,Dynamic> replicate(int rowFacor,int colFactor) const;
-
- Eigen::Reverse<Derived, BothDirections> reverse();
- const Eigen::Reverse<Derived, BothDirections> reverse() const;
- void reverseInPlace();
+ ArrayWrapper<Derived> array() { return derived(); }
+ const ArrayWrapper<Derived> array() const { return derived(); }
/////////// LU module ///////////
@@ -762,15 +353,6 @@ template<typename Derived> class MatrixBase
typedef Homogeneous<Derived,MatrixBase<Derived>::ColsAtCompileTime==1?Vertical:Horizontal> HomogeneousReturnType;
const HomogeneousReturnType homogeneous() const;
-/////////// Sparse module ///////////
-
- // dense = sparse * dense
- template<typename Derived1, typename Derived2>
- Derived& lazyAssign(const SparseProduct<Derived1,Derived2,SparseTimeDenseProduct>& product);
- // dense = dense * sparse
- template<typename Derived1, typename Derived2>
- Derived& lazyAssign(const SparseProduct<Derived1,Derived2,DenseTimeSparseProduct>& product);
-
////////// Householder module ///////////
void makeHouseholderInPlace(Scalar& tau, RealScalar& beta);
@@ -793,22 +375,47 @@ template<typename Derived> class MatrixBase
template<typename OtherScalar>
void applyOnTheRight(int p, int q, const PlanarRotation<OtherScalar>& j);
- #ifdef EIGEN_MATRIXBASE_PLUGIN
- #include EIGEN_MATRIXBASE_PLUGIN
- #endif
+#ifdef EIGEN2_SUPPORT
+ template<typename ProductDerived, typename Lhs, typename Rhs>
+ Derived& operator+=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
+ EvalBeforeAssigningBit>& other);
- protected:
- /** Default constructor. Do nothing. */
- MatrixBase()
- {
- /* Just checks for self-consistency of the flags.
- * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down
- */
-#ifdef EIGEN_INTERNAL_DEBUGGING
- EIGEN_STATIC_ASSERT(ei_are_flags_consistent<Flags>::ret,
- INVALID_MATRIXBASE_TEMPLATE_PARAMETERS)
+ template<typename ProductDerived, typename Lhs, typename Rhs>
+ Derived& operator-=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
+ EvalBeforeAssigningBit>& other);
+
+ /** \deprecated because .lazy() is deprecated
+ * Overloaded for cache friendly product evaluation */
+ template<typename OtherDerived>
+ Derived& lazyAssign(const Flagged<OtherDerived, 0, EvalBeforeAssigningBit>& other)
+ { return lazyAssign(other._expression()); }
+
+ template<unsigned int Added>
+ const Flagged<Derived, Added, 0> marked() const;
+ const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const;
+
+ inline const Cwise<Derived> cwise() const;
+ inline Cwise<Derived> cwise();
+
+ VectorBlock<Derived> start(int size);
+ const VectorBlock<Derived> start(int size) const;
+ VectorBlock<Derived> end(int size);
+ const VectorBlock<Derived> end(int size) const;
+ template<int Size> VectorBlock<Derived,Size> start();
+ template<int Size> const VectorBlock<Derived,Size> start() const;
+ template<int Size> VectorBlock<Derived,Size> end();
+ template<int Size> const VectorBlock<Derived,Size> end() const;
+
+ template<typename OtherDerived>
+ typename ei_plain_matrix_type_column_major<OtherDerived>::type
+ solveTriangular(const MatrixBase<OtherDerived>& other) const;
+
+ template<typename OtherDerived>
+ void solveTriangularInPlace(const MatrixBase<OtherDerived>& other) const;
#endif
- }
+
+ protected:
+ MatrixBase() : Base() {}
private:
explicit MatrixBase(int);
diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h
index eb44f3760..629dbe609 100644
--- a/Eigen/src/Core/Minor.h
+++ b/Eigen/src/Core/Minor.h
@@ -25,7 +25,7 @@
#ifndef EIGEN_MINOR_H
#define EIGEN_MINOR_H
-/** \nonstableyet
+/** \nonstableyet
* \class Minor
*
* \brief Expression of a minor
@@ -40,8 +40,8 @@
*/
template<typename MatrixType>
struct ei_traits<Minor<MatrixType> >
+ : ei_traits<MatrixType>
{
- typedef typename MatrixType::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
enum {
@@ -94,7 +94,7 @@ template<typename MatrixType> class Minor
const int m_row, m_col;
};
-/** \nonstableyet
+/** \nonstableyet
* \return an expression of the (\a row, \a col)-minor of *this,
* i.e. an expression constructed from *this by removing the specified
* row and column.
@@ -111,7 +111,7 @@ MatrixBase<Derived>::minor(int row, int col)
return Minor<Derived>(derived(), row, col);
}
-/** \nonstableyet
+/** \nonstableyet
* This is the const version of minor(). */
template<typename Derived>
inline const Minor<Derived>
diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h
index 66d8d834d..bfea5c91d 100644
--- a/Eigen/src/Core/NoAlias.h
+++ b/Eigen/src/Core/NoAlias.h
@@ -39,7 +39,7 @@
*
* \sa MatrixBase::noalias()
*/
-template<typename ExpressionType>
+template<typename ExpressionType, template <typename> class StorageBase>
class NoAlias
{
public:
@@ -48,17 +48,17 @@ class NoAlias
/** Behaves like MatrixBase::lazyAssign(other)
* \sa MatrixBase::lazyAssign() */
template<typename OtherDerived>
- EIGEN_STRONG_INLINE ExpressionType& operator=(const MatrixBase<OtherDerived>& other)
+ EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other)
{ return m_expression.lazyAssign(other.derived()); }
/** \sa MatrixBase::operator+= */
template<typename OtherDerived>
- EIGEN_STRONG_INLINE ExpressionType& operator+=(const MatrixBase<OtherDerived>& other)
+ EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other)
{ return m_expression.lazyAssign(m_expression + other.derived()); }
/** \sa MatrixBase::operator-= */
template<typename OtherDerived>
- EIGEN_STRONG_INLINE ExpressionType& operator-=(const MatrixBase<OtherDerived>& other)
+ EIGEN_STRONG_INLINE ExpressionType& operator-=(const StorageBase<OtherDerived>& other)
{ return m_expression.lazyAssign(m_expression - other.derived()); }
#ifndef EIGEN_PARSED_BY_DOXYGEN
@@ -77,12 +77,12 @@ class NoAlias
/** \returns a pseudo expression of \c *this with an operator= assuming
* no aliasing between \c *this and the source expression.
- *
+ *
* More precisely, noalias() allows to bypass the EvalBeforeAssignBit flag.
* Currently, even though several expressions may alias, only product
* expressions have this flag. Therefore, noalias() is only usefull when
* the source expression contains a matrix product.
- *
+ *
* Here are some examples where noalias is usefull:
* \code
* D.noalias() = A * B;
@@ -104,7 +104,7 @@ class NoAlias
* \sa class NoAlias
*/
template<typename Derived>
-NoAlias<Derived> MatrixBase<Derived>::noalias()
+NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()
{
return derived();
}
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h
index 7066e5743..15f44de89 100644
--- a/Eigen/src/Core/Product.h
+++ b/Eigen/src/Core/Product.h
@@ -172,7 +172,7 @@ class GeneralProduct<Lhs, Rhs, InnerProduct>
EIGEN_STRONG_INLINE Scalar value() const
{
- return (m_lhs.transpose().cwise()*m_rhs).sum();
+ return (m_lhs.transpose().cwiseProduct(m_rhs)).sum();
}
template<typename Dest> void scaleAndAddTo(Dest& dst, Scalar alpha) const
@@ -399,7 +399,7 @@ template<> struct ei_gemv_selector<OnTheRight,RowMajor,false>
// TODO makes sure rhs is sequentially stored in memory, otherwise use a temp
const int rows = prod.rows();
for(int i=0; i<rows; ++i)
- dest.coeffRef(i) += alpha * (prod.lhs().row(i).cwise() * prod.rhs().transpose()).sum();
+ dest.coeffRef(i) += alpha * (prod.lhs().row(i).cwiseProduct(prod.rhs().transpose())).sum();
}
};
@@ -427,7 +427,7 @@ MatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const
};
// note to the lost user:
// * for a dot product use: v1.dot(v2)
- // * for a coeff-wise product use: v1.cwise()*v2
+ // * for a coeff-wise product use: v1.cwiseProduct(v2)
EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h
index 33ada4bee..1d19ef72a 100644
--- a/Eigen/src/Core/ProductBase.h
+++ b/Eigen/src/Core/ProductBase.h
@@ -29,11 +29,14 @@
*
*/
template<typename Derived, typename _Lhs, typename _Rhs>
-struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> >
+struct ei_traits<ProductBase<Derived,_Lhs,_Rhs> > //: ei_traits<typename ei_cleantype<_Lhs>::type>
{
+ typedef DenseStorageMatrix DenseStorageType;
typedef typename ei_cleantype<_Lhs>::type Lhs;
typedef typename ei_cleantype<_Rhs>::type Rhs;
typedef typename ei_scalar_product_traits<typename Lhs::Scalar, typename Rhs::Scalar>::ReturnType Scalar;
+ typedef typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType,
+ typename ei_traits<Rhs>::StorageType>::ret StorageType;
enum {
RowsAtCompileTime = ei_traits<Lhs>::RowsAtCompileTime,
ColsAtCompileTime = ei_traits<Rhs>::ColsAtCompileTime,
@@ -52,8 +55,8 @@ struct ei_nested<ProductBase<Derived,Lhs,Rhs>, N, EvalType>
};
#define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived) \
- typedef ProductBase<Derived, Lhs, Rhs > ProductBaseType; \
- _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, ProductBaseType) \
+ typedef ProductBase<Derived, Lhs, Rhs > Base; \
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
typedef typename Base::LhsNested LhsNested; \
typedef typename Base::_LhsNested _LhsNested; \
typedef typename Base::LhsBlasTraits LhsBlasTraits; \
@@ -71,7 +74,8 @@ template<typename Derived, typename Lhs, typename Rhs>
class ProductBase : public MatrixBase<Derived>
{
public:
- _EIGEN_GENERIC_PUBLIC_INTERFACE(ProductBase,MatrixBase<Derived>)
+ typedef MatrixBase<Derived> Base;
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(ProductBase)
typedef typename Lhs::Nested LhsNested;
typedef typename ei_cleantype<LhsNested>::type _LhsNested;
@@ -169,7 +173,9 @@ struct ei_traits<ScaledProduct<NestedProduct> >
: ei_traits<ProductBase<ScaledProduct<NestedProduct>,
typename NestedProduct::_LhsNested,
typename NestedProduct::_RhsNested> >
-{};
+{
+ typedef typename ei_traits<NestedProduct>::StorageType StorageType;
+};
template<typename NestedProduct>
class ScaledProduct
@@ -210,27 +216,9 @@ template<typename Derived>
template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& MatrixBase<Derived>::lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other)
{
- other.derived().evalTo(derived()); return derived();
+ other.derived().evalTo(derived());
+ return derived();
}
-/** \internal
- * Overloaded to perform an efficient C += (A*B).lazy() */
-template<typename Derived>
-template<typename ProductDerived, typename Lhs, typename Rhs>
-Derived& MatrixBase<Derived>::operator+=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other)
-{
- other._expression().derived().addTo(derived()); return derived();
-}
-
-/** \internal
- * Overloaded to perform an efficient C -= (A*B).lazy() */
-template<typename Derived>
-template<typename ProductDerived, typename Lhs, typename Rhs>
-Derived& MatrixBase<Derived>::operator-=(const Flagged<ProductBase<ProductDerived, Lhs,Rhs>, 0,
- EvalBeforeAssigningBit>& other)
-{
- other._expression().derived().subTo(derived()); return derived();
-}
#endif // EIGEN_PRODUCTBASE_H
diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h
index 399e2cd90..1643f13b2 100644
--- a/Eigen/src/Core/Redux.h
+++ b/Eigen/src/Core/Redux.h
@@ -306,12 +306,12 @@ struct ei_redux_impl<Func, Derived, LinearVectorizedTraversal, CompleteUnrolling
* The template parameter \a BinaryOp is the type of the functor \a func which must be
* an associative operator. Both current STL and TR1 functor styles are handled.
*
- * \sa MatrixBase::sum(), MatrixBase::minCoeff(), MatrixBase::maxCoeff(), MatrixBase::colwise(), MatrixBase::rowwise()
+ * \sa DenseBase::sum(), DenseBase::minCoeff(), DenseBase::maxCoeff(), MatrixBase::colwise(), MatrixBase::rowwise()
*/
template<typename Derived>
template<typename Func>
inline typename ei_result_of<Func(typename ei_traits<Derived>::Scalar)>::type
-MatrixBase<Derived>::redux(const Func& func) const
+DenseBase<Derived>::redux(const Func& func) const
{
typename Derived::Nested nested(derived());
typedef typename ei_cleantype<typename Derived::Nested>::type ThisNested;
@@ -323,7 +323,7 @@ MatrixBase<Derived>::redux(const Func& func) const
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::minCoeff() const
+DenseBase<Derived>::minCoeff() const
{
return this->redux(Eigen::ei_scalar_min_op<Scalar>());
}
@@ -332,7 +332,7 @@ MatrixBase<Derived>::minCoeff() const
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::maxCoeff() const
+DenseBase<Derived>::maxCoeff() const
{
return this->redux(Eigen::ei_scalar_max_op<Scalar>());
}
@@ -343,7 +343,7 @@ MatrixBase<Derived>::maxCoeff() const
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::sum() const
+DenseBase<Derived>::sum() const
{
return this->redux(Eigen::ei_scalar_sum_op<Scalar>());
}
@@ -354,7 +354,7 @@ MatrixBase<Derived>::sum() const
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::mean() const
+DenseBase<Derived>::mean() const
{
return this->redux(Eigen::ei_scalar_sum_op<Scalar>()) / this->size();
}
@@ -368,7 +368,7 @@ MatrixBase<Derived>::mean() const
*/
template<typename Derived>
EIGEN_STRONG_INLINE typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::prod() const
+DenseBase<Derived>::prod() const
{
return this->redux(Eigen::ei_scalar_product_op<Scalar>());
}
diff --git a/Eigen/src/Core/ReturnByValue.h b/Eigen/src/Core/ReturnByValue.h
index 1d977ace2..e35493236 100644
--- a/Eigen/src/Core/ReturnByValue.h
+++ b/Eigen/src/Core/ReturnByValue.h
@@ -72,7 +72,7 @@ template<typename Derived>
template<typename Derived>
template<typename OtherDerived>
-Derived& MatrixBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
+Derived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
{
other.evalTo(derived());
return derived();
diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h
index 9b6b3261f..9ab8cb2c1 100644
--- a/Eigen/src/Core/SelfAdjointView.h
+++ b/Eigen/src/Core/SelfAdjointView.h
@@ -200,15 +200,15 @@ struct ei_triangular_assignment_selector<Derived1, Derived2, SelfAdjoint, Dynami
***************************************************************************/
template<typename Derived>
-template<unsigned int Mode>
-const SelfAdjointView<Derived, Mode> MatrixBase<Derived>::selfadjointView() const
+template<unsigned int UpLo>
+const SelfAdjointView<Derived, UpLo> MatrixBase<Derived>::selfadjointView() const
{
return derived();
}
template<typename Derived>
-template<unsigned int Mode>
-SelfAdjointView<Derived, Mode> MatrixBase<Derived>::selfadjointView()
+template<unsigned int UpLo>
+SelfAdjointView<Derived, UpLo> MatrixBase<Derived>::selfadjointView()
{
return derived();
}
diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h
new file mode 100644
index 000000000..df35d0ee9
--- /dev/null
+++ b/Eigen/src/Core/SelfCwiseBinaryOp.h
@@ -0,0 +1,141 @@
+// This file is part of Eigen, a lightweight C++ template library
+// for linear algebra.
+//
+// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
+//
+// Eigen is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 3 of the License, or (at your option) any later version.
+//
+// Alternatively, you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License and a copy of the GNU General Public License along with
+// Eigen. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EIGEN_SELFCWISEBINARYOP_H
+#define EIGEN_SELFCWISEBINARYOP_H
+
+/** \class SelfCwiseBinaryOp
+ *
+ * \internal
+ *
+ * \brief Internal helper class for optimizing operators like +=, -=
+ *
+ * This is a pseudo expression class re-implementing the copyCoeff/copyPacket
+ * method to directly performs a +=/-= operations in an optimal way. In particular,
+ * this allows to make sure that the input/output data are loaded only once using
+ * aligned packet loads.
+ *
+ * \sa class SwapWrapper for a similar trick.
+ */
+template<typename BinaryOp, typename MatrixType>
+struct ei_traits<SelfCwiseBinaryOp<BinaryOp,MatrixType> > : ei_traits<MatrixType> {};
+
+template<typename BinaryOp, typename MatrixType> class SelfCwiseBinaryOp
+ : public MatrixType::template MakeBase< SelfCwiseBinaryOp<BinaryOp, MatrixType> >::Type
+{
+ public:
+
+ typedef typename MatrixType::template MakeBase< SelfCwiseBinaryOp<BinaryOp, MatrixType> >::Type Base;
+ _EIGEN_DENSE_PUBLIC_INTERFACE(SelfCwiseBinaryOp)
+
+ typedef typename ei_packet_traits<Scalar>::type Packet;
+
+ using Base::operator=;
+
+ inline SelfCwiseBinaryOp(MatrixType& xpr, const BinaryOp& func = BinaryOp()) : m_matrix(xpr), m_functor(func) {}
+
+ inline int rows() const { return m_matrix.rows(); }
+ inline int cols() const { return m_matrix.cols(); }
+ inline int stride() const { return m_matrix.stride(); }
+ inline const Scalar* data() const { return m_matrix.data(); }
+
+ // note that this function is needed by assign to correctly align loads/stores
+ // TODO make Assign use .data()
+ inline Scalar& coeffRef(int row, int col)
+ {
+ return m_matrix.const_cast_derived().coeffRef(row, col);
+ }
+
+ // note that this function is needed by assign to correctly align loads/stores
+ // TODO make Assign use .data()
+ inline Scalar& coeffRef(int index)
+ {
+ return m_matrix.const_cast_derived().coeffRef(index);
+ }
+
+ template<typename OtherDerived>
+ void copyCoeff(int row, int col, const DenseBase<OtherDerived>& other)
+ {
+ OtherDerived& _other = other.const_cast_derived();
+ ei_internal_assert(row >= 0 && row < rows()
+ && col >= 0 && col < cols());
+ Scalar& tmp = m_matrix.coeffRef(row,col);
+ tmp = m_functor(tmp, _other.coeff(row,col));
+ }
+
+ template<typename OtherDerived>
+ void copyCoeff(int index, const DenseBase<OtherDerived>& other)
+ {
+ OtherDerived& _other = other.const_cast_derived();
+ ei_internal_assert(index >= 0 && index < m_matrix.size());
+ Scalar& tmp = m_matrix.coeffRef(index);
+ tmp = m_functor(tmp, _other.coeff(index));
+ }
+
+ template<typename OtherDerived, int StoreMode, int LoadMode>
+ void copyPacket(int row, int col, const DenseBase<OtherDerived>& other)
+ {
+ OtherDerived& _other = other.const_cast_derived();
+ ei_internal_assert(row >= 0 && row < rows()
+ && col >= 0 && col < cols());
+ m_matrix.template writePacket<StoreMode>(row, col,
+ m_functor.packetOp(m_matrix.template packet<StoreMode>(row, col),_other.template packet<LoadMode>(row, col)) );
+ }
+
+ template<typename OtherDerived, int StoreMode, int LoadMode>
+ void copyPacket(int index, const DenseBase<OtherDerived>& other)
+ {
+ OtherDerived& _other = other.const_cast_derived();
+ ei_internal_assert(index >= 0 && index < m_matrix.size());
+ m_matrix.template writePacket<StoreMode>(index,
+ m_functor.packetOp(m_matrix.template packet<StoreMode>(index),_other.template packet<LoadMode>(index)) );
+ }
+
+ protected:
+ MatrixType& m_matrix;
+ const BinaryOp& m_functor;
+
+ private:
+ SelfCwiseBinaryOp& operator=(const SelfCwiseBinaryOp&);
+};
+
+template<typename Derived>
+inline Derived& DenseBase<Derived>::operator*=(const Scalar& other)
+{
+ SelfCwiseBinaryOp<ei_scalar_product_op<Scalar>, Derived> tmp(derived());
+ typedef typename Derived::PlainMatrixType PlainMatrixType;
+ tmp = PlainMatrixType::Constant(rows(),cols(),other);
+ return derived();
+}
+
+template<typename Derived>
+inline Derived& DenseBase<Derived>::operator/=(const Scalar& other)
+{
+ SelfCwiseBinaryOp<typename ei_meta_if<NumTraits<Scalar>::HasFloatingPoint,ei_scalar_product_op<Scalar>,ei_scalar_quotient_op<Scalar> >::ret, Derived> tmp(derived());
+ typedef typename Derived::PlainMatrixType PlainMatrixType;
+ tmp = PlainMatrixType::Constant(rows(),cols(), NumTraits<Scalar>::HasFloatingPoint ? Scalar(1)/other : other);
+ return derived();
+}
+
+#endif // EIGEN_SELFCWISEBINARYOP_H
diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h
index 9c4a49c3c..9dc019d17 100644
--- a/Eigen/src/Core/SolveTriangular.h
+++ b/Eigen/src/Core/SolveTriangular.h
@@ -92,8 +92,7 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,RowMajor
int i = IsLowerTriangular ? pi+k : pi-k-1;
int s = IsLowerTriangular ? pi : i+1;
if (k>0)
- other.coeffRef(i) -= ((lhs.row(i).segment(s,k).transpose())
- .cwise()*(other.segment(s,k))).sum();
+ other.coeffRef(i) -= (lhs.row(i).segment(s,k).transpose().cwiseProduct(other.segment(s,k))).sum();
if(!(Mode & UnitDiagBit))
other.coeffRef(i) /= lhs.coeff(i,i);
@@ -206,8 +205,7 @@ struct ei_triangular_solver_unroller<Lhs,Rhs,Mode,Index,Size,false> {
static void run(const Lhs& lhs, Rhs& rhs)
{
if (Index>0)
- rhs.coeffRef(I) -= ((lhs.row(I).template segment<Index>(S).transpose())
- .cwise()*(rhs.template segment<Index>(S))).sum();
+ rhs.coeffRef(I) -= ((lhs.row(I).template segment<Index>(S).transpose()).cwiseProduct(rhs.template segment<Index>(S))).sum();
if(!(Mode & UnitDiagBit))
rhs.coeffRef(I) /= lhs.coeff(I,I);
@@ -231,7 +229,7 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,CompleteUnrolling,St
* TriangularView methods
***************************************************************************/
-/** "in-place" version of MatrixBase::solveTriangular() where the result is written in \a other
+/** "in-place" version of TriangularView::solve() where the result is written in \a other
*
* \nonstableyet
*
diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h
index 3ebd7282b..b4d6aa353 100644
--- a/Eigen/src/Core/StableNorm.h
+++ b/Eigen/src/Core/StableNorm.h
@@ -28,7 +28,7 @@
template<typename ExpressionType, typename Scalar>
inline void ei_stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& scale, Scalar& invScale)
{
- Scalar max = bl.cwise().abs().maxCoeff();
+ Scalar max = bl.cwiseAbs().maxCoeff();
if (max>scale)
{
ssq = ssq * ei_abs2(scale/max);
@@ -59,7 +59,7 @@ MatrixBase<Derived>::stableNorm() const
RealScalar invScale = 1;
RealScalar ssq = 0; // sum of square
enum {
- Alignment = (int(Flags)&DirectAccessBit) || (int(Flags)&AlignedBit) ? EnforceAlignedAccess : AsRequested
+ Alignment = (int(Flags)&DirectAccessBit) || (int(Flags)&AlignedBit) ? 1 : 0
};
int n = size();
int bi=0;
@@ -67,10 +67,10 @@ MatrixBase<Derived>::stableNorm() const
{
bi = ei_first_aligned(&const_cast_derived().coeffRef(0), n);
if (bi>0)
- ei_stable_norm_kernel(head(bi), ssq, scale, invScale);
+ ei_stable_norm_kernel(this->head(bi), ssq, scale, invScale);
}
for (; bi<n; bi+=blockSize)
- ei_stable_norm_kernel(VectorBlock<Derived,Dynamic,Alignment>(derived(),bi,std::min(blockSize, n - bi)), ssq, scale, invScale);
+ ei_stable_norm_kernel(this->segment(bi,std::min(blockSize, n - bi)).template forceAlignedAccessIf<Alignment>(), ssq, scale, invScale);
return scale * ei_sqrt(ssq);
}
@@ -182,7 +182,7 @@ template<typename Derived>
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real
MatrixBase<Derived>::hypotNorm() const
{
- return this->cwise().abs().redux(ei_scalar_hypot_op<RealScalar>());
+ return this->cwiseAbs().redux(ei_scalar_hypot_op<RealScalar>());
}
#endif // EIGEN_STABLENORM_H
diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h
index a7cf219f7..60b6fffc9 100644
--- a/Eigen/src/Core/Swap.h
+++ b/Eigen/src/Core/Swap.h
@@ -32,25 +32,15 @@
* \brief Internal helper class for swapping two expressions
*/
template<typename ExpressionType>
-struct ei_traits<SwapWrapper<ExpressionType> >
-{
- typedef typename ExpressionType::Scalar Scalar;
- enum {
- RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
- ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
- MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
- MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime,
- Flags = ExpressionType::Flags,
- CoeffReadCost = ExpressionType::CoeffReadCost
- };
-};
+struct ei_traits<SwapWrapper<ExpressionType> > : ei_traits<ExpressionType> {};
template<typename ExpressionType> class SwapWrapper
- : public MatrixBase<SwapWrapper<ExpressionType> >
+ : public ExpressionType::template MakeBase<SwapWrapper<ExpressionType> >::Type
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(SwapWrapper)
+ typedef typename ExpressionType::template MakeBase<SwapWrapper<ExpressionType> >::Type Base;
+ _EIGEN_DENSE_PUBLIC_INTERFACE(SwapWrapper)
typedef typename ei_packet_traits<Scalar>::type Packet;
inline SwapWrapper(ExpressionType& xpr) : m_expression(xpr) {}
@@ -128,7 +118,7 @@ template<typename ExpressionType> class SwapWrapper
*/
template<typename Derived>
template<typename OtherDerived>
-void MatrixBase<Derived>::swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
+void DenseBase<Derived>::swap(DenseBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other)
{
(SwapWrapper<Derived>(derived())).lazyAssign(other);
}
diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h
index 1e037e618..80b056527 100644
--- a/Eigen/src/Core/Transpose.h
+++ b/Eigen/src/Core/Transpose.h
@@ -38,11 +38,12 @@
* \sa MatrixBase::transpose(), MatrixBase::adjoint()
*/
template<typename MatrixType>
-struct ei_traits<Transpose<MatrixType> >
+struct ei_traits<Transpose<MatrixType> > : ei_traits<MatrixType>
{
typedef typename MatrixType::Scalar Scalar;
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
+ typedef typename ei_traits<MatrixType>::StorageType StorageType;
enum {
RowsAtCompileTime = MatrixType::ColsAtCompileTime,
ColsAtCompileTime = MatrixType::RowsAtCompileTime,
@@ -56,12 +57,15 @@ struct ei_traits<Transpose<MatrixType> >
};
};
+template<typename MatrixType, typename StorageType> class TransposeImpl;
+
template<typename MatrixType> class Transpose
- : public MatrixBase<Transpose<MatrixType> >
+ : public TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageType>
{
public:
- EIGEN_GENERIC_PUBLIC_INTERFACE(Transpose)
+ typedef typename TransposeImpl<MatrixType,typename ei_traits<MatrixType>::StorageType>::Base Base;
+ EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Transpose)
inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {}
@@ -69,60 +73,85 @@ template<typename MatrixType> class Transpose
inline int rows() const { return m_matrix.cols(); }
inline int cols() const { return m_matrix.rows(); }
- inline int stride() const { return m_matrix.stride(); }
- inline Scalar* data() { return m_matrix.data(); }
- inline const Scalar* data() const { return m_matrix.data(); }
+
+ /** \internal used for introspection */
+ const typename ei_cleantype<typename MatrixType::Nested>::type&
+ _expression() const { return m_matrix; }
+
+ const typename ei_cleantype<typename MatrixType::Nested>::type&
+ nestedExpression() const { return m_matrix; }
+
+ typename ei_cleantype<typename MatrixType::Nested>::type&
+ nestedExpression() { return m_matrix.const_cast_derived(); }
+
+ protected:
+ const typename MatrixType::Nested m_matrix;
+};
+
+
+template<typename MatrixType> class TransposeImpl<MatrixType,Dense>
+ : public MatrixType::template MakeBase<Transpose<MatrixType> >::Type
+{
+ const typename ei_cleantype<typename MatrixType::Nested>::type& nestedExpression() const
+ { return derived().nestedExpression(); }
+ typename ei_cleantype<typename MatrixType::Nested>::type& nestedExpression()
+ { return derived().nestedExpression(); }
+
+ public:
+
+ //EIGEN_DENSE_PUBLpename IC_INTERFACE(TransposeImpl,MatrixBase<Transpose<MatrixType> >)
+ typedef typename MatrixType::template MakeBase<Transpose<MatrixType> >::Type Base;
+ _EIGEN_DENSE_PUBLIC_INTERFACE(Transpose<MatrixType>)
+
+// EIGEN_EXPRESSION_IMPL_COMMON(MatrixBase<Transpose<MatrixType> >)
+
+ inline int stride() const { return nestedExpression().stride(); }
+ inline Scalar* data() { return nestedExpression().data(); }
+ inline const Scalar* data() const { return nestedExpression().data(); }
inline Scalar& coeffRef(int row, int col)
{
- return m_matrix.const_cast_derived().coeffRef(col, row);
+ return nestedExpression().const_cast_derived().coeffRef(col, row);
}
inline Scalar& coeffRef(int index)
{
- return m_matrix.const_cast_derived().coeffRef(index);
+ return nestedExpression().const_cast_derived().coeffRef(index);
}
inline const CoeffReturnType coeff(int row, int col) const
{
- return m_matrix.coeff(col, row);
+ return nestedExpression().coeff(col, row);
}
inline const CoeffReturnType coeff(int index) const
{
- return m_matrix.coeff(index);
+ return nestedExpression().coeff(index);
}
template<int LoadMode>
inline const PacketScalar packet(int row, int col) const
{
- return m_matrix.template packet<LoadMode>(col, row);
+ return nestedExpression().template packet<LoadMode>(col, row);
}
template<int LoadMode>
inline void writePacket(int row, int col, const PacketScalar& x)
{
- m_matrix.const_cast_derived().template writePacket<LoadMode>(col, row, x);
+ nestedExpression().const_cast_derived().template writePacket<LoadMode>(col, row, x);
}
template<int LoadMode>
inline const PacketScalar packet(int index) const
{
- return m_matrix.template packet<LoadMode>(index);
+ return nestedExpression().template packet<LoadMode>(index);
}
template<int LoadMode>
inline void writePacket(int index, const PacketScalar& x)
{
- m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
+ nestedExpression().const_cast_derived().template writePacket<LoadMode>(index, x);
}
-
- /** \internal used for introspection */
- const typename ei_cleantype<typename MatrixType::Nested>::type&
- _expression() const { return m_matrix; }
-
- protected:
- const typename MatrixType::Nested m_matrix;
};
/** \returns an expression of the transpose of *this.
@@ -146,7 +175,7 @@ template<typename MatrixType> class Transpose
* \sa transposeInPlace(), adjoint() */
template<typename Derived>
inline Transpose<Derived>
-MatrixBase<Derived>::transpose()
+DenseBase<Derived>::transpose()
{
return derived();
}
@@ -158,7 +187,7 @@ MatrixBase<Derived>::transpose()
* \sa transposeInPlace(), adjoint() */
template<typename Derived>
inline const Transpose<Derived>
-MatrixBase<Derived>::transpose() const
+DenseBase<Derived>::transpose() const
{
return derived();
}
@@ -186,7 +215,7 @@ template<typename Derived>
inline const typename MatrixBase<Derived>::AdjointReturnType
MatrixBase<Derived>::adjoint() const
{
- return transpose();
+ return this->transpose();
}
/***************************************************************************
@@ -233,7 +262,7 @@ struct ei_inplace_transpose_selector<MatrixType,false> { // non square matrix
*
* \sa transpose(), adjoint(), adjointInPlace() */
template<typename Derived>
-inline void MatrixBase<Derived>::transposeInPlace()
+inline void DenseBase<Derived>::transposeInPlace()
{
ei_inplace_transpose_selector<Derived>::run(derived());
}
@@ -270,6 +299,15 @@ inline void MatrixBase<Derived>::adjointInPlace()
// The following is to detect aliasing problems in most common cases.
+template<typename BinOp,typename NestedXpr>
+struct ei_blas_traits<SelfCwiseBinaryOp<BinOp,NestedXpr> >
+ : ei_blas_traits<NestedXpr>
+{
+ typedef SelfCwiseBinaryOp<BinOp,NestedXpr> XprType;
+ static inline const XprType extract(const XprType& x) { return x; }
+};
+
+
template<typename T, int Access=ei_blas_traits<T>::ActualAccess>
struct ei_extract_data_selector {
static typename T::Scalar* run(const T& m)
@@ -309,7 +347,7 @@ struct ei_check_transpose_aliasing_selector<Scalar,DestIsTranposed,CwiseBinaryOp
template<typename Derived>
template<typename OtherDerived>
-void MatrixBase<Derived>::checkTransposeAliasing(const OtherDerived& other) const
+void DenseBase<Derived>::checkTransposeAliasing(const OtherDerived& other) const
{
ei_assert((!ei_check_transpose_aliasing_selector<Scalar,ei_blas_traits<Derived>::IsTransposed,OtherDerived>::run(ei_extract_data(derived()), other))
&& "aliasing detected during tranposition, use transposeInPlace() or evaluate the rhs into a temporary using .eval()");
diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h
index 172355aa6..62d800fef 100644
--- a/Eigen/src/Core/TriangularMatrix.h
+++ b/Eigen/src/Core/TriangularMatrix.h
@@ -467,7 +467,7 @@ TriangularView<MatrixType, Mode>::operator=(const MatrixBase<OtherDerived>& othe
{
if(OtherDerived::Flags & EvalBeforeAssigningBit)
{
- typename OtherDerived::PlainMatrixType other_evaluated(other.rows(), other.cols());
+ typename ei_plain_matrix_type<OtherDerived>::type other_evaluated(other.rows(), other.cols());
other_evaluated.template triangularView<Mode>().lazyAssign(other.derived());
lazyAssign(other_evaluated);
}
@@ -538,7 +538,7 @@ void TriangularBase<Derived>::evalTo(MatrixBase<DenseDerived> &other) const
{
if(ei_traits<Derived>::Flags & EvalBeforeAssigningBit)
{
- typename Derived::PlainMatrixType other_evaluated(rows(), cols());
+ typename ei_plain_matrix_type<Derived>::type other_evaluated(rows(), cols());
evalToLazy(other_evaluated);
other.derived().swap(other_evaluated);
}
diff --git a/Eigen/src/Core/VectorBlock.h b/Eigen/src/Core/VectorBlock.h
index 15b3a2aa5..760c097ad 100644
--- a/Eigen/src/Core/VectorBlock.h
+++ b/Eigen/src/Core/VectorBlock.h
@@ -32,13 +32,9 @@
*
* \param VectorType the type of the object in which we are taking a sub-vector
* \param Size size of the sub-vector we are taking at compile time (optional)
- * \param _PacketAccess allows to enforce aligned loads and stores if set to ForceAligned.
- * The default is AsRequested. This parameter is internaly used by Eigen
- * in expressions such as \code mat.segment() += other; \endcode and most of
- * the time this is the only way it is used.
*
* This class represents an expression of either a fixed-size or dynamic-size sub-vector.
- * It is the return type of MatrixBase::segment(int,int) and MatrixBase::segment<int>(int) and
+ * It is the return type of DenseBase::segment(int,int) and DenseBase::segment<int>(int) and
* most of the time this is the only way it is used.
*
* However, if you want to directly maniputate sub-vector expressions,
@@ -57,32 +53,29 @@
* \include class_FixedVectorBlock.cpp
* Output: \verbinclude class_FixedVectorBlock.out
*
- * \sa class Block, MatrixBase::segment(int,int,int,int), MatrixBase::segment(int,int)
+ * \sa class Block, DenseBase::segment(int,int,int,int), DenseBase::segment(int,int)
*/
-template<typename VectorType, int Size, int _PacketAccess>
-struct ei_traits<VectorBlock<VectorType, Size, _PacketAccess> >
+template<typename VectorType, int Size>
+struct ei_traits<VectorBlock<VectorType, Size> >
: public ei_traits<Block<VectorType,
ei_traits<VectorType>::RowsAtCompileTime==1 ? 1 : Size,
- ei_traits<VectorType>::ColsAtCompileTime==1 ? 1 : Size,
- _PacketAccess> >
+ ei_traits<VectorType>::ColsAtCompileTime==1 ? 1 : Size> >
{
};
-template<typename VectorType, int Size, int PacketAccess> class VectorBlock
+template<typename VectorType, int Size> class VectorBlock
: public Block<VectorType,
ei_traits<VectorType>::RowsAtCompileTime==1 ? 1 : Size,
- ei_traits<VectorType>::ColsAtCompileTime==1 ? 1 : Size,
- PacketAccess>
+ ei_traits<VectorType>::ColsAtCompileTime==1 ? 1 : Size>
{
typedef Block<VectorType,
ei_traits<VectorType>::RowsAtCompileTime==1 ? 1 : Size,
- ei_traits<VectorType>::ColsAtCompileTime==1 ? 1 : Size,
- PacketAccess> _Base;
+ ei_traits<VectorType>::ColsAtCompileTime==1 ? 1 : Size> Base;
enum {
IsColVector = ei_traits<VectorType>::ColsAtCompileTime==1
};
public:
- _EIGEN_GENERIC_PUBLIC_INTERFACE(VectorBlock, _Base)
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(VectorBlock)
using Base::operator=;
using Base::operator+=;
@@ -128,7 +121,7 @@ template<typename VectorType, int Size, int PacketAccess> class VectorBlock
* \sa class Block, segment(int)
*/
template<typename Derived>
-inline VectorBlock<Derived> MatrixBase<Derived>
+inline VectorBlock<Derived> DenseBase<Derived>
::segment(int start, int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
@@ -138,7 +131,7 @@ inline VectorBlock<Derived> MatrixBase<Derived>
/** This is the const version of segment(int,int).*/
template<typename Derived>
inline const VectorBlock<Derived>
-MatrixBase<Derived>::segment(int start, int size) const
+DenseBase<Derived>::segment(int start, int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), start, size);
@@ -161,7 +154,7 @@ MatrixBase<Derived>::segment(int start, int size) const
*/
template<typename Derived>
inline VectorBlock<Derived>
-MatrixBase<Derived>::head(int size)
+DenseBase<Derived>::head(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), 0, size);
@@ -170,7 +163,7 @@ MatrixBase<Derived>::head(int size)
/** This is the const version of head(int).*/
template<typename Derived>
inline const VectorBlock<Derived>
-MatrixBase<Derived>::head(int size) const
+DenseBase<Derived>::head(int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), 0, size);
@@ -193,7 +186,7 @@ MatrixBase<Derived>::head(int size) const
*/
template<typename Derived>
inline VectorBlock<Derived>
-MatrixBase<Derived>::tail(int size)
+DenseBase<Derived>::tail(int size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), this->size() - size, size);
@@ -202,7 +195,7 @@ MatrixBase<Derived>::tail(int size)
/** This is the const version of tail(int).*/
template<typename Derived>
inline const VectorBlock<Derived>
-MatrixBase<Derived>::tail(int size) const
+DenseBase<Derived>::tail(int size) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived>(derived(), this->size() - size, size);
@@ -224,7 +217,7 @@ MatrixBase<Derived>::tail(int size) const
template<typename Derived>
template<int Size>
inline VectorBlock<Derived,Size>
-MatrixBase<Derived>::segment(int start)
+DenseBase<Derived>::segment(int start)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived,Size>(derived(), start);
@@ -234,7 +227,7 @@ MatrixBase<Derived>::segment(int start)
template<typename Derived>
template<int Size>
inline const VectorBlock<Derived,Size>
-MatrixBase<Derived>::segment(int start) const
+DenseBase<Derived>::segment(int start) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived,Size>(derived(), start);
@@ -254,7 +247,7 @@ MatrixBase<Derived>::segment(int start) const
template<typename Derived>
template<int Size>
inline VectorBlock<Derived,Size>
-MatrixBase<Derived>::head()
+DenseBase<Derived>::head()
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived,Size>(derived(), 0);
@@ -264,7 +257,7 @@ MatrixBase<Derived>::head()
template<typename Derived>
template<int Size>
inline const VectorBlock<Derived,Size>
-MatrixBase<Derived>::head() const
+DenseBase<Derived>::head() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived,Size>(derived(), 0);
@@ -284,7 +277,7 @@ MatrixBase<Derived>::head() const
template<typename Derived>
template<int Size>
inline VectorBlock<Derived,Size>
-MatrixBase<Derived>::tail()
+DenseBase<Derived>::tail()
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived, Size>(derived(), size() - Size);
@@ -294,7 +287,7 @@ MatrixBase<Derived>::tail()
template<typename Derived>
template<int Size>
inline const VectorBlock<Derived,Size>
-MatrixBase<Derived>::tail() const
+DenseBase<Derived>::tail() const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
return VectorBlock<Derived, Size>(derived(), size() - Size);
diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h
index 590efc766..e6f02b79b 100644
--- a/Eigen/src/Core/Visitor.h
+++ b/Eigen/src/Core/Visitor.h
@@ -79,11 +79,11 @@ struct ei_visitor_impl<Visitor, Derived, Dynamic>
* \note compared to one or two \em for \em loops, visitors offer automatic
* unrolling for small fixed size matrix.
*
- * \sa minCoeff(int*,int*), maxCoeff(int*,int*), MatrixBase::redux()
+ * \sa minCoeff(int*,int*), maxCoeff(int*,int*), DenseBase::redux()
*/
template<typename Derived>
template<typename Visitor>
-void MatrixBase<Derived>::visit(Visitor& visitor) const
+void DenseBase<Derived>::visit(Visitor& visitor) const
{
const bool unroll = SizeAtCompileTime * CoeffReadCost
+ (SizeAtCompileTime-1) * ei_functor_traits<Visitor>::Cost
@@ -112,7 +112,7 @@ struct ei_coeff_visitor
/** \internal
* \brief Visitor computing the min coefficient with its value and coordinates
*
- * \sa MatrixBase::minCoeff(int*, int*)
+ * \sa DenseBase::minCoeff(int*, int*)
*/
template <typename Scalar>
struct ei_min_coeff_visitor : ei_coeff_visitor<Scalar>
@@ -138,7 +138,7 @@ struct ei_functor_traits<ei_min_coeff_visitor<Scalar> > {
/** \internal
* \brief Visitor computing the max coefficient with its value and coordinates
*
- * \sa MatrixBase::maxCoeff(int*, int*)
+ * \sa DenseBase::maxCoeff(int*, int*)
*/
template <typename Scalar>
struct ei_max_coeff_visitor : ei_coeff_visitor<Scalar>
@@ -164,11 +164,11 @@ struct ei_functor_traits<ei_max_coeff_visitor<Scalar> > {
/** \returns the minimum of all coefficients of *this
* and puts in *row and *col its location.
*
- * \sa MatrixBase::minCoeff(int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
+ * \sa DenseBase::minCoeff(int*), DenseBase::maxCoeff(int*,int*), DenseBase::visitor(), DenseBase::minCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::minCoeff(int* row, int* col) const
+DenseBase<Derived>::minCoeff(int* row, int* col) const
{
ei_min_coeff_visitor<Scalar> minVisitor;
this->visit(minVisitor);
@@ -180,11 +180,11 @@ MatrixBase<Derived>::minCoeff(int* row, int* col) const
/** \returns the minimum of all coefficients of *this
* and puts in *index its location.
*
- * \sa MatrixBase::minCoeff(int*,int*), MatrixBase::maxCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::minCoeff()
+ * \sa DenseBase::minCoeff(int*,int*), DenseBase::maxCoeff(int*,int*), DenseBase::visitor(), DenseBase::minCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::minCoeff(int* index) const
+DenseBase<Derived>::minCoeff(int* index) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
ei_min_coeff_visitor<Scalar> minVisitor;
@@ -196,11 +196,11 @@ MatrixBase<Derived>::minCoeff(int* index) const
/** \returns the maximum of all coefficients of *this
* and puts in *row and *col its location.
*
- * \sa MatrixBase::minCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::maxCoeff()
+ * \sa DenseBase::minCoeff(int*,int*), DenseBase::visitor(), DenseBase::maxCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::maxCoeff(int* row, int* col) const
+DenseBase<Derived>::maxCoeff(int* row, int* col) const
{
ei_max_coeff_visitor<Scalar> maxVisitor;
this->visit(maxVisitor);
@@ -212,11 +212,11 @@ MatrixBase<Derived>::maxCoeff(int* row, int* col) const
/** \returns the maximum of all coefficients of *this
* and puts in *index its location.
*
- * \sa MatrixBase::maxCoeff(int*,int*), MatrixBase::minCoeff(int*,int*), MatrixBase::visitor(), MatrixBase::maxCoeff()
+ * \sa DenseBase::maxCoeff(int*,int*), DenseBase::minCoeff(int*,int*), DenseBase::visitor(), DenseBase::maxCoeff()
*/
template<typename Derived>
typename ei_traits<Derived>::Scalar
-MatrixBase<Derived>::maxCoeff(int* index) const
+DenseBase<Derived>::maxCoeff(int* index) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
ei_max_coeff_visitor<Scalar> maxVisitor;
diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h
index dbdddb38d..a633c7b7c 100644
--- a/Eigen/src/Core/arch/SSE/PacketMath.h
+++ b/Eigen/src/Core/arch/SSE/PacketMath.h
@@ -176,14 +176,14 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_pandnot<Packet4f>(const Packet4f& a,
template<> EIGEN_STRONG_INLINE Packet2d ei_pandnot<Packet2d>(const Packet2d& a, const Packet2d& b) { return _mm_andnot_pd(a,b); }
template<> EIGEN_STRONG_INLINE Packet4i ei_pandnot<Packet4i>(const Packet4i& a, const Packet4i& b) { return _mm_andnot_si128(a,b); }
-template<> EIGEN_STRONG_INLINE Packet4f ei_pload<float>(const float* from) { return _mm_load_ps(from); }
-template<> EIGEN_STRONG_INLINE Packet2d ei_pload<double>(const double* from) { return _mm_load_pd(from); }
-template<> EIGEN_STRONG_INLINE Packet4i ei_pload<int>(const int* from) { return _mm_load_si128(reinterpret_cast<const Packet4i*>(from)); }
+template<> EIGEN_STRONG_INLINE Packet4f ei_pload<float>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_ps(from); }
+template<> EIGEN_STRONG_INLINE Packet2d ei_pload<double>(const double* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_pd(from); }
+template<> EIGEN_STRONG_INLINE Packet4i ei_pload<int>(const int* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm_load_si128(reinterpret_cast<const Packet4i*>(from)); }
#if (!defined __GNUC__) && (!defined __ICC)
-template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu(const float* from) { return _mm_loadu_ps(from); }
-template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu<double>(const double* from) { return _mm_loadu_pd(from); }
-template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<int>(const int* from) { return _mm_loadu_si128(reinterpret_cast<const Packet4i*>(from)); }
+template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu(const float* from) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_ps(from); }
+template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu<double>(const double* from) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_pd(from); }
+template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<int>(const int* from) { return EIGEN_DEBUG_UNALIGNED_LOAD _mm_loadu_si128(reinterpret_cast<const Packet4i*>(from)); }
#else
// Fast unaligned loads. Note that here we cannot directly use intrinsics: this would
// require pointer casting to incompatible pointer types and leads to invalid code
@@ -192,6 +192,7 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu<int>(const int* from) { return
// TODO: do the same for MSVC (ICC is compatible)
template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu(const float* from)
{
+ EIGEN_DEBUG_UNALIGNED_LOAD
__m128 res;
asm volatile ("movsd %[from0], %[r]" : [r] "=x" (res) : [from0] "m" (*from), [dummy] "m" (*(from+1)) );
asm volatile ("movhps %[from2], %[r]" : [r] "+x" (res) : [from2] "m" (*(from+2)), [dummy] "m" (*(from+3)) );
@@ -199,6 +200,7 @@ template<> EIGEN_STRONG_INLINE Packet4f ei_ploadu(const float* from)
}
template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu(const double* from)
{
+ EIGEN_DEBUG_UNALIGNED_LOAD
__m128d res;
asm volatile ("movsd %[from0], %[r]" : [r] "=x" (res) : [from0] "m" (*from) );
asm volatile ("movhpd %[from1], %[r]" : [r] "+x" (res) : [from1] "m" (*(from+1)) );
@@ -206,6 +208,7 @@ template<> EIGEN_STRONG_INLINE Packet2d ei_ploadu(const double* from)
}
template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu(const int* from)
{
+ EIGEN_DEBUG_UNALIGNED_LOAD
__m128i res;
asm volatile ("movsd %[from0], %[r]" : [r] "=x" (res) : [from0] "m" (*from), [dummy] "m" (*(from+1)) );
asm volatile ("movhps %[from2], %[r]" : [r] "+x" (res) : [from2] "m" (*(from+2)), [dummy] "m" (*(from+3)) );
@@ -213,16 +216,17 @@ template<> EIGEN_STRONG_INLINE Packet4i ei_ploadu(const int* from)
}
#endif
-template<> EIGEN_STRONG_INLINE void ei_pstore<float>(float* to, const Packet4f& from) { _mm_store_ps(to, from); }
-template<> EIGEN_STRONG_INLINE void ei_pstore<double>(double* to, const Packet2d& from) { _mm_store_pd(to, from); }
-template<> EIGEN_STRONG_INLINE void ei_pstore<int>(int* to, const Packet4i& from) { _mm_store_si128(reinterpret_cast<Packet4i*>(to), from); }
+template<> EIGEN_STRONG_INLINE void ei_pstore<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_ps(to, from); }
+template<> EIGEN_STRONG_INLINE void ei_pstore<double>(double* to, const Packet2d& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_pd(to, from); }
+template<> EIGEN_STRONG_INLINE void ei_pstore<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_ALIGNED_STORE _mm_store_si128(reinterpret_cast<Packet4i*>(to), from); }
template<> EIGEN_STRONG_INLINE void ei_pstoreu<double>(double* to, const Packet2d& from) {
+ EIGEN_DEBUG_UNALIGNED_STORE
_mm_storel_pd((to), from);
_mm_storeh_pd((to+1), from);
}
-template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const Packet4f& from) { ei_pstoreu((double*)to, _mm_castps_pd(from)); }
-template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const Packet4i& from) { ei_pstoreu((double*)to, _mm_castsi128_pd(from)); }
+template<> EIGEN_STRONG_INLINE void ei_pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu((double*)to, _mm_castps_pd(from)); }
+template<> EIGEN_STRONG_INLINE void ei_pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE ei_pstoreu((double*)to, _mm_castsi128_pd(from)); }
#if defined(_MSC_VER) && (_MSC_VER <= 1500) && defined(_WIN64)
// The temporary variable fixes an internal compilation error.
diff --git a/Eigen/src/Core/products/GeneralUnrolled.h b/Eigen/src/Core/products/GeneralUnrolled.h
index e8fb760ae..f04c27a95 100644
--- a/Eigen/src/Core/products/GeneralUnrolled.h
+++ b/Eigen/src/Core/products/GeneralUnrolled.h
@@ -32,7 +32,7 @@
/* Since the all the dimensions of the product are small, here we can rely
* on the generic Assign mechanism to evaluate the product per coeff (or packet).
- *
+ *
* Note that here the inner-loops should always be unrolled.
*/
@@ -45,10 +45,13 @@ struct ei_product_packet_impl;
template<typename LhsNested, typename RhsNested>
struct ei_traits<GeneralProduct<LhsNested,RhsNested,UnrolledProduct> >
{
+ typedef DenseStorageMatrix DenseStorageType;
typedef typename ei_cleantype<LhsNested>::type _LhsNested;
typedef typename ei_cleantype<RhsNested>::type _RhsNested;
typedef typename ei_scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar;
-
+ typedef typename ei_promote_storage_type<typename ei_traits<_LhsNested>::StorageType,
+ typename ei_traits<_RhsNested>::StorageType>::ret StorageType;
+
enum {
LhsCoeffReadCost = _LhsNested::CoeffReadCost,
RhsCoeffReadCost = _RhsNested::CoeffReadCost,
diff --git a/Eigen/src/Core/products/TriangularMatrixVector.h b/Eigen/src/Core/products/TriangularMatrixVector.h
index 291177445..fc3188cd8 100644
--- a/Eigen/src/Core/products/TriangularMatrixVector.h
+++ b/Eigen/src/Core/products/TriangularMatrixVector.h
@@ -95,7 +95,7 @@ struct ei_product_triangular_vector_selector<Lhs,Rhs,Result,Mode,ConjLhs,ConjRhs
int s = IsLowerTriangular ? pi : (HasUnitDiag ? i+1 : i);
int r = IsLowerTriangular ? k+1 : actualPanelWidth-k;
if ((!HasUnitDiag) || (--r)>0)
- res.coeffRef(i) += alpha * (cjLhs.row(i).segment(s,r).cwise() * cjRhs.segment(s,r).transpose()).sum();
+ res.coeffRef(i) += alpha * (cjLhs.row(i).segment(s,r).cwiseProduct(cjRhs.segment(s,r).transpose())).sum();
if (HasUnitDiag)
res.coeffRef(i) += alpha * cjRhs.coeff(i);
}
diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h
index 1128876f8..8483772df 100644
--- a/Eigen/src/Core/util/Constants.h
+++ b/Eigen/src/Core/util/Constants.h
@@ -174,16 +174,10 @@ const unsigned int UpperTriangularBit = 0x400;
* means the strictly upper triangular part is 0 */
const unsigned int LowerTriangularBit = 0x800;
-/** \ingroup flags
- *
- * means the expression includes sparse matrices and the sparse path has to be taken. */
-const unsigned int SparseBit = 0x1000;
-
// list of flags that are inherited by default
const unsigned int HereditaryBits = RowMajorBit
| EvalBeforeNestingBit
- | EvalBeforeAssigningBit
- | SparseBit;
+ | EvalBeforeAssigningBit;
// Possible values for the Mode parameter of part()
const unsigned int UpperTriangular = UpperTriangularBit;
@@ -195,11 +189,10 @@ const unsigned int UnitUpperTriangular = UpperTriangularBit | UnitDiagBit;
const unsigned int UnitLowerTriangular = LowerTriangularBit | UnitDiagBit;
enum { Unaligned=0, Aligned=1 };
-enum { AsRequested=0, EnforceAlignedAccess=2 };
enum { ConditionalJumpCost = 5 };
enum CornerType { TopLeft, TopRight, BottomLeft, BottomRight };
enum DirectionType { Vertical, Horizontal, BothDirections };
-enum ProductEvaluationMode { NormalProduct, CacheFriendlyProduct, SparseTimeSparseProduct, SparseTimeDenseProduct, DenseTimeSparseProduct };
+enum ProductEvaluationMode { NormalProduct, CacheFriendlyProduct };
enum {
/** \internal Default traversal, no vectorization, no index-based access */
@@ -264,7 +257,7 @@ namespace {
enum {
IsDense = 0,
- IsSparse = SparseBit,
+ IsSparse,
NoDirectAccess = 0,
HasDirectAccess = DirectAccessBit
};
@@ -292,4 +285,7 @@ namespace Architecture
};
}
+enum DenseStorageMatrix {};
+enum DenseStorageArray {};
+
#endif // EIGEN_CONSTANTS_H
diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h
index 62e4bb31b..09c6c9528 100644
--- a/Eigen/src/Core/util/ForwardDeclarations.h
+++ b/Eigen/src/Core/util/ForwardDeclarations.h
@@ -35,20 +35,21 @@ template<typename _Scalar, int _Rows, int _Cols,
int _MaxRows = _Rows, int _MaxCols = _Cols> class Matrix;
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged;
-template<typename ExpressionType> class NoAlias;
+template<typename ExpressionType, template <typename> class StorageBase > class NoAlias;
template<typename ExpressionType> class NestByValue;
+template<typename ExpressionType> class ForceAlignedAccess;
template<typename ExpressionType> class SwapWrapper;
template<typename MatrixType> class Minor;
-template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic, int PacketAccess=AsRequested,
- int _DirectAccessStatus = ei_traits<MatrixType>::Flags&DirectAccessBit ? DirectAccessBit
- : ei_traits<MatrixType>::Flags&SparseBit> class Block;
-template<typename MatrixType, int Size=Dynamic, int PacketAccess=AsRequested> class VectorBlock;
+template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic,
+ int _DirectAccessStatus = (ei_traits<MatrixType>::Flags&DirectAccessBit) ? HasDirectAccess : NoDirectAccess> class Block;
+template<typename MatrixType, int Size=Dynamic> class VectorBlock;
template<typename MatrixType> class Transpose;
template<typename MatrixType> class Conjugate;
template<typename NullaryOp, typename MatrixType> class CwiseNullaryOp;
template<typename UnaryOp, typename MatrixType> class CwiseUnaryOp;
template<typename ViewOp, typename MatrixType> class CwiseUnaryView;
template<typename BinaryOp, typename Lhs, typename Rhs> class CwiseBinaryOp;
+template<typename BinOp, typename MatrixType> class SelfCwiseBinaryOp;
template<typename Derived, typename Lhs, typename Rhs> class ProductBase;
template<typename Derived> class DiagonalBase;
@@ -57,14 +58,14 @@ template<typename _Scalar, int SizeAtCompileTime, int MaxSizeAtCompileTime=SizeA
template<typename MatrixType, typename DiagonalType, int ProductOrder> class DiagonalProduct;
template<typename MatrixType, int Index> class Diagonal;
-template<typename MatrixType, int PacketAccess = AsRequested> class Map;
+template<typename MatrixType, int Options=Unaligned> class Map;
template<typename Derived> class TriangularBase;
template<typename MatrixType, unsigned int Mode> class TriangularView;
template<typename MatrixType, unsigned int Mode> class SelfAdjointView;
-template<typename ExpressionType> class Cwise;
template<typename ExpressionType> class WithFormat;
template<typename MatrixType> struct CommaInitializer;
template<typename Derived> class ReturnByValue;
+template<typename ExpressionType> class ArrayWrapper;
template<typename DecompositionType, typename Rhs> struct ei_solve_retval_base;
template<typename DecompositionType, typename Rhs> struct ei_solve_retval;
@@ -114,6 +115,9 @@ template<typename Scalar1,typename Scalar2> struct ei_scalar_multiple2_op;
struct IOFormat;
// Array module
+template<typename _Scalar, int _Rows, int _Cols,
+ int _Options = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION | AutoAlign,
+ int _MaxRows = _Rows, int _MaxCols = _Cols> class Array;
template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMatrixType> class Select;
template<typename MatrixType, typename BinaryOp, int Direction> class PartialReduxExpr;
template<typename ExpressionType, int Direction> class VectorwiseOp;
@@ -147,8 +151,8 @@ template<typename Scalar,int Dim> class Translation;
template<typename Scalar> class UniformScaling;
template<typename MatrixType,int Direction> class Homogeneous;
-// Sparse module:
-template<typename Lhs, typename Rhs, int ProductMode> class SparseProduct;
-
+#ifdef EIGEN2_SUPPORT
+template<typename ExpressionType> class Cwise;
+#endif
#endif // EIGEN_FORWARDDECLARATIONS_H
diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h
index a51b46f02..4ea5013f7 100644
--- a/Eigen/src/Core/util/Macros.h
+++ b/Eigen/src/Core/util/Macros.h
@@ -263,43 +263,79 @@ using Eigen::ei_cos;
#if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
-using Base::operator =;
+ using Base::operator =;
#else
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
-using Base::operator =; \
-EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
-{ \
- Base::operator=(other); \
- return *this; \
-}
+ using Base::operator =; \
+ EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
+ { \
+ Base::operator=(other); \
+ return *this; \
+ }
#endif
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
-using Base::operator +=; \
-using Base::operator -=; \
-using Base::operator *=; \
-using Base::operator /=; \
-EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
-
-#define _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
-typedef BaseClass Base; \
-typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
-typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
-typedef typename Base::PacketScalar PacketScalar; \
-typedef typename Base::CoeffReturnType CoeffReturnType; \
-typedef typename Eigen::ei_nested<Derived>::type Nested; \
-enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
- ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
- MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
- MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \
- Flags = Eigen::ei_traits<Derived>::Flags, \
- CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
- SizeAtCompileTime = Base::SizeAtCompileTime, \
- MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
- IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
+ using Base::operator +=; \
+ using Base::operator -=; \
+ using Base::operator *=; \
+ using Base::operator /=; \
+ EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
+
+#define _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
+ typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
+ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
+ typedef typename Base::PacketScalar PacketScalar; \
+ typedef typename Base::CoeffReturnType CoeffReturnType; \
+ typedef typename Eigen::ei_nested<Derived>::type Nested; \
+ enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
+ ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
+ MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
+ MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \
+ Flags = Eigen::ei_traits<Derived>::Flags, \
+ CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
+ SizeAtCompileTime = Base::SizeAtCompileTime, \
+ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
+ IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
-_EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>)
+ typedef Eigen::MatrixBase<Derived> Base; \
+ _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
+
+#define EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Derived) \
+ typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
+ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
+ typedef typename Base::CoeffReturnType CoeffReturnType; \
+ typedef typename Eigen::ei_nested<Derived>::type Nested; \
+ enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
+ ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
+ Flags = Eigen::ei_traits<Derived>::Flags, \
+ CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
+ SizeAtCompileTime = Base::SizeAtCompileTime, \
+ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
+ IsVectorAtCompileTime = Base::IsVectorAtCompileTime };
+
+
+#define _EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
+ typedef typename Eigen::ei_traits<Derived>::Scalar Scalar; \
+ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
+ typedef typename Base::PacketScalar PacketScalar; \
+ typedef typename Base::CoeffReturnType CoeffReturnType; \
+ typedef typename Eigen::ei_nested<Derived>::type Nested; \
+ enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
+ ColsAtCompileTime = Eigen::ei_traits<Derived>::ColsAtCompileTime, \
+ MaxRowsAtCompileTime = Eigen::ei_traits<Derived>::MaxRowsAtCompileTime, \
+ MaxColsAtCompileTime = Eigen::ei_traits<Derived>::MaxColsAtCompileTime, \
+ Flags = Eigen::ei_traits<Derived>::Flags, \
+ CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
+ SizeAtCompileTime = Base::SizeAtCompileTime, \
+ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
+ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
+ using Base::derived;
+
+#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
+ typedef Eigen::MatrixBase<Derived> Base; \
+ _EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
+
#define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
#define EIGEN_SIZE_MIN(a,b) (((int)a == 1 || (int)b == 1) ? 1 \
@@ -308,4 +344,26 @@ _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>)
#define EIGEN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
#define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
+
+#define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,FUNCTOR) \
+ template<typename OtherDerived> \
+ inline const CwiseBinaryOp<FUNCTOR<Scalar>, Derived, OtherDerived> \
+ METHOD(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
+ { \
+ return CwiseBinaryOp<FUNCTOR<Scalar>, Derived, OtherDerived>(derived(), other.derived()); \
+ }
+
+// the expression type of a cwise product
+#define EIGEN_CWISE_PRODUCT_RETURN_TYPE(LHS,RHS) \
+ CwiseBinaryOp< \
+ ei_scalar_product_op< \
+ typename ei_scalar_product_traits< \
+ typename ei_traits<LHS>::Scalar, \
+ typename ei_traits<RHS>::Scalar \
+ >::ReturnType \
+ >, \
+ LHS, \
+ RHS \
+ >
+
#endif // EIGEN_MACROS_H
diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h
index e00ff3606..4bff09252 100644
--- a/Eigen/src/Core/util/XprHelper.h
+++ b/Eigen/src/Core/util/XprHelper.h
@@ -105,13 +105,18 @@ template<int _Rows, int _Cols> struct ei_size_at_compile_time
enum { ret = (_Rows==Dynamic || _Cols==Dynamic) ? Dynamic : _Rows * _Cols };
};
-/* ei_eval : the return type of eval(). For matrices, this is just a const reference
- * in order to avoid a useless copy
+/* ei_plain_matrix_type : the difference from ei_eval is that ei_plain_matrix_type is always a plain matrix type,
+ * whereas ei_eval is a const reference in the case of a matrix
*/
-template<typename T, int Sparseness = ei_traits<T>::Flags&SparseBit> struct ei_eval;
+template<typename T, typename StorageType = typename ei_traits<T>::StorageType> class ei_plain_matrix_type;
+template<typename T, typename BaseClassType> struct ei_plain_matrix_type_dense;
+template<typename T> struct ei_plain_matrix_type<T,Dense>
+{
+ typedef typename ei_plain_matrix_type_dense<T,typename ei_traits<T>::DenseStorageType>::type type;
+};
-template<typename T> struct ei_eval<T,IsDense>
+template<typename T> struct ei_plain_matrix_type_dense<T,DenseStorageMatrix>
{
typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
@@ -122,19 +127,9 @@ template<typename T> struct ei_eval<T,IsDense>
> type;
};
-// for matrices, no need to evaluate, just use a const reference to avoid a useless copy
-template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
-struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, IsDense>
-{
- typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type;
-};
-
-/* ei_plain_matrix_type : the difference from ei_eval is that ei_plain_matrix_type is always a plain matrix type,
- * whereas ei_eval is a const reference in the case of a matrix
- */
-template<typename T> struct ei_plain_matrix_type
+template<typename T> struct ei_plain_matrix_type_dense<T,DenseStorageArray>
{
- typedef Matrix<typename ei_traits<T>::Scalar,
+ typedef Array<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime,
ei_traits<T>::ColsAtCompileTime,
AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),
@@ -143,6 +138,40 @@ template<typename T> struct ei_plain_matrix_type
> type;
};
+/* ei_eval : the return type of eval(). For matrices, this is just a const reference
+ * in order to avoid a useless copy
+ */
+
+template<typename T, typename StorageType = typename ei_traits<T>::StorageType> class ei_eval;
+
+template<typename T> struct ei_eval<T,Dense>
+{
+ typedef typename ei_plain_matrix_type<T>::type type;
+// typedef typename T::PlainMatrixType type;
+// typedef T::Matrix<typename ei_traits<T>::Scalar,
+// ei_traits<T>::RowsAtCompileTime,
+// ei_traits<T>::ColsAtCompileTime,
+// AutoAlign | (ei_traits<T>::Flags&RowMajorBit ? RowMajor : ColMajor),
+// ei_traits<T>::MaxRowsAtCompileTime,
+// ei_traits<T>::MaxColsAtCompileTime
+// > type;
+};
+
+// for matrices, no need to evaluate, just use a const reference to avoid a useless copy
+template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
+struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, Dense>
+{
+ typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type;
+};
+
+template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
+struct ei_eval<Array<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, Dense>
+{
+ typedef const Array<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type;
+};
+
+
+
/* ei_plain_matrix_type_column_major : same as ei_plain_matrix_type but guaranteed to be column-major
*/
template<typename T> struct ei_plain_matrix_type_column_major
@@ -261,7 +290,7 @@ struct ei_special_scalar_op_base<Derived,Scalar,OtherScalar,true> : public AnyM
inline friend const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,OtherScalar>, Derived>
operator*(const OtherScalar& scalar, const Derived& matrix)
- { return matrix*scalar; }
+ { return static_cast<const ei_special_scalar_op_base&>(matrix).operator*(scalar); }
};
/** \internal Gives the type of a sub-matrix or sub-vector of a matrix of type \a ExpressionType and size \a Size
@@ -293,4 +322,11 @@ template<typename XprType, typename CastType> struct ei_cast_return_type
const XprType&,CastType>::ret type;
};
+template <typename A, typename B> struct ei_promote_storage_type;
+
+template <typename A> struct ei_promote_storage_type<A,A>
+{
+ typedef A ret;
+};
+
#endif // EIGEN_XPRHELPER_H