aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-05-28 09:09:18 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-05-28 09:09:18 +0000
commit73084dc754a64a5ae5753ef119399ea7e45c0626 (patch)
tree3b333df315c0b81cb8a49350278318974a97942c /Eigen/src/Core
parentf54760c889efcfabfdb8be594abee0647ed0c8da (diff)
* added _*coeffRef members in NestedByValue
* added ConjugateReturnType and AdjointReturnType that are type-defined to Derived& and Transpose<Derived> if the scalar type is not complex: this avoids abusive copies in the cache friendly Product
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r--Eigen/src/Core/CwiseUnaryOp.h4
-rw-r--r--Eigen/src/Core/MatrixBase.h17
-rw-r--r--Eigen/src/Core/NestByValue.h11
-rw-r--r--Eigen/src/Core/Product.h2
-rw-r--r--Eigen/src/Core/Transpose.h4
5 files changed, 27 insertions, 11 deletions
diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h
index 8d2737e12..e2ae35b3d 100644
--- a/Eigen/src/Core/CwiseUnaryOp.h
+++ b/Eigen/src/Core/CwiseUnaryOp.h
@@ -143,10 +143,10 @@ MatrixBase<Derived>::cwiseAbs2() const
*
* \sa adjoint() */
template<typename Derived>
-inline const CwiseUnaryOp<ei_scalar_conjugate_op<typename ei_traits<Derived>::Scalar>, Derived>
+inline const typename MatrixBase<Derived>::ConjugateReturnType
MatrixBase<Derived>::conjugate() const
{
- return derived();
+ return ConjugateReturnType(derived());
}
/** \returns an expression of *this with the \a Scalar type casted to
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 8d1b03eb6..27d60d078 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -304,10 +304,17 @@ template<typename Derived> class MatrixBase
Transpose<Derived> transpose();
const Transpose<Derived> transpose() const;
- const Transpose<
- NestByValue<CwiseUnaryOp<ei_scalar_conjugate_op<typename ei_traits<Derived>::Scalar>, Derived> >
- >
- adjoint() const;
+
+ /** the return type of MatrixBase::conjugate() */
+ typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
+ CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Derived>,
+ Derived&
+ >::ret ConjugateReturnType;
+ /** the return type of MatrixBase::adjoint() */
+ typedef Transpose<
+ NestByValue<typename ei_unref<ConjugateReturnType>::type>
+ > AdjointReturnType;
+ const AdjointReturnType adjoint() const;
//@}
/// \name Sub-matrices
@@ -465,7 +472,7 @@ template<typename Derived> class MatrixBase
/// \name Coefficient-wise operations
//@{
- const CwiseUnaryOp<ei_scalar_conjugate_op<typename ei_traits<Derived>::Scalar>, Derived> conjugate() const;
+ const ConjugateReturnType conjugate() const;
template<typename OtherDerived>
const CwiseBinaryOp<ei_scalar_product_op<typename ei_traits<Derived>::Scalar>, Derived, OtherDerived>
diff --git a/Eigen/src/Core/NestByValue.h b/Eigen/src/Core/NestByValue.h
index dc2ea950e..51f38e8d8 100644
--- a/Eigen/src/Core/NestByValue.h
+++ b/Eigen/src/Core/NestByValue.h
@@ -71,12 +71,23 @@ template<typename ExpressionType> class NestByValue
return m_expression.coeff(row, col);
}
+ inline Scalar& _coeffRef(int row, int col)
+ {
+ return m_expression.const_cast_derived().coeffRef(row, col);
+ }
+
template<int LoadMode>
inline const PacketScalar _packetCoeff(int row, int col) const
{
return m_expression.template packetCoeff<LoadMode>(row, col);
}
+ template<int LoadMode>
+ inline void _writePacketCoeff(int row, int col, const PacketScalar& x)
+ {
+ m_expression.const_cast_derived().template writePacketCoeff<LoadMode>(row, col, x);
+ }
+
protected:
const ExpressionType m_expression;
};
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h
index c65e6ec47..cd7d9ca93 100644
--- a/Eigen/src/Core/Product.h
+++ b/Eigen/src/Core/Product.h
@@ -228,7 +228,7 @@ struct ei_traits<Product<Lhs, Rhs, EvalMode> >
_LostBits = HereditaryBits & ~(
(_RowMajor ? 0 : RowMajorBit)
| ((RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic) ? 0 : LargeBit)),
- Flags = ((unsigned int)(LhsFlags | RhsFlags) & _LostBits)
+ Flags = ((unsigned int)(LhsFlags | RhsFlags) & _LostBits & ~NestedByValue)
| EvalBeforeAssigningBit
| EvalBeforeNestingBit
| (_Vectorizable ? VectorizableBit : 0),
diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h
index 8c59d2425..5c9cd54ac 100644
--- a/Eigen/src/Core/Transpose.h
+++ b/Eigen/src/Core/Transpose.h
@@ -125,9 +125,7 @@ MatrixBase<Derived>::transpose() const
*
* \sa transpose(), conjugate(), class Transpose, class ei_scalar_conjugate_op */
template<typename Derived>
-inline const Transpose<
- NestByValue<CwiseUnaryOp<ei_scalar_conjugate_op<typename ei_traits<Derived>::Scalar>, Derived > >
- >
+inline const typename MatrixBase<Derived>::AdjointReturnType
MatrixBase<Derived>::adjoint() const
{
return conjugate().nestByValue();