aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2010-01-04 19:00:16 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2010-01-04 19:00:16 +0100
commit8eab9fb87e2bcb3d9bce50c588e88fb6d500bfb5 (patch)
treee2ea6cb7185a144979a617b7e765491775b1a800 /Eigen/src
parentfcc3be5dceb2378a1b7659793686faaeb3fbe294 (diff)
port VectorwiseOp and Swap to the novel mechanisms, and various cleanning
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Array/ArrayBase.h63
-rw-r--r--Eigen/src/Array/VectorwiseOp.h68
-rw-r--r--Eigen/src/Core/DenseBase.h41
-rw-r--r--Eigen/src/Core/MatrixBase.h53
-rw-r--r--Eigen/src/Core/SelfCwiseBinaryOp.h27
-rw-r--r--Eigen/src/Core/Swap.h7
-rw-r--r--Eigen/src/Sparse/CoreIterators.h4
7 files changed, 88 insertions, 175 deletions
diff --git a/Eigen/src/Array/ArrayBase.h b/Eigen/src/Array/ArrayBase.h
index ccc8b8373..1ec2a3516 100644
--- a/Eigen/src/Array/ArrayBase.h
+++ b/Eigen/src/Array/ArrayBase.h
@@ -35,17 +35,17 @@ template<typename ExpressionType> class MatrixWrapper;
*
* An array is similar to a dense vector or matrix. While matrices are mathematical
* objects with well defined linear algebra operators, an array is just a collection
- * of scalar values arranged in a one or two dimensionnal fashion. The main consequence,
- * is that all operations applied to an array are performed coefficient wise. Furthermore,
- * arays support scalar math functions of the c++ standard library, and convenient
+ * of scalar values arranged in a one or two dimensionnal fashion. As the main consequence,
+ * all operations applied to an array are performed coefficient wise. Furthermore,
+ * arrays support scalar math functions of the c++ standard library (e.g., std::sin(x)), and convenient
* constructors allowing to easily write generic code working for both scalar values
* and arrays.
*
* This class is the base that is inherited by all array expression types.
*
- * \param Derived is the derived type, e.g. an array type, or an expression, etc.
+ * \param Derived is the derived type, e.g., an array or an expression type.
*
- * \sa class ArrayBase
+ * \sa class MatrixBase
*/
template<typename Derived> class ArrayBase
: public DenseBase<Derived>
@@ -60,8 +60,6 @@ template<typename Derived> class ArrayBase
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;
@@ -126,11 +124,6 @@ template<typename Derived> class ArrayBase
# endif
#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
-
- /** Copies \a other into *this. \returns a reference to *this. */
-// template<typename OtherDerived>
-// Derived& operator=(const ArrayBase<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)
*/
@@ -139,14 +132,6 @@ template<typename Derived> class ArrayBase
return ei_assign_selector<Derived,Derived>::run(derived(), other.derived());
}
-#ifndef EIGEN_PARSED_BY_DOXYGEN
- /** Copies \a other into *this without evaluating other. \returns a reference to *this. */
-// template<typename OtherDerived>
-// Derived& lazyAssign(const ArrayBase<OtherDerived>& other);
-// template<typename OtherDerived>
-// Derived& lazyAssign(const MatrixBase<OtherDerived>& other);
-#endif // not EIGEN_PARSED_BY_DOXYGEN
-
Derived& operator+=(const Scalar& scalar)
{ return *this = derived() + scalar; }
Derived& operator-=(const Scalar& scalar)
@@ -168,46 +153,16 @@ template<typename Derived> class ArrayBase
inline bool operator!=(const ArrayBase<OtherDerived>& other) const
{ return cwiseNotEqual(other).all(); }
-
- /** \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(ArrayBase<OtherDerived> EIGEN_REF_TO_TEMPORARY other);
-
-
-// const VectorwiseOp<Derived,Horizontal> rowwise() const;
-// VectorwiseOp<Derived,Horizontal> rowwise();
-// const VectorwiseOp<Derived,Vertical> colwise() const;
-// VectorwiseOp<Derived,Vertical> colwise();
-
-
-
public:
MatrixWrapper<Derived> asMatrix() { return derived(); }
const MatrixWrapper<Derived> asMatrix() const { return derived(); }
- template<typename Dest>
- inline void evalTo(Dest& dst) const { dst = asMatrix(); }
+// template<typename Dest>
+// inline void evalTo(Dest& dst) const { dst = asMatrix(); }
protected:
- /** Default constructor. Do nothing. */
- ArrayBase()
- {
- /* 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
- }
-
+ ArrayBase() : Base() {}
+
private:
explicit ArrayBase(int);
ArrayBase(int,int);
diff --git a/Eigen/src/Array/VectorwiseOp.h b/Eigen/src/Array/VectorwiseOp.h
index 05dd69789..c0944fc42 100644
--- a/Eigen/src/Array/VectorwiseOp.h
+++ b/Eigen/src/Array/VectorwiseOp.h
@@ -119,7 +119,7 @@ class PartialReduxExpr : ei_no_assignment_operator,
template<typename Scalar, int Size> struct Cost \
{ enum { value = COST }; }; \
template<typename Derived> \
- inline ResultType operator()(const MatrixBase<Derived>& mat) const \
+ inline ResultType operator()(const DenseBase<Derived>& mat) const \
{ return mat.MEMBER(); } \
}
@@ -148,7 +148,7 @@ struct ei_member_redux {
{ enum { value = (Size-1) * ei_functor_traits<BinaryOp>::Cost }; };
ei_member_redux(const BinaryOp func) : m_functor(func) {}
template<typename Derived>
- inline result_type operator()(const MatrixBase<Derived>& mat) const
+ inline result_type operator()(const DenseBase<Derived>& mat) const
{ return mat.redux(m_functor); }
const BinaryOp m_functor;
};
@@ -163,13 +163,13 @@ struct ei_member_redux {
* \param Direction indicates the direction of the redux (Vertical or Horizontal)
*
* This class represents a pseudo expression with partial reduction features.
- * It is the return type of MatrixBase::colwise() and MatrixBase::rowwise()
+ * It is the return type of DenseBase::colwise() and DenseBase::rowwise()
* and most of the time this is the only way it is used.
*
* Example: \include MatrixBase_colwise.cpp
* Output: \verbinclude MatrixBase_colwise.out
*
- * \sa MatrixBase::colwise(), MatrixBase::rowwise(), class PartialReduxExpr
+ * \sa DenseBase::colwise(), DenseBase::rowwise(), class PartialReduxExpr
*/
template<typename ExpressionType, int Direction> class VectorwiseOp
{
@@ -227,7 +227,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Replicates a vector to match the size of \c *this */
template<typename OtherDerived>
typename ExtendedType<OtherDerived>::Type
- extendedTo(const MatrixBase<OtherDerived>& other) const
+ extendedTo(const DenseBase<OtherDerived>& other) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
return typename ExtendedType<OtherDerived>::Type
@@ -248,7 +248,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* The template parameter \a BinaryOp is the type of the functor
* of the custom redux operator. Note that func must be an associative operator.
*
- * \sa class VectorwiseOp, MatrixBase::colwise(), MatrixBase::rowwise()
+ * \sa class VectorwiseOp, DenseBase::colwise(), DenseBase::rowwise()
*/
template<typename BinaryOp>
const typename ReduxReturnType<BinaryOp>::Type
@@ -261,7 +261,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_minCoeff.cpp
* Output: \verbinclude PartialRedux_minCoeff.out
*
- * \sa MatrixBase::minCoeff() */
+ * \sa DenseBase::minCoeff() */
const typename ReturnType<ei_member_minCoeff>::Type minCoeff() const
{ return _expression(); }
@@ -271,7 +271,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_maxCoeff.cpp
* Output: \verbinclude PartialRedux_maxCoeff.out
*
- * \sa MatrixBase::maxCoeff() */
+ * \sa DenseBase::maxCoeff() */
const typename ReturnType<ei_member_maxCoeff>::Type maxCoeff() const
{ return _expression(); }
@@ -281,7 +281,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_squaredNorm.cpp
* Output: \verbinclude PartialRedux_squaredNorm.out
*
- * \sa MatrixBase::squaredNorm() */
+ * \sa DenseBase::squaredNorm() */
const typename ReturnType<ei_member_squaredNorm>::Type squaredNorm() const
{ return _expression(); }
@@ -291,7 +291,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_norm.cpp
* Output: \verbinclude PartialRedux_norm.out
*
- * \sa MatrixBase::norm() */
+ * \sa DenseBase::norm() */
const typename ReturnType<ei_member_norm>::Type norm() const
{ return _expression(); }
@@ -300,7 +300,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* of each column (or row) of the referenced expression, using
* blue's algorithm.
*
- * \sa MatrixBase::blueNorm() */
+ * \sa DenseBase::blueNorm() */
const typename ReturnType<ei_member_blueNorm>::Type blueNorm() const
{ return _expression(); }
@@ -309,7 +309,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* of each column (or row) of the referenced expression, avoiding
* underflow and overflow.
*
- * \sa MatrixBase::stableNorm() */
+ * \sa DenseBase::stableNorm() */
const typename ReturnType<ei_member_stableNorm>::Type stableNorm() const
{ return _expression(); }
@@ -318,7 +318,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* of each column (or row) of the referenced expression, avoiding
* underflow and overflow using a concatenation of hypot() calls.
*
- * \sa MatrixBase::hypotNorm() */
+ * \sa DenseBase::hypotNorm() */
const typename ReturnType<ei_member_hypotNorm>::Type hypotNorm() const
{ return _expression(); }
@@ -328,28 +328,28 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_sum.cpp
* Output: \verbinclude PartialRedux_sum.out
*
- * \sa MatrixBase::sum() */
+ * \sa DenseBase::sum() */
const typename ReturnType<ei_member_sum>::Type sum() const
{ return _expression(); }
/** \returns a row (or column) vector expression of the mean
* of each column (or row) of the referenced expression.
*
- * \sa MatrixBase::mean() */
+ * \sa DenseBase::mean() */
const typename ReturnType<ei_member_mean>::Type mean() const
{ return _expression(); }
/** \returns a row (or column) vector expression representing
* whether \b all coefficients of each respective column (or row) are \c true.
*
- * \sa MatrixBase::all() */
+ * \sa DenseBase::all() */
const typename ReturnType<ei_member_all>::Type all() const
{ return _expression(); }
/** \returns a row (or column) vector expression representing
* whether \b at \b least one coefficient of each respective column (or row) is \c true.
*
- * \sa MatrixBase::any() */
+ * \sa DenseBase::any() */
const typename ReturnType<ei_member_any>::Type any() const
{ return _expression(); }
@@ -359,7 +359,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_count.cpp
* Output: \verbinclude PartialRedux_count.out
*
- * \sa MatrixBase::count() */
+ * \sa DenseBase::count() */
const PartialReduxExpr<ExpressionType, ei_member_count<int>, Direction> count() const
{ return _expression(); }
@@ -369,7 +369,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_prod.cpp
* Output: \verbinclude PartialRedux_prod.out
*
- * \sa MatrixBase::prod() */
+ * \sa DenseBase::prod() */
const typename ReturnType<ei_member_prod>::Type prod() const
{ return _expression(); }
@@ -380,7 +380,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include PartialRedux_reverse.cpp
* Output: \verbinclude PartialRedux_reverse.out
*
- * \sa MatrixBase::reverse() */
+ * \sa DenseBase::reverse() */
const Reverse<ExpressionType, Direction> reverse() const
{ return Reverse<ExpressionType, Direction>( _expression() ); }
@@ -393,7 +393,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
* Example: \include DirectionWise_replicate.cpp
* Output: \verbinclude DirectionWise_replicate.out
*
- * \sa VectorwiseOp::replicate(int), MatrixBase::replicate(), class Replicate
+ * \sa VectorwiseOp::replicate(int), DenseBase::replicate(), class Replicate
*/
// NOTE implemented here because of sunstudio's compilation errors
template<int Factor> const Replicate<ExpressionType,(IsVertical?Factor:1),(IsHorizontal?Factor:1)>
@@ -407,7 +407,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
/** Copies the vector \a other to each subvector of \c *this */
template<typename OtherDerived>
- ExpressionType& operator=(const MatrixBase<OtherDerived>& other)
+ ExpressionType& operator=(const DenseBase<OtherDerived>& other)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
//ei_assert((m_matrix.isNull()) == (other.isNull())); FIXME
@@ -418,21 +418,21 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
/** Adds the vector \a other to each subvector of \c *this */
template<typename OtherDerived>
- ExpressionType& operator+=(const MatrixBase<OtherDerived>& other)
+ ExpressionType& operator+=(const DenseBase<OtherDerived>& other)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
for(int j=0; j<subVectors(); ++j)
- subVector(j) += other;
+ subVector(j) += other.derived();
return const_cast<ExpressionType&>(m_matrix);
}
/** Substracts the vector \a other to each subvector of \c *this */
template<typename OtherDerived>
- ExpressionType& operator-=(const MatrixBase<OtherDerived>& other)
+ ExpressionType& operator-=(const DenseBase<OtherDerived>& other)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
for(int j=0; j<subVectors(); ++j)
- subVector(j) -= other;
+ subVector(j) -= other.derived();
return const_cast<ExpressionType&>(m_matrix);
}
@@ -441,10 +441,10 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
CwiseBinaryOp<ei_scalar_sum_op<Scalar>,
ExpressionType,
typename ExtendedType<OtherDerived>::Type>
- operator+(const MatrixBase<OtherDerived>& other) const
+ operator+(const DenseBase<OtherDerived>& other) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
- return m_matrix + extendedTo(other);
+ return m_matrix + extendedTo(other.derived());
}
/** Returns the expression of the difference between each subvector of \c *this and the vector \a other */
@@ -452,10 +452,10 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
ExpressionType,
typename ExtendedType<OtherDerived>::Type>
- operator-(const MatrixBase<OtherDerived>& other) const
+ operator-(const DenseBase<OtherDerived>& other) const
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
- return m_matrix - extendedTo(other);
+ return m_matrix - extendedTo(other.derived());
}
/////////// Geometry module ///////////
@@ -505,7 +505,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
*/
template<typename Derived>
inline const VectorwiseOp<Derived,Vertical>
-MatrixBase<Derived>::colwise() const
+DenseBase<Derived>::colwise() const
{
return derived();
}
@@ -518,7 +518,7 @@ MatrixBase<Derived>::colwise() const
*/
template<typename Derived>
inline VectorwiseOp<Derived,Vertical>
-MatrixBase<Derived>::colwise()
+DenseBase<Derived>::colwise()
{
return derived();
}
@@ -534,7 +534,7 @@ MatrixBase<Derived>::colwise()
*/
template<typename Derived>
inline const VectorwiseOp<Derived,Horizontal>
-MatrixBase<Derived>::rowwise() const
+DenseBase<Derived>::rowwise() const
{
return derived();
}
@@ -547,7 +547,7 @@ MatrixBase<Derived>::rowwise() const
*/
template<typename Derived>
inline VectorwiseOp<Derived,Horizontal>
-MatrixBase<Derived>::rowwise()
+DenseBase<Derived>::rowwise()
{
return derived();
}
diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h
index a7e74b81d..d47cc8876 100644
--- a/Eigen/src/Core/DenseBase.h
+++ b/Eigen/src/Core/DenseBase.h
@@ -30,16 +30,17 @@
*
* \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 expression
- * types). The common Eigen API for dense object is contained in this class.
+ * 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, etc.
+ * \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 AnyMatrixBase<Derived>
: 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:
@@ -266,11 +267,6 @@ template<typename Derived> class DenseBase
template<int StoreMode>
void writePacket(int index, const PacketScalar& x);
- template<typename OtherDerived>
- Derived& operator+=(const DenseBase<OtherDerived>& other);
- template<typename OtherDerived>
- Derived& operator-=(const DenseBase<OtherDerived>& other);
-
Eigen::Transpose<Derived> transpose();
const Eigen::Transpose<Derived> transpose() const;
void transposeInPlace();
@@ -385,31 +381,8 @@ template<typename Derived> class DenseBase
bool isZero(RealScalar prec = dummy_precision<Scalar>()) const;
bool isOnes(RealScalar prec = dummy_precision<Scalar>()) const;
- // FIXME
- EIGEN_STRONG_INLINE 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();
- }
- EIGEN_STRONG_INLINE 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();
- }
-
- // FIXME
-// template<typename OtherDerived>
-// inline bool operator==(const DenseBase<OtherDerived>& other) const
-// { return cwiseEqual(other).all(); }
-//
-// template<typename OtherDerived>
-// inline bool operator!=(const DenseBase<OtherDerived>& other) const
-// { return cwiseNotEqual(other).all(); }
-
+ inline Derived& operator*=(const Scalar& other);
+ inline Derived& operator/=(const Scalar& other);
/** \returns the matrix or vector obtained by evaluating this expression.
*
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index f7b32a650..8f9949b43 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -30,9 +30,9 @@
*
* \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.
*
@@ -61,10 +61,6 @@ template<typename Derived> class MatrixBase
/** Construct the base class type for the derived class OtherDerived */
template <typename OtherDerived> struct MakeBase { typedef MatrixBase<OtherDerived> Type; };
-// using DenseBase<Derived>::operator*;
-
- class InnerIterator;
-
typedef typename ei_traits<Derived>::Scalar Scalar;
typedef typename ei_packet_traits<Scalar>::type PacketScalar;
@@ -89,6 +85,7 @@ template<typename Derived> class MatrixBase
using Base::coeff;
using Base::coeffRef;
using Base::lazyAssign;
+ using Base::eval;
using Base::operator=;
using Base::operator+=;
using Base::operator-=;
@@ -96,6 +93,8 @@ template<typename Derived> class MatrixBase
using Base::operator/=;
typedef typename Base::CoeffReturnType CoeffReturnType;
+ typedef typename Base::RowXpr RowXpr;
+ typedef typename Base::ColXpr ColXpr;
#endif // not EIGEN_PARSED_BY_DOXYGEN
@@ -132,13 +131,6 @@ template<typename Derived> class MatrixBase
ei_traits<Derived>::MaxRowsAtCompileTime,
ei_traits<Derived>::MaxColsAtCompileTime
> 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 Represents a matrix with all coefficients equal to one another*/
typedef CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> ConstantReturnType;
@@ -149,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 */
@@ -286,18 +274,6 @@ template<typename Derived> class MatrixBase
inline bool operator!=(const MatrixBase<OtherDerived>& other) const
{ return cwiseNotEqual(other).all(); }
-
- /** \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);
-
NoAlias<Derived,Eigen::MatrixBase > noalias();
inline const NestByValue<Derived> nestByValue() const;
@@ -311,11 +287,6 @@ template<typename Derived> class MatrixBase
/////////// Array module ///////////
- const VectorwiseOp<Derived,Horizontal> rowwise() const;
- VectorwiseOp<Derived,Horizontal> rowwise();
- const VectorwiseOp<Derived,Vertical> colwise() const;
- VectorwiseOp<Derived,Vertical> colwise();
-
template<int p> RealScalar lpNorm() const;
ArrayWrapper<Derived> array() { return derived(); }
@@ -435,17 +406,7 @@ template<typename Derived> class MatrixBase
#endif
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)
-#endif
- }
+ MatrixBase() : Base() {}
private:
explicit MatrixBase(int);
diff --git a/Eigen/src/Core/SelfCwiseBinaryOp.h b/Eigen/src/Core/SelfCwiseBinaryOp.h
index ad5dc819b..55bd93f9e 100644
--- a/Eigen/src/Core/SelfCwiseBinaryOp.h
+++ b/Eigen/src/Core/SelfCwiseBinaryOp.h
@@ -30,12 +30,18 @@
* \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 MatrixBase<SelfCwiseBinaryOp<BinaryOp,MatrixType> >
: public MatrixType::template MakeBase< SelfCwiseBinaryOp<BinaryOp, MatrixType> >::Type
{
public:
@@ -43,7 +49,6 @@ template<typename BinaryOp, typename MatrixType> class SelfCwiseBinaryOp
typedef typename MatrixType::template MakeBase< SelfCwiseBinaryOp<BinaryOp, MatrixType> >::Type Base;
_EIGEN_DENSE_PUBLIC_INTERFACE(SelfCwiseBinaryOp)
-// EIGEN_GENERIC_PUBLIC_INTERFACE(SelfCwiseBinaryOp)
typedef typename ei_packet_traits<Scalar>::type Packet;
using Base::operator=;
@@ -114,4 +119,22 @@ template<typename BinaryOp, typename MatrixType> class SelfCwiseBinaryOp
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/Swap.h b/Eigen/src/Core/Swap.h
index 010d8bb8b..60b6fffc9 100644
--- a/Eigen/src/Core/Swap.h
+++ b/Eigen/src/Core/Swap.h
@@ -35,11 +35,12 @@ template<typename ExpressionType>
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) {}
@@ -117,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/Sparse/CoreIterators.h b/Eigen/src/Sparse/CoreIterators.h
index 1789b4f45..69780456d 100644
--- a/Eigen/src/Sparse/CoreIterators.h
+++ b/Eigen/src/Sparse/CoreIterators.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-2010 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
@@ -35,7 +35,7 @@
*/
// generic version for dense matrix and expressions
-template<typename Derived> class MatrixBase<Derived>::InnerIterator
+template<typename Derived> class DenseBase<Derived>::InnerIterator
{
typedef typename Derived::Scalar Scalar;
enum { IsRowMajor = (Derived::Flags&RowMajorBit)==RowMajorBit };