more ET refactoring:

* extend Cwise for multiple storage base class
* a lot of cleaning in the Sparse module
This commit is contained in:
Gael Guennebaud 2009-11-17 16:04:19 +01:00
parent 63bcc1c0fb
commit 1e62e0b0d8
27 changed files with 180 additions and 552 deletions

View File

@ -121,6 +121,9 @@ namespace Eigen {
* \endcode * \endcode
*/ */
/** The type used to identify a dense storage. */
struct Dense {};
#include "src/Core/util/Macros.h" #include "src/Core/util/Macros.h"
#include "src/Core/util/Constants.h" #include "src/Core/util/Constants.h"
#include "src/Core/util/ForwardDeclarations.h" #include "src/Core/util/ForwardDeclarations.h"
@ -201,7 +204,6 @@ namespace Eigen {
#include "src/Core/products/TriangularMatrixMatrix.h" #include "src/Core/products/TriangularMatrixMatrix.h"
#include "src/Core/products/TriangularSolverMatrix.h" #include "src/Core/products/TriangularSolverMatrix.h"
#include "src/Core/BandMatrix.h" #include "src/Core/BandMatrix.h"
#include "src/Core/ExpressionMaker.h"
} // namespace Eigen } // namespace Eigen

View File

@ -82,6 +82,9 @@ namespace Eigen {
* \endcode * \endcode
*/ */
/** The type used to identify a general sparse storage. */
struct Sparse {};
#include "src/Sparse/SparseUtil.h" #include "src/Sparse/SparseUtil.h"
#include "src/Sparse/SparseMatrixBase.h" #include "src/Sparse/SparseMatrixBase.h"
#include "src/Sparse/SparseNestByValue.h" #include "src/Sparse/SparseNestByValue.h"
@ -102,7 +105,6 @@ namespace Eigen {
#include "src/Sparse/SparseAssign.h" #include "src/Sparse/SparseAssign.h"
#include "src/Sparse/SparseRedux.h" #include "src/Sparse/SparseRedux.h"
#include "src/Sparse/SparseFuzzy.h" #include "src/Sparse/SparseFuzzy.h"
#include "src/Sparse/SparseFlagged.h"
#include "src/Sparse/SparseProduct.h" #include "src/Sparse/SparseProduct.h"
#include "src/Sparse/SparseDiagonalProduct.h" #include "src/Sparse/SparseDiagonalProduct.h"
#include "src/Sparse/SparseTriangular.h" #include "src/Sparse/SparseTriangular.h"

View File

@ -28,7 +28,7 @@
// -- unary operators -- // -- unary operators --
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise square root of *this. * \returns an expression of the coefficient-wise square root of *this.
* *
* Example: \include Cwise_sqrt.cpp * Example: \include Cwise_sqrt.cpp
@ -36,15 +36,15 @@
* *
* \sa pow(), square() * \sa pow(), square()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op)
Cwise<ExpressionType>::sqrt() const Cwise<ExpressionType,StorageBase>::sqrt() const
{ {
return _expression(); return _expression();
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise cosine of *this. * \returns an expression of the coefficient-wise cosine of *this.
* *
* Example: \include Cwise_cos.cpp * Example: \include Cwise_cos.cpp
@ -52,16 +52,16 @@ Cwise<ExpressionType>::sqrt() const
* *
* \sa sin(), exp(), EIGEN_FAST_MATH * \sa sin(), exp(), EIGEN_FAST_MATH
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op)
Cwise<ExpressionType>::cos() const Cwise<ExpressionType,StorageBase>::cos() const
{ {
return _expression(); return _expression();
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise sine of *this. * \returns an expression of the coefficient-wise sine of *this.
* *
* Example: \include Cwise_sin.cpp * Example: \include Cwise_sin.cpp
@ -69,16 +69,16 @@ Cwise<ExpressionType>::cos() const
* *
* \sa cos(), exp(), EIGEN_FAST_MATH * \sa cos(), exp(), EIGEN_FAST_MATH
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op)
Cwise<ExpressionType>::sin() const Cwise<ExpressionType,StorageBase>::sin() const
{ {
return _expression(); return _expression();
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise power of *this to the given exponent. * \returns an expression of the coefficient-wise power of *this to the given exponent.
* *
* Example: \include Cwise_pow.cpp * Example: \include Cwise_pow.cpp
@ -86,16 +86,16 @@ Cwise<ExpressionType>::sin() const
* *
* \sa exp(), log() * \sa exp(), log()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)
Cwise<ExpressionType>::pow(const Scalar& exponent) const Cwise<ExpressionType,StorageBase>::pow(const Scalar& exponent) const
{ {
return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op<Scalar>(exponent)); return EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op)(_expression(), ei_scalar_pow_op<Scalar>(exponent));
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise inverse of *this. * \returns an expression of the coefficient-wise inverse of *this.
* *
* Example: \include Cwise_inverse.cpp * Example: \include Cwise_inverse.cpp
@ -103,9 +103,9 @@ Cwise<ExpressionType>::pow(const Scalar& exponent) const
* *
* \sa operator/(), operator*() * \sa operator/(), operator*()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op)
Cwise<ExpressionType>::inverse() const Cwise<ExpressionType,StorageBase>::inverse() const
{ {
return _expression(); return _expression();
} }
@ -119,9 +119,9 @@ Cwise<ExpressionType>::inverse() const
* *
* \sa operator/(), operator*(), abs2() * \sa operator/(), operator*(), abs2()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op)
Cwise<ExpressionType>::square() const Cwise<ExpressionType,StorageBase>::square() const
{ {
return _expression(); return _expression();
} }
@ -135,9 +135,9 @@ Cwise<ExpressionType>::square() const
* *
* \sa square(), pow() * \sa square(), pow()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op)
Cwise<ExpressionType>::cube() const Cwise<ExpressionType,StorageBase>::cube() const
{ {
return _expression(); return _expression();
} }
@ -146,7 +146,7 @@ Cwise<ExpressionType>::cube() const
// -- binary operators -- // -- binary operators --
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \< operator of *this and \a other * \returns an expression of the coefficient-wise \< operator of *this and \a other
* *
* Example: \include Cwise_less.cpp * Example: \include Cwise_less.cpp
@ -154,16 +154,16 @@ Cwise<ExpressionType>::cube() const
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=() * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator<(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)(_expression(), other.derived());
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \<= operator of *this and \a other * \returns an expression of the coefficient-wise \<= operator of *this and \a other
* *
* Example: \include Cwise_less_equal.cpp * Example: \include Cwise_less_equal.cpp
@ -171,16 +171,16 @@ Cwise<ExpressionType>::operator<(const MatrixBase<OtherDerived> &other) const
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<() * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator<=(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)(_expression(), other.derived());
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \> operator of *this and \a other * \returns an expression of the coefficient-wise \> operator of *this and \a other
* *
* Example: \include Cwise_greater.cpp * Example: \include Cwise_greater.cpp
@ -188,16 +188,16 @@ Cwise<ExpressionType>::operator<=(const MatrixBase<OtherDerived> &other) const
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<() * \sa MatrixBase::all(), MatrixBase::any(), operator>=(), operator<()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator>(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)(_expression(), other.derived());
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \>= operator of *this and \a other * \returns an expression of the coefficient-wise \>= operator of *this and \a other
* *
* Example: \include Cwise_greater_equal.cpp * Example: \include Cwise_greater_equal.cpp
@ -205,16 +205,16 @@ Cwise<ExpressionType>::operator>(const MatrixBase<OtherDerived> &other) const
* *
* \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=() * \sa MatrixBase::all(), MatrixBase::any(), operator>(), operator<=()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator>=(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)(_expression(), other.derived());
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise == operator of *this and \a other * \returns an expression of the coefficient-wise == operator of *this and \a other
* *
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types. * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
@ -227,16 +227,16 @@ Cwise<ExpressionType>::operator>=(const MatrixBase<OtherDerived> &other) const
* *
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator==(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)(_expression(), other.derived());
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise != operator of *this and \a other * \returns an expression of the coefficient-wise != operator of *this and \a other
* *
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types. * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
@ -249,10 +249,10 @@ Cwise<ExpressionType>::operator==(const MatrixBase<OtherDerived> &other) const
* *
* \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan() * \sa MatrixBase::all(), MatrixBase::any(), MatrixBase::isApprox(), MatrixBase::isMuchSmallerThan()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) inline const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator!=(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)(_expression(), other.derived());
} }
@ -260,63 +260,63 @@ Cwise<ExpressionType>::operator!=(const MatrixBase<OtherDerived> &other) const
// comparisons to scalar value // comparisons to scalar value
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \< operator of *this and a scalar \a s * \returns an expression of the coefficient-wise \< operator of *this and a scalar \a s
* *
* \sa operator<(const MatrixBase<OtherDerived> &) const * \sa operator<(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)
Cwise<ExpressionType>::operator<(Scalar s) const Cwise<ExpressionType,StorageBase>::operator<(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \<= operator of *this and a scalar \a s * \returns an expression of the coefficient-wise \<= operator of *this and a scalar \a s
* *
* \sa operator<=(const MatrixBase<OtherDerived> &) const * \sa operator<=(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)
Cwise<ExpressionType>::operator<=(Scalar s) const Cwise<ExpressionType,StorageBase>::operator<=(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less_equal)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \> operator of *this and a scalar \a s * \returns an expression of the coefficient-wise \> operator of *this and a scalar \a s
* *
* \sa operator>(const MatrixBase<OtherDerived> &) const * \sa operator>(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)
Cwise<ExpressionType>::operator>(Scalar s) const Cwise<ExpressionType,StorageBase>::operator>(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise \>= operator of *this and a scalar \a s * \returns an expression of the coefficient-wise \>= operator of *this and a scalar \a s
* *
* \sa operator>=(const MatrixBase<OtherDerived> &) const * \sa operator>=(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)
Cwise<ExpressionType>::operator>=(Scalar s) const Cwise<ExpressionType,StorageBase>::operator>=(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::greater_equal)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise == operator of *this and a scalar \a s * \returns an expression of the coefficient-wise == operator of *this and a scalar \a s
* *
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types. * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
@ -326,16 +326,16 @@ Cwise<ExpressionType>::operator>=(Scalar s) const
* *
* \sa operator==(const MatrixBase<OtherDerived> &) const * \sa operator==(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)
Cwise<ExpressionType>::operator==(Scalar s) const Cwise<ExpressionType,StorageBase>::operator==(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::equal_to)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
} }
/** \array_module /** \array_module
* *
* \returns an expression of the coefficient-wise != operator of *this and a scalar \a s * \returns an expression of the coefficient-wise != operator of *this and a scalar \a s
* *
* \warning this performs an exact comparison, which is generally a bad idea with floating-point types. * \warning this performs an exact comparison, which is generally a bad idea with floating-point types.
@ -345,9 +345,9 @@ Cwise<ExpressionType>::operator==(Scalar s) const
* *
* \sa operator!=(const MatrixBase<OtherDerived> &) const * \sa operator!=(const MatrixBase<OtherDerived> &) const
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to) inline const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)
Cwise<ExpressionType>::operator!=(Scalar s) const Cwise<ExpressionType,StorageBase>::operator!=(Scalar s) const
{ {
return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(), return EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::not_equal_to)(_expression(),
typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s)); typename ExpressionType::ConstantReturnType(_expression().rows(), _expression().cols(), s));
@ -364,11 +364,11 @@ Cwise<ExpressionType>::operator!=(Scalar s) const
* *
* \sa operator+=(), operator-() * \sa operator+=(), operator-()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const typename Cwise<ExpressionType>::ScalarAddReturnType inline const typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType
Cwise<ExpressionType>::operator+(const Scalar& scalar) const Cwise<ExpressionType,StorageBase>::operator+(const Scalar& scalar) const
{ {
return typename Cwise<ExpressionType>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar)); return typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType(m_matrix, ei_scalar_add_op<Scalar>(scalar));
} }
/** \array_module /** \array_module
@ -380,8 +380,8 @@ Cwise<ExpressionType>::operator+(const Scalar& scalar) const
* *
* \sa operator+(), operator-=() * \sa operator+(), operator-=()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar) inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator+=(const Scalar& scalar)
{ {
return m_matrix.const_cast_derived() = *this + scalar; return m_matrix.const_cast_derived() = *this + scalar;
} }
@ -395,9 +395,9 @@ inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
* *
* \sa operator+(), operator-=() * \sa operator+(), operator-=()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const typename Cwise<ExpressionType>::ScalarAddReturnType inline const typename Cwise<ExpressionType,StorageBase>::ScalarAddReturnType
Cwise<ExpressionType>::operator-(const Scalar& scalar) const Cwise<ExpressionType,StorageBase>::operator-(const Scalar& scalar) const
{ {
return *this + (-scalar); return *this + (-scalar);
} }
@ -412,8 +412,8 @@ Cwise<ExpressionType>::operator-(const Scalar& scalar) const
* \sa operator+=(), operator-() * \sa operator+=(), operator-()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline ExpressionType& Cwise<ExpressionType>::operator-=(const Scalar& scalar) inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator-=(const Scalar& scalar)
{ {
return m_matrix.const_cast_derived() = *this - scalar; return m_matrix.const_cast_derived() = *this - scalar;
} }

View File

@ -45,6 +45,7 @@ template<typename ConditionMatrixType, typename ThenMatrixType, typename ElseMat
struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > struct ei_traits<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> >
{ {
typedef typename ei_traits<ThenMatrixType>::Scalar Scalar; typedef typename ei_traits<ThenMatrixType>::Scalar Scalar;
typedef Dense StorageType;
typedef typename ConditionMatrixType::Nested ConditionMatrixNested; typedef typename ConditionMatrixType::Nested ConditionMatrixNested;
typedef typename ThenMatrixType::Nested ThenMatrixNested; typedef typename ThenMatrixType::Nested ThenMatrixNested;
typedef typename ElseMatrixType::Nested ElseMatrixNested; typedef typename ElseMatrixType::Nested ElseMatrixNested;
@ -87,7 +88,7 @@ class Select : ei_no_assignment_operator,
else else
return m_else.coeff(i,j); return m_else.coeff(i,j);
} }
const Scalar coeff(int i) const const Scalar coeff(int i) const
{ {
if (m_condition.coeff(i)) if (m_condition.coeff(i))

View File

@ -71,7 +71,7 @@
* *
* \sa MatrixBase::cwise() const, MatrixBase::cwise() * \sa MatrixBase::cwise() const, MatrixBase::cwise()
*/ */
template<typename ExpressionType> class Cwise template<typename ExpressionType, template<typename> class StorageBase> class Cwise
{ {
public: public:
@ -91,15 +91,15 @@ template<typename ExpressionType> class Cwise
template<typename OtherDerived> template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
operator/(const MatrixBase<OtherDerived> &other) const; operator/(const StorageBase<OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
min(const MatrixBase<OtherDerived> &other) const; min(const StorageBase<OtherDerived> &other) const;
template<typename OtherDerived> template<typename OtherDerived>
const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
max(const MatrixBase<OtherDerived> &other) const; max(const StorageBase<OtherDerived> &other) const;
const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) abs() 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_abs2_op) abs2() const;
@ -129,28 +129,28 @@ template<typename ExpressionType> class Cwise
ExpressionType& operator-=(const Scalar& scalar); ExpressionType& operator-=(const Scalar& scalar);
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other); inline ExpressionType& operator*=(const StorageBase<OtherDerived> &other);
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other); inline ExpressionType& operator/=(const StorageBase<OtherDerived> &other);
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
operator<(const MatrixBase<OtherDerived>& other) const; operator<(const StorageBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less_equal)
operator<=(const MatrixBase<OtherDerived>& other) const; operator<=(const StorageBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater)
operator>(const MatrixBase<OtherDerived>& other) const; operator>(const StorageBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::greater_equal)
operator>=(const MatrixBase<OtherDerived>& other) const; operator>=(const StorageBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::equal_to)
operator==(const MatrixBase<OtherDerived>& other) const; operator==(const StorageBase<OtherDerived>& other) const;
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to) template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::not_equal_to)
operator!=(const MatrixBase<OtherDerived>& other) const; operator!=(const StorageBase<OtherDerived>& other) const;
// comparisons to a scalar value // comparisons to a scalar value
const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less) const EIGEN_CWISE_COMP_TO_SCALAR_RETURN_TYPE(std::less)

View File

@ -95,7 +95,7 @@ class CwiseBinaryOp : ei_no_assignment_operator,
typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType, typename ei_promote_storage_type<typename ei_traits<Lhs>::StorageType,
typename ei_traits<Rhs>::StorageType>::ret>::Base Base; typename ei_traits<Rhs>::StorageType>::ret>::Base Base;
EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseBinaryOp) EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseBinaryOp)
typedef typename ei_traits<CwiseBinaryOp>::LhsNested LhsNested; typedef typename ei_traits<CwiseBinaryOp>::LhsNested LhsNested;
typedef typename ei_traits<CwiseBinaryOp>::RhsNested RhsNested; typedef typename ei_traits<CwiseBinaryOp>::RhsNested RhsNested;
typedef typename ei_traits<CwiseBinaryOp>::_LhsNested _LhsNested; typedef typename ei_traits<CwiseBinaryOp>::_LhsNested _LhsNested;
@ -232,10 +232,10 @@ MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
* *
* \sa class CwiseBinaryOp, operator/(), square() * \sa class CwiseBinaryOp, operator/(), square()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE
Cwise<ExpressionType>::operator*(const AnyMatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator*(const AnyMatrixBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived()); return EIGEN_CWISE_PRODUCT_RETURN_TYPE(_expression(), other.derived());
} }
@ -247,10 +247,10 @@ Cwise<ExpressionType>::operator*(const AnyMatrixBase<OtherDerived> &other) const
* *
* \sa class CwiseBinaryOp, operator*(), inverse() * \sa class CwiseBinaryOp, operator*(), inverse()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::operator/(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)(_expression(), other.derived());
} }
@ -262,9 +262,9 @@ Cwise<ExpressionType>::operator/(const MatrixBase<OtherDerived> &other) const
* *
* \sa operator*(), operator/=() * \sa operator*(), operator/=()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other) inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator*=(const StorageBase<OtherDerived> &other)
{ {
return m_matrix.const_cast_derived() = *this * other; return m_matrix.const_cast_derived() = *this * other;
} }
@ -276,9 +276,9 @@ inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherD
* *
* \sa operator/(), operator*=() * \sa operator/(), operator*=()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other) inline ExpressionType& Cwise<ExpressionType,StorageBase>::operator/=(const StorageBase<OtherDerived> &other)
{ {
return m_matrix.const_cast_derived() = *this / other; return m_matrix.const_cast_derived() = *this / other;
} }
@ -290,10 +290,10 @@ inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherD
* *
* \sa class CwiseBinaryOp * \sa class CwiseBinaryOp
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
Cwise<ExpressionType>::min(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::min(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)(_expression(), other.derived());
} }
@ -305,10 +305,10 @@ Cwise<ExpressionType>::min(const MatrixBase<OtherDerived> &other) const
* *
* \sa class CwiseBinaryOp * \sa class CwiseBinaryOp
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
template<typename OtherDerived> template<typename OtherDerived>
EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
Cwise<ExpressionType>::max(const MatrixBase<OtherDerived> &other) const Cwise<ExpressionType,StorageBase>::max(const StorageBase<OtherDerived> &other) const
{ {
return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)(_expression(), other.derived()); return EIGEN_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)(_expression(), other.derived());
} }

View File

@ -135,9 +135,9 @@ class CwiseUnaryOpImpl<UnaryOp,MatrixType,Dense> : public MatrixBase<CwiseUnaryO
* *
* \sa abs2() * \sa abs2()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op)
Cwise<ExpressionType>::abs() const Cwise<ExpressionType,StorageBase>::abs() const
{ {
return _expression(); return _expression();
} }
@ -149,9 +149,9 @@ Cwise<ExpressionType>::abs() const
* *
* \sa abs(), square() * \sa abs(), square()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) EIGEN_STRONG_INLINE const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op)
Cwise<ExpressionType>::abs2() const Cwise<ExpressionType,StorageBase>::abs2() const
{ {
return _expression(); return _expression();
} }
@ -163,9 +163,9 @@ Cwise<ExpressionType>::abs2() const
* *
* \sa pow(), log(), sin(), cos() * \sa pow(), log(), sin(), cos()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op)
Cwise<ExpressionType>::exp() const Cwise<ExpressionType,StorageBase>::exp() const
{ {
return _expression(); return _expression();
} }
@ -177,9 +177,9 @@ Cwise<ExpressionType>::exp() const
* *
* \sa exp() * \sa exp()
*/ */
template<typename ExpressionType> template<typename ExpressionType,template <typename> class StorageBase>
inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) inline const EIGEN_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op)
Cwise<ExpressionType>::log() const Cwise<ExpressionType,StorageBase>::log() const
{ {
return _expression(); return _expression();
} }

View File

@ -66,11 +66,11 @@ operator*(const std::complex<Scalar>& scalar) const
} }
inline friend const ScalarMultipleReturnType inline friend const ScalarMultipleReturnType
operator*(const Scalar& scalar, const Self& matrix) operator*(const Scalar& scalar, const StorageBaseType& matrix)
{ return matrix*scalar; } { return matrix*scalar; }
inline friend const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,std::complex<Scalar> >, Derived> inline friend const CwiseUnaryOp<ei_scalar_multiple2_op<Scalar,std::complex<Scalar> >, Derived>
operator*(const std::complex<Scalar>& scalar, const Self& matrix) operator*(const std::complex<Scalar>& scalar, const StorageBaseType& matrix)
{ return matrix*scalar; } { return matrix*scalar; }
/** \returns an expression of *this with the \a Scalar type casted to /** \returns an expression of *this with the \a Scalar type casted to
@ -163,7 +163,7 @@ imag() { return derived(); }
* *
* \sa class Cwise, cwise() * \sa class Cwise, cwise()
*/ */
inline const Cwise<Derived> cwise() const inline const Cwise<Derived,EIGEN_CURRENT_STORAGE_BASE_CLASS> cwise() const
{ {
return derived(); return derived();
} }
@ -175,7 +175,7 @@ inline const Cwise<Derived> cwise() const
* *
* \sa class Cwise, cwise() const * \sa class Cwise, cwise() const
*/ */
inline Cwise<Derived> cwise() inline Cwise<Derived,EIGEN_CURRENT_STORAGE_BASE_CLASS> cwise()
{ {
return derived(); return derived();
} }

View File

@ -51,9 +51,6 @@
} }
* \endcode * \endcode
*/ */
struct Dense {};
template<typename Derived> class MatrixBase template<typename Derived> class MatrixBase
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
: public ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar, : public ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
@ -62,7 +59,9 @@ template<typename Derived> class MatrixBase
{ {
public: public:
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
typedef MatrixBase Self; /** The base class for a given storage type. */
typedef MatrixBase StorageBaseType;
using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar, using ei_special_scalar_op_base<Derived,typename ei_traits<Derived>::Scalar,
typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*; typename NumTraits<typename ei_traits<Derived>::Scalar>::Real>::operator*;
@ -246,7 +245,9 @@ template<typename Derived> class MatrixBase
ei_traits<Derived>::ColsAtCompileTime> BasisReturnType; ei_traits<Derived>::ColsAtCompileTime> BasisReturnType;
#endif // not EIGEN_PARSED_BY_DOXYGEN #endif // not EIGEN_PARSED_BY_DOXYGEN
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::MatrixBase
#include "CwiseUnaryOps.h" #include "CwiseUnaryOps.h"
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
/** Copies \a other into *this. \returns a reference to *this. */ /** Copies \a other into *this. \returns a reference to *this. */
template<typename OtherDerived> template<typename OtherDerived>
@ -563,7 +564,7 @@ template<typename Derived> class MatrixBase
const Flagged<Derived, Added, 0> marked() const; const Flagged<Derived, Added, 0> marked() const;
const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const; const Flagged<Derived, 0, EvalBeforeAssigningBit> lazy() const;
NoAlias<Derived> noalias(); NoAlias<Derived,Eigen::MatrixBase > noalias();
/** \returns number of elements to skip to pass from one row (resp. column) to another /** \returns number of elements to skip to pass from one row (resp. column) to another
* for a row-major (resp. column-major) matrix. * for a row-major (resp. column-major) matrix.

View File

@ -39,7 +39,7 @@
* *
* \sa MatrixBase::noalias() * \sa MatrixBase::noalias()
*/ */
template<typename ExpressionType> template<typename ExpressionType, template <typename> class StorageBase>
class NoAlias class NoAlias
{ {
public: public:
@ -48,17 +48,17 @@ class NoAlias
/** Behaves like MatrixBase::lazyAssign(other) /** Behaves like MatrixBase::lazyAssign(other)
* \sa MatrixBase::lazyAssign() */ * \sa MatrixBase::lazyAssign() */
template<typename OtherDerived> 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()); } { return m_expression.lazyAssign(other.derived()); }
/** \sa MatrixBase::operator+= */ /** \sa MatrixBase::operator+= */
template<typename OtherDerived> 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()); } { return m_expression.lazyAssign(m_expression + other.derived()); }
/** \sa MatrixBase::operator-= */ /** \sa MatrixBase::operator-= */
template<typename OtherDerived> 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()); } { return m_expression.lazyAssign(m_expression - other.derived()); }
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
@ -80,12 +80,12 @@ class NoAlias
/** \returns a pseudo expression of \c *this with an operator= assuming /** \returns a pseudo expression of \c *this with an operator= assuming
* no aliasing between \c *this and the source expression. * no aliasing between \c *this and the source expression.
* *
* More precisely, noalias() allows to bypass the EvalBeforeAssignBit flag. * More precisely, noalias() allows to bypass the EvalBeforeAssignBit flag.
* Currently, even though several expressions may alias, only product * Currently, even though several expressions may alias, only product
* expressions have this flag. Therefore, noalias() is only usefull when * expressions have this flag. Therefore, noalias() is only usefull when
* the source expression contains a matrix product. * the source expression contains a matrix product.
* *
* Here are some examples where noalias is usefull: * Here are some examples where noalias is usefull:
* \code * \code
* D.noalias() = A * B; * D.noalias() = A * B;
@ -107,7 +107,7 @@ class NoAlias
* \sa class NoAlias * \sa class NoAlias
*/ */
template<typename Derived> template<typename Derived>
NoAlias<Derived> MatrixBase<Derived>::noalias() NoAlias<Derived,MatrixBase> MatrixBase<Derived>::noalias()
{ {
return derived(); return derived();
} }

View File

@ -32,18 +32,7 @@
* \brief Internal helper class for swapping two expressions * \brief Internal helper class for swapping two expressions
*/ */
template<typename ExpressionType> template<typename ExpressionType>
struct ei_traits<SwapWrapper<ExpressionType> > struct ei_traits<SwapWrapper<ExpressionType> > : ei_traits<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
};
};
template<typename ExpressionType> class SwapWrapper template<typename ExpressionType> class SwapWrapper
: public MatrixBase<SwapWrapper<ExpressionType> > : public MatrixBase<SwapWrapper<ExpressionType> >

View File

@ -174,16 +174,10 @@ const unsigned int UpperTriangularBit = 0x400;
* means the strictly upper triangular part is 0 */ * means the strictly upper triangular part is 0 */
const unsigned int LowerTriangularBit = 0x800; 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 // list of flags that are inherited by default
const unsigned int HereditaryBits = RowMajorBit const unsigned int HereditaryBits = RowMajorBit
| EvalBeforeNestingBit | EvalBeforeNestingBit
| EvalBeforeAssigningBit | EvalBeforeAssigningBit;
| SparseBit;
// Possible values for the Mode parameter of part() // Possible values for the Mode parameter of part()
const unsigned int UpperTriangular = UpperTriangularBit; const unsigned int UpperTriangular = UpperTriangularBit;
@ -262,7 +256,7 @@ namespace {
enum { enum {
IsDense = 0, IsDense = 0,
IsSparse = SparseBit, IsSparse,
NoDirectAccess = 0, NoDirectAccess = 0,
HasDirectAccess = DirectAccessBit HasDirectAccess = DirectAccessBit
}; };

View File

@ -35,13 +35,12 @@ template<typename _Scalar, int _Rows, int _Cols,
int _MaxRows = _Rows, int _MaxCols = _Cols> class Matrix; int _MaxRows = _Rows, int _MaxCols = _Cols> class Matrix;
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class Flagged; 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 NestByValue;
template<typename ExpressionType> class SwapWrapper; template<typename ExpressionType> class SwapWrapper;
template<typename MatrixType> class Minor; template<typename MatrixType> class Minor;
template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic, int PacketAccess=AsRequested, template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic, int PacketAccess=AsRequested,
int _DirectAccessStatus = ei_traits<MatrixType>::Flags&DirectAccessBit ? DirectAccessBit int _DirectAccessStatus = (ei_traits<MatrixType>::Flags&DirectAccessBit) ? HasDirectAccess : NoDirectAccess> class Block;
: ei_traits<MatrixType>::Flags&SparseBit> class Block;
template<typename MatrixType, int Size=Dynamic, int PacketAccess=AsRequested> class VectorBlock; template<typename MatrixType, int Size=Dynamic, int PacketAccess=AsRequested> class VectorBlock;
template<typename MatrixType> class Transpose; template<typename MatrixType> class Transpose;
template<typename MatrixType> class Conjugate; template<typename MatrixType> class Conjugate;
@ -61,7 +60,7 @@ template<typename MatrixType, int PacketAccess = AsRequested> class Map;
template<typename Derived> class TriangularBase; template<typename Derived> class TriangularBase;
template<typename MatrixType, unsigned int Mode> class TriangularView; template<typename MatrixType, unsigned int Mode> class TriangularView;
template<typename MatrixType, unsigned int Mode> class SelfAdjointView; template<typename MatrixType, unsigned int Mode> class SelfAdjointView;
template<typename ExpressionType> class Cwise; template<typename ExpressionType, template <typename> class StorageBase> class Cwise;
template<typename ExpressionType> class WithFormat; template<typename ExpressionType> class WithFormat;
template<typename MatrixType> struct CommaInitializer; template<typename MatrixType> struct CommaInitializer;
template<typename Derived> class ReturnByValue; template<typename Derived> class ReturnByValue;

View File

@ -108,9 +108,9 @@ template<int _Rows, int _Cols> struct ei_size_at_compile_time
* in order to avoid a useless copy * in order to avoid a useless copy
*/ */
template<typename T, int Sparseness = ei_traits<T>::Flags&SparseBit> class ei_eval; template<typename T, typename StorageType = typename ei_traits<T>::StorageType> class ei_eval;
template<typename T> struct ei_eval<T,IsDense> template<typename T> struct ei_eval<T,Dense>
{ {
typedef Matrix<typename ei_traits<T>::Scalar, typedef Matrix<typename ei_traits<T>::Scalar,
ei_traits<T>::RowsAtCompileTime, ei_traits<T>::RowsAtCompileTime,
@ -123,7 +123,7 @@ template<typename T> struct ei_eval<T,IsDense>
// for matrices, no need to evaluate, just use a const reference to avoid a useless copy // 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> template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, IsDense> struct ei_eval<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>, Dense>
{ {
typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type; typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type;
}; };

View File

@ -52,7 +52,7 @@ struct ei_traits<DynamicSparseMatrix<_Scalar, _Flags> >
ColsAtCompileTime = Dynamic, ColsAtCompileTime = Dynamic,
MaxRowsAtCompileTime = Dynamic, MaxRowsAtCompileTime = Dynamic,
MaxColsAtCompileTime = Dynamic, MaxColsAtCompileTime = Dynamic,
Flags = SparseBit | _Flags, Flags = _Flags,
CoeffReadCost = NumTraits<Scalar>::ReadCost, CoeffReadCost = NumTraits<Scalar>::ReadCost,
SupportedAccessPatterns = OuterRandomAccessPattern SupportedAccessPatterns = OuterRandomAccessPattern
}; };

View File

@ -1,179 +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/>.
#if 0
#ifndef EIGEN_SPARSE_CWISE_H
#define EIGEN_SPARSE_CWISE_H
/** \internal
* convenient macro to defined the return type of a cwise binary operation */
#define EIGEN_SPARSE_CWISE_BINOP_RETURN_TYPE(OP) \
CwiseBinaryOp<OP<typename ei_traits<ExpressionType>::Scalar>, ExpressionType, OtherDerived>
#define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \
SparseCwiseBinaryOp< \
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_SPARSE_CWISE_UNOP_RETURN_TYPE(OP) \
SparseCwiseUnaryOp<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, \
NestByValue<typename ExpressionType::ConstantReturnType> >*/
template<typename ExpressionType> class SparseCwise
{
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 SparseCwise(const ExpressionType& matrix) : m_matrix(matrix) {}
/** \internal */
inline const ExpressionType& _expression() const { return m_matrix; }
template<typename OtherDerived>
const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
operator*(const SparseMatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
operator*(const MatrixBase<OtherDerived> &other) const;
// template<typename OtherDerived>
// const EIGEN_SPARSE_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
// operator/(const SparseMatrixBase<OtherDerived> &other) const;
//
// template<typename OtherDerived>
// const EIGEN_SPARSE_CWISE_BINOP_RETURN_TYPE(ei_scalar_quotient_op)
// operator/(const MatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const EIGEN_SPARSE_CWISE_BINOP_RETURN_TYPE(ei_scalar_min_op)
min(const SparseMatrixBase<OtherDerived> &other) const;
template<typename OtherDerived>
const EIGEN_SPARSE_CWISE_BINOP_RETURN_TYPE(ei_scalar_max_op)
max(const SparseMatrixBase<OtherDerived> &other) const;
const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs_op) abs() const;
const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_abs2_op) abs2() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_square_op) square() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_cube_op) cube() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_inverse_op) inverse() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_sqrt_op) sqrt() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_exp_op) exp() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_log_op) log() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_cos_op) cos() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_sin_op) sin() const;
// const EIGEN_SPARSE_CWISE_UNOP_RETURN_TYPE(ei_scalar_pow_op) pow(const Scalar& exponent) const;
template<typename OtherDerived>
inline ExpressionType& operator*=(const SparseMatrixBase<OtherDerived> &other);
// template<typename OtherDerived>
// inline ExpressionType& operator/=(const SparseMatrixBase<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 SparseCwise outside Eigen
#ifdef EIGEN_SPARSE_CWISE_PLUGIN
#include EIGEN_SPARSE_CWISE_PLUGIN
#endif
protected:
ExpressionTypeNested m_matrix;
};
// template<typename Derived>
// inline const SparseCwise<Derived>
// SparseMatrixBase<Derived>::cwise() const
// {
// return derived();
// }
//
// template<typename Derived>
// inline SparseCwise<Derived>
// SparseMatrixBase<Derived>::cwise()
// {
// return derived();
// }
#endif // EIGEN_SPARSE_CWISE_H
#endif

View File

@ -95,8 +95,8 @@ class CwiseBinaryOpImpl<BinaryOp, Lhs, Rhs, Sparse>
}; };
template<typename BinaryOp, typename Lhs, typename Rhs, typename Derived, template<typename BinaryOp, typename Lhs, typename Rhs, typename Derived,
int _LhsStorageMode = int(Lhs::Flags) & SparseBit, typename _LhsStorageMode = typename ei_traits<Lhs>::StorageType,
int _RhsStorageMode = int(Rhs::Flags) & SparseBit> typename _RhsStorageMode = typename ei_traits<Rhs>::StorageType>
class ei_sparse_cwise_binary_op_inner_iterator_selector; class ei_sparse_cwise_binary_op_inner_iterator_selector;
template<typename BinaryOp, typename Lhs, typename Rhs> template<typename BinaryOp, typename Lhs, typename Rhs>
@ -123,7 +123,7 @@ class CwiseBinaryOpImpl<BinaryOp,Lhs,Rhs,Sparse>::InnerIterator
// sparse - sparse (generic) // sparse - sparse (generic)
template<typename BinaryOp, typename Lhs, typename Rhs, typename Derived> template<typename BinaryOp, typename Lhs, typename Rhs, typename Derived>
class ei_sparse_cwise_binary_op_inner_iterator_selector<BinaryOp, Lhs, Rhs, Derived, IsSparse, IsSparse> class ei_sparse_cwise_binary_op_inner_iterator_selector<BinaryOp, Lhs, Rhs, Derived, Sparse, Sparse>
{ {
typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> CwiseBinaryXpr; typedef CwiseBinaryOp<BinaryOp, Lhs, Rhs> CwiseBinaryXpr;
typedef typename ei_traits<CwiseBinaryXpr>::Scalar Scalar; typedef typename ei_traits<CwiseBinaryXpr>::Scalar Scalar;
@ -185,7 +185,7 @@ class ei_sparse_cwise_binary_op_inner_iterator_selector<BinaryOp, Lhs, Rhs, Deri
// sparse - sparse (product) // sparse - sparse (product)
template<typename T, typename Lhs, typename Rhs, typename Derived> template<typename T, typename Lhs, typename Rhs, typename Derived>
class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>, Lhs, Rhs, Derived, IsSparse, IsSparse> class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>, Lhs, Rhs, Derived, Sparse, Sparse>
{ {
typedef ei_scalar_product_op<T> BinaryFunc; typedef ei_scalar_product_op<T> BinaryFunc;
typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr; typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr;
@ -238,7 +238,7 @@ class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>,
// sparse - dense (product) // sparse - dense (product)
template<typename T, typename Lhs, typename Rhs, typename Derived> template<typename T, typename Lhs, typename Rhs, typename Derived>
class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>, Lhs, Rhs, Derived, IsSparse, IsDense> class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>, Lhs, Rhs, Derived, Sparse, Dense>
{ {
typedef ei_scalar_product_op<T> BinaryFunc; typedef ei_scalar_product_op<T> BinaryFunc;
typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr; typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr;
@ -278,7 +278,7 @@ class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>,
// sparse - dense (product) // sparse - dense (product)
template<typename T, typename Lhs, typename Rhs, typename Derived> template<typename T, typename Lhs, typename Rhs, typename Derived>
class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>, Lhs, Rhs, Derived, IsDense, IsSparse> class ei_sparse_cwise_binary_op_inner_iterator_selector<ei_scalar_product_op<T>, Lhs, Rhs, Derived, Dense, Sparse>
{ {
typedef ei_scalar_product_op<T> BinaryFunc; typedef ei_scalar_product_op<T> BinaryFunc;
typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr; typedef CwiseBinaryOp<BinaryFunc, Lhs, Rhs> CwiseBinaryXpr;

View File

@ -43,21 +43,22 @@ struct ei_traits<SparseDiagonalProduct<Lhs, Rhs> >
typedef typename ei_cleantype<Lhs>::type _Lhs; typedef typename ei_cleantype<Lhs>::type _Lhs;
typedef typename ei_cleantype<Rhs>::type _Rhs; typedef typename ei_cleantype<Rhs>::type _Rhs;
typedef typename _Lhs::Scalar Scalar; typedef typename _Lhs::Scalar Scalar;
typedef Sparse StorageType;
enum { enum {
RowsAtCompileTime = _Lhs::RowsAtCompileTime, RowsAtCompileTime = _Lhs::RowsAtCompileTime,
ColsAtCompileTime = _Rhs::ColsAtCompileTime, ColsAtCompileTime = _Rhs::ColsAtCompileTime,
MaxRowsAtCompileTime = _Lhs::MaxRowsAtCompileTime, MaxRowsAtCompileTime = _Lhs::MaxRowsAtCompileTime,
MaxColsAtCompileTime = _Rhs::MaxColsAtCompileTime, MaxColsAtCompileTime = _Rhs::MaxColsAtCompileTime,
SparseFlags = ei_is_diagonal<_Lhs>::ret ? int(_Rhs::Flags) : int(_Lhs::Flags), SparseFlags = ei_is_diagonal<_Lhs>::ret ? int(_Rhs::Flags) : int(_Lhs::Flags),
Flags = SparseBit | (SparseFlags&RowMajorBit), Flags = (SparseFlags&RowMajorBit),
CoeffReadCost = Dynamic CoeffReadCost = Dynamic
}; };
}; };
enum {SDP_IsDiagonal, SDP_IsSparseRowMajor, SDP_IsSparseColMajor}; enum {SDP_IsDiagonal, SDP_IsSparseRowMajor, SDP_IsSparseColMajor};
template<typename Lhs, typename Rhs, typename SparseDiagonalProductType, int RhsMode, int LhsMode> template<typename Lhs, typename Rhs, typename SparseDiagonalProductType, int RhsMode, int LhsMode>
class ei_sparse_diagonal_product_inner_iterator_selector; class ei_sparse_diagonal_product_inner_iterator_selector;
template<typename Lhs, typename Rhs> template<typename Lhs, typename Rhs>
@ -70,7 +71,7 @@ class SparseDiagonalProduct
typedef typename ei_cleantype<LhsNested>::type _LhsNested; typedef typename ei_cleantype<LhsNested>::type _LhsNested;
typedef typename ei_cleantype<RhsNested>::type _RhsNested; typedef typename ei_cleantype<RhsNested>::type _RhsNested;
enum { enum {
LhsMode = ei_is_diagonal<_LhsNested>::ret ? SDP_IsDiagonal LhsMode = ei_is_diagonal<_LhsNested>::ret ? SDP_IsDiagonal
: (_LhsNested::Flags&RowMajorBit) ? SDP_IsSparseRowMajor : SDP_IsSparseColMajor, : (_LhsNested::Flags&RowMajorBit) ? SDP_IsSparseRowMajor : SDP_IsSparseColMajor,
@ -81,7 +82,7 @@ class SparseDiagonalProduct
public: public:
EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseDiagonalProduct) EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseDiagonalProduct)
typedef ei_sparse_diagonal_product_inner_iterator_selector typedef ei_sparse_diagonal_product_inner_iterator_selector
<_LhsNested,_RhsNested,SparseDiagonalProduct,LhsMode,RhsMode> InnerIterator; <_LhsNested,_RhsNested,SparseDiagonalProduct,LhsMode,RhsMode> InnerIterator;

View File

@ -1,49 +0,0 @@
// 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/>.
#if 0
#ifndef EIGEN_SPARSE_EXPRESSIONMAKER_H
#define EIGEN_SPARSE_EXPRESSIONMAKER_H
template<typename XprType>
struct MakeNestByValue<XprType,IsSparse>
{
typedef SparseNestByValue<XprType> Type;
};
template<typename Func, typename XprType>
struct MakeCwiseUnaryOp<Func,XprType,IsSparse>
{
typedef SparseCwiseUnaryOp<Func,XprType> Type;
};
template<typename Func, typename A, typename B>
struct MakeCwiseBinaryOp<Func,A,B,IsSparse>
{
typedef SparseCwiseBinaryOp<Func,A,B> Type;
};
// TODO complete the list
#endif // EIGEN_SPARSE_EXPRESSIONMAKER_H
#endif

View File

@ -1,97 +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>
// Copyright (C) 2008 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_SPARSE_FLAGGED_H
#define EIGEN_SPARSE_FLAGGED_H
template<typename ExpressionType, unsigned int Added, unsigned int Removed>
struct ei_traits<SparseFlagged<ExpressionType, Added, Removed> > : ei_traits<ExpressionType>
{
enum { Flags = (ExpressionType::Flags | Added) & ~Removed };
};
template<typename ExpressionType, unsigned int Added, unsigned int Removed> class SparseFlagged
: public SparseMatrixBase<SparseFlagged<ExpressionType, Added, Removed> >
{
public:
EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseFlagged)
class InnerIterator;
class ReverseInnerIterator;
typedef typename ei_meta_if<ei_must_nest_by_value<ExpressionType>::ret,
ExpressionType, const ExpressionType&>::ret ExpressionTypeNested;
inline SparseFlagged(const ExpressionType& matrix) : m_matrix(matrix) {}
inline int rows() const { return m_matrix.rows(); }
inline int cols() const { return m_matrix.cols(); }
// FIXME should be keep them ?
inline Scalar& coeffRef(int row, int col)
{ return m_matrix.const_cast_derived().coeffRef(col, row); }
inline const Scalar coeff(int row, int col) const
{ return m_matrix.coeff(col, row); }
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); }
protected:
ExpressionTypeNested m_matrix;
};
template<typename ExpressionType, unsigned int Added, unsigned int Removed>
class SparseFlagged<ExpressionType,Added,Removed>::InnerIterator : public ExpressionType::InnerIterator
{
public:
EIGEN_STRONG_INLINE InnerIterator(const SparseFlagged& xpr, int outer)
: ExpressionType::InnerIterator(xpr.m_matrix, outer)
{}
};
template<typename ExpressionType, unsigned int Added, unsigned int Removed>
class SparseFlagged<ExpressionType,Added,Removed>::ReverseInnerIterator : public ExpressionType::ReverseInnerIterator
{
public:
EIGEN_STRONG_INLINE ReverseInnerIterator(const SparseFlagged& xpr, int outer)
: ExpressionType::ReverseInnerIterator(xpr.m_matrix, outer)
{}
};
template<typename Derived>
template<unsigned int Added>
inline const SparseFlagged<Derived, Added, 0>
SparseMatrixBase<Derived>::marked() const
{
return derived();
}
#endif // EIGEN_SPARSE_FLAGGED_H

View File

@ -51,7 +51,7 @@ struct ei_traits<SparseMatrix<_Scalar, _Options> >
ColsAtCompileTime = Dynamic, ColsAtCompileTime = Dynamic,
MaxRowsAtCompileTime = Dynamic, MaxRowsAtCompileTime = Dynamic,
MaxColsAtCompileTime = Dynamic, MaxColsAtCompileTime = Dynamic,
Flags = SparseBit | _Options, Flags = _Options,
CoeffReadCost = NumTraits<Scalar>::ReadCost, CoeffReadCost = NumTraits<Scalar>::ReadCost,
SupportedAccessPatterns = InnerRandomAccessPattern SupportedAccessPatterns = InnerRandomAccessPattern
}; };

View File

@ -36,16 +36,13 @@
* *
* *
*/ */
struct Sparse {};
template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived> template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived>
{ {
public: public:
typedef typename ei_traits<Derived>::Scalar Scalar; typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar; typedef typename ei_packet_traits<Scalar>::type PacketScalar;
typedef SparseMatrixBase Self; typedef SparseMatrixBase StorageBaseType;
enum { enum {
@ -112,7 +109,9 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
Transpose<Derived> Transpose<Derived>
>::ret AdjointReturnType; >::ret AdjointReturnType;
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
#include "../Core/CwiseUnaryOps.h" #include "../Core/CwiseUnaryOps.h"
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
#ifndef EIGEN_PARSED_BY_DOXYGEN #ifndef EIGEN_PARSED_BY_DOXYGEN
/** This is the "real scalar" type; if the \a Scalar type is already real numbers /** This is the "real scalar" type; if the \a Scalar type is already real numbers
@ -534,8 +533,8 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
// template<typename OtherDerived> // template<typename OtherDerived>
// void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other); // void swap(MatrixBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
template<unsigned int Added> // template<unsigned int Added>
const SparseFlagged<Derived, Added, 0> marked() const; // const SparseFlagged<Derived, Added, 0> marked() const;
// const Flagged<Derived, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit> lazy() const; // const Flagged<Derived, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit> lazy() const;
/** \returns number of elements to skip to pass from one row (resp. column) to another /** \returns number of elements to skip to pass from one row (resp. column) to another

View File

@ -25,16 +25,9 @@
#ifndef EIGEN_SPARSEPRODUCT_H #ifndef EIGEN_SPARSEPRODUCT_H
#define EIGEN_SPARSEPRODUCT_H #define EIGEN_SPARSEPRODUCT_H
template<typename Lhs, typename Rhs> struct ei_sparse_product_mode template<typename Lhs, typename Rhs> struct ei_sparse_product_mode<Lhs,Rhs,Sparse,Sparse> { enum { value = SparseTimeSparseProduct }; };
{ template<typename Lhs, typename Rhs> struct ei_sparse_product_mode<Lhs,Rhs,Dense, Sparse> { enum { value = DenseTimeSparseProduct }; };
enum { template<typename Lhs, typename Rhs> struct ei_sparse_product_mode<Lhs,Rhs,Sparse,Dense> { enum { value = SparseTimeDenseProduct }; };
value = (Rhs::Flags&Lhs::Flags&SparseBit)==SparseBit
? SparseTimeSparseProduct
: (Lhs::Flags&SparseBit)==SparseBit
? SparseTimeDenseProduct
: DenseTimeSparseProduct };
};
template<typename Lhs, typename Rhs, int ProductMode> template<typename Lhs, typename Rhs, int ProductMode>
struct SparseProductReturnType struct SparseProductReturnType
@ -91,13 +84,10 @@ struct ei_traits<SparseProduct<LhsNested, RhsNested, ProductMode> >
MaxRowsAtCompileTime = _LhsNested::MaxRowsAtCompileTime, MaxRowsAtCompileTime = _LhsNested::MaxRowsAtCompileTime,
MaxColsAtCompileTime = _RhsNested::MaxColsAtCompileTime, MaxColsAtCompileTime = _RhsNested::MaxColsAtCompileTime,
// LhsIsRowMajor = (LhsFlags & RowMajorBit)==RowMajorBit,
// RhsIsRowMajor = (RhsFlags & RowMajorBit)==RowMajorBit,
EvalToRowMajor = (RhsFlags & LhsFlags & RowMajorBit), EvalToRowMajor = (RhsFlags & LhsFlags & RowMajorBit),
ResultIsSparse = ProductMode==SparseTimeSparseProduct, ResultIsSparse = ProductMode==SparseTimeSparseProduct,
RemovedBits = ~( (EvalToRowMajor ? 0 : RowMajorBit) | (ResultIsSparse ? 0 : SparseBit) ), RemovedBits = ~(EvalToRowMajor ? 0 : RowMajorBit),
Flags = (int(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits) Flags = (int(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits)
| EvalBeforeAssigningBit | EvalBeforeAssigningBit
@ -106,6 +96,8 @@ struct ei_traits<SparseProduct<LhsNested, RhsNested, ProductMode> >
CoeffReadCost = Dynamic CoeffReadCost = Dynamic
}; };
typedef typename ei_meta_if<ResultIsSparse, Sparse, Dense>::ret StorageType;
typedef typename ei_meta_if<ResultIsSparse, typedef typename ei_meta_if<ResultIsSparse,
SparseMatrixBase<SparseProduct<LhsNested, RhsNested, ProductMode> >, SparseMatrixBase<SparseProduct<LhsNested, RhsNested, ProductMode> >,
MatrixBase<SparseProduct<LhsNested, RhsNested, ProductMode> > >::ret Base; MatrixBase<SparseProduct<LhsNested, RhsNested, ProductMode> > >::ret Base;

View File

@ -1,7 +1,7 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of Eigen, a lightweight C++ template library
// for linear algebra. // for linear algebra.
// //
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr> // Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr>
// //
// Eigen is free software; you can redistribute it and/or // Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
@ -25,51 +25,30 @@
#ifndef EIGEN_SPARSETRANSPOSE_H #ifndef EIGEN_SPARSETRANSPOSE_H
#define EIGEN_SPARSETRANSPOSE_H #define EIGEN_SPARSETRANSPOSE_H
// template<typename MatrixType>
// struct ei_traits<SparseTranspose<MatrixType> > : ei_traits<Transpose<MatrixType> >
// {};
template<typename MatrixType> class TransposeImpl<MatrixType,Sparse> template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
: public SparseMatrixBase<Transpose<MatrixType> > : public SparseMatrixBase<Transpose<MatrixType> >
{ {
const typename ei_cleantype<typename MatrixType::Nested>::type& matrix() const
{ return derived().nestedExpression(); }
typename ei_cleantype<typename MatrixType::Nested>::type& matrix()
{ return derived().nestedExpression(); }
public: public:
// _EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(TransposeImpl,SparseMatrixBase<Transpose<MatrixType> >)
// EIGEN_EXPRESSION_IMPL_COMMON(SparseMatrixBase<Transpose<MatrixType> >)
EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose<MatrixType>) EIGEN_SPARSE_PUBLIC_INTERFACE(Transpose<MatrixType>)
class InnerIterator; class InnerIterator;
class ReverseInnerIterator; class ReverseInnerIterator;
// inline SparseTranspose(const MatrixType& matrix) : m_matrix(matrix) {} inline int nonZeros() const { return derived().nestedExpression().nonZeros(); }
//EIGEN_INHERIT_ASSIGNMENT_OPERATORS(SparseTranspose)
// inline int rows() const { return m_matrix.cols(); }
// inline int cols() const { return m_matrix.rows(); }
inline int nonZeros() const { return matrix().nonZeros(); }
// FIXME should be keep them ? // FIXME should be keep them ?
inline Scalar& coeffRef(int row, int col) inline Scalar& coeffRef(int row, int col)
{ return matrix().const_cast_derived().coeffRef(col, row); } { return const_cast_derived().nestedExpression().coeffRef(col, row); }
inline const Scalar coeff(int row, int col) const inline const Scalar coeff(int row, int col) const
{ return matrix().coeff(col, row); } { return derived().nestedExpression().coeff(col, row); }
inline const Scalar coeff(int index) const inline const Scalar coeff(int index) const
{ return matrix().coeff(index); } { return derived().nestedExpression().coeff(index); }
inline Scalar& coeffRef(int index) inline Scalar& coeffRef(int index)
{ return matrix().const_cast_derived().coeffRef(index); } { return const_cast_derived().nestedExpression().coeffRef(index); }
// protected:
// const typename MatrixType::Nested m_matrix;
}; };
template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerIterator : public MatrixType::InnerIterator template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerIterator : public MatrixType::InnerIterator
@ -78,7 +57,7 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerItera
public: public:
EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, int outer) EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, int outer)
: Base(trans.matrix(), outer) : Base(trans.derived().nestedExpression(), outer)
{} {}
inline int row() const { return Base::col(); } inline int row() const { return Base::col(); }
inline int col() const { return Base::row(); } inline int col() const { return Base::row(); }
@ -90,7 +69,7 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInn
public: public:
EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, int outer) EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, int outer)
: Base(xpr.matrix(), outer) : Base(xpr.derived().nestedExpression(), outer)
{} {}
inline int row() const { return Base::col(); } inline int row() const { return Base::col(); }
inline int col() const { return Base::row(); } inline int col() const { return Base::row(); }

View File

@ -82,7 +82,8 @@ enum { RowsAtCompileTime = Eigen::ei_traits<Derived>::RowsAtCompileTime, \
CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \ CoeffReadCost = Eigen::ei_traits<Derived>::CoeffReadCost, \
SizeAtCompileTime = Base::SizeAtCompileTime, \ SizeAtCompileTime = Base::SizeAtCompileTime, \
IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
using Base::derived; using Base::derived; \
using Base::const_cast_derived;
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \ #define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
_EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived>) _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived>)
@ -129,7 +130,10 @@ template<typename ExpressionType,
template<typename ExpressionType, int Mode> class SparseTriangular; template<typename ExpressionType, int Mode> class SparseTriangular;
template<typename Lhs, typename Rhs> class SparseDiagonalProduct; template<typename Lhs, typename Rhs> class SparseDiagonalProduct;
template<typename Lhs, typename Rhs> struct ei_sparse_product_mode; template<typename Lhs, typename Rhs,
typename LhsStorage = typename ei_traits<Lhs>::StorageType,
typename RhsStorage = typename ei_traits<Rhs>::StorageType> struct ei_sparse_product_mode;
template<typename Lhs, typename Rhs, int ProductMode = ei_sparse_product_mode<Lhs,Rhs>::value> struct SparseProductReturnType; template<typename Lhs, typename Rhs, int ProductMode = ei_sparse_product_mode<Lhs,Rhs>::value> struct SparseProductReturnType;
const int CoherentAccessPattern = 0x1; const int CoherentAccessPattern = 0x1;
@ -137,18 +141,7 @@ const int InnerRandomAccessPattern = 0x2 | CoherentAccessPattern;
const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern; const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern;
const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern; const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;
// const int AccessPatternNotSupported = 0x0; template<typename T> class ei_eval<T,Sparse>
// const int AccessPatternSupported = 0x1;
//
// template<typename MatrixType, int AccessPattern> struct ei_support_access_pattern
// {
// enum { ret = (int(ei_traits<MatrixType>::SupportedAccessPatterns) & AccessPattern) == AccessPattern
// ? AccessPatternSupported
// : AccessPatternNotSupported
// };
// };
template<typename T> class ei_eval<T,IsSparse>
{ {
typedef typename ei_traits<T>::Scalar _Scalar; typedef typename ei_traits<T>::Scalar _Scalar;
enum { enum {

View File

@ -46,7 +46,7 @@ struct ei_traits<SparseVector<_Scalar, _Options> >
ColsAtCompileTime = IsColVector ? 1 : Dynamic, ColsAtCompileTime = IsColVector ? 1 : Dynamic,
MaxRowsAtCompileTime = RowsAtCompileTime, MaxRowsAtCompileTime = RowsAtCompileTime,
MaxColsAtCompileTime = ColsAtCompileTime, MaxColsAtCompileTime = ColsAtCompileTime,
Flags = SparseBit | _Options, Flags = _Options,
CoeffReadCost = NumTraits<Scalar>::ReadCost, CoeffReadCost = NumTraits<Scalar>::ReadCost,
SupportedAccessPatterns = InnerRandomAccessPattern SupportedAccessPatterns = InnerRandomAccessPattern
}; };

View File

@ -58,10 +58,10 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType&
VERIFY_IS_APPROX(dm4=m2*refMat3.transpose(), refMat4=refMat2*refMat3.transpose()); VERIFY_IS_APPROX(dm4=m2*refMat3.transpose(), refMat4=refMat2*refMat3.transpose());
VERIFY_IS_APPROX(dm4=m2.transpose()*refMat3, refMat4=refMat2.transpose()*refMat3); VERIFY_IS_APPROX(dm4=m2.transpose()*refMat3, refMat4=refMat2.transpose()*refMat3);
VERIFY_IS_APPROX(dm4=m2.transpose()*refMat3.transpose(), refMat4=refMat2.transpose()*refMat3.transpose()); VERIFY_IS_APPROX(dm4=m2.transpose()*refMat3.transpose(), refMat4=refMat2.transpose()*refMat3.transpose());
VERIFY_IS_APPROX(dm4=m2*(refMat3+refMat3), refMat4=refMat2*(refMat3+refMat3)); VERIFY_IS_APPROX(dm4=m2*(refMat3+refMat3), refMat4=refMat2*(refMat3+refMat3));
VERIFY_IS_APPROX(dm4=m2.transpose()*(refMat3+refMat5)*0.5, refMat4=refMat2.transpose()*(refMat3+refMat5)*0.5); VERIFY_IS_APPROX(dm4=m2.transpose()*(refMat3+refMat5)*0.5, refMat4=refMat2.transpose()*(refMat3+refMat5)*0.5);
// dense * sparse // dense * sparse
VERIFY_IS_APPROX(dm4=refMat2*m3, refMat4=refMat2*refMat3); VERIFY_IS_APPROX(dm4=refMat2*m3, refMat4=refMat2*refMat3);
VERIFY_IS_APPROX(dm4=refMat2*m3.transpose(), refMat4=refMat2*refMat3.transpose()); VERIFY_IS_APPROX(dm4=refMat2*m3.transpose(), refMat4=refMat2*refMat3.transpose());
@ -114,9 +114,10 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType&
VERIFY_IS_APPROX(mS.transpose().conjugate(), mS); VERIFY_IS_APPROX(mS.transpose().conjugate(), mS);
VERIFY_IS_APPROX(mS, refS); VERIFY_IS_APPROX(mS, refS);
VERIFY_IS_APPROX(x=mS*b, refX=refS*b); VERIFY_IS_APPROX(x=mS*b, refX=refS*b);
VERIFY_IS_APPROX(x=mUp.template marked<UpperTriangular|SelfAdjoint>()*b, refX=refS*b); // TODO properly implement triangular/selfadjoint views
VERIFY_IS_APPROX(x=mLo.template marked<LowerTriangular|SelfAdjoint>()*b, refX=refS*b); // VERIFY_IS_APPROX(x=mUp.template marked<UpperTriangular|SelfAdjoint>()*b, refX=refS*b);
VERIFY_IS_APPROX(x=mS.template marked<SelfAdjoint>()*b, refX=refS*b); // VERIFY_IS_APPROX(x=mLo.template marked<LowerTriangular|SelfAdjoint>()*b, refX=refS*b);
// VERIFY_IS_APPROX(x=mS.template marked<SelfAdjoint>()*b, refX=refS*b);
} }
} }