From 486fdb26a1d9fa2cd74855d3d459aeb906967b8b Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 29 May 2008 03:12:30 +0000 Subject: many small fixes and documentation improvements, this should be alpha5. --- Eigen/src/Core/Block.h | 2 +- Eigen/src/Core/CommaInitializer.h | 1 + Eigen/src/Core/CwiseNullaryOp.h | 4 ++-- Eigen/src/Core/Extract.h | 8 ++++++- Eigen/src/Core/Flagged.h | 10 ++++++++ Eigen/src/Core/InverseProduct.h | 14 +++++++++--- Eigen/src/Core/MatrixBase.h | 9 ++++---- Eigen/src/Core/Part.h | 48 +++++++++++++++++++++++++++++++++++++-- Eigen/src/Core/util/Macros.h | 1 + Eigen/src/Core/util/Meta.h | 7 ++++++ 10 files changed, 90 insertions(+), 14 deletions(-) (limited to 'Eigen/src') diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index d5b1d9de1..65b9ad649 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -497,7 +497,7 @@ inline const Block MatrixBase * Example: \include MatrixBase_block_int_int.cpp * Output: \verbinclude MatrixBase_block_int_int.out * - * \note since block is a templated member, the keyword template as to be used + * \note since block is a templated member, the keyword template has to be used * if the matrix type is also a template parameter: \code m.template block<3,3>(1,1); \endcode * * \sa class Block, block(int,int,int,int) diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h index d5e25b6e4..0a555e1b7 100644 --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -113,6 +113,7 @@ inline typename MatrixBase::CommaInitializer MatrixBase::opera return CommaInitializer(*static_cast(this), s); } +/** \sa operator<<(const Scalar&) */ template template inline typename MatrixBase::CommaInitializer diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index 66ccb40f1..009d89dec 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -218,7 +218,7 @@ MatrixBase::constant(const Scalar& value) } template -bool MatrixBase::isEqualToConstant +bool MatrixBase::isApproxToConstant (const Scalar& value, typename NumTraits::Real prec) const { for(int j = 0; j < cols(); j++) @@ -408,7 +408,7 @@ template bool MatrixBase::isOnes (typename NumTraits::Real prec) const { - return isEqualToConstant(Scalar(1), prec); + return isApproxToConstant(Scalar(1), prec); } /** Sets all coefficients in this expression to one. diff --git a/Eigen/src/Core/Extract.h b/Eigen/src/Core/Extract.h index e9323733a..ea7240ada 100755 --- a/Eigen/src/Core/Extract.h +++ b/Eigen/src/Core/Extract.h @@ -93,7 +93,13 @@ template class Extract /** \returns an expression of a triangular matrix extracted from the current matrix * - * \sa part(), marked() + * The parameter \a Mode can have the following values: \c Upper, \c StrictlyUpper, \c UnitUpper, + * \c Lower, \c StrictlyLower, \c UnitLower. + * + * Example: \include MatrixBase_extract.cpp + * Output: \verbinclude MatrixBase_extract.out + * + * \sa class Extract, part(), marked() */ template template diff --git a/Eigen/src/Core/Flagged.h b/Eigen/src/Core/Flagged.h index 925066533..54a081f1e 100644 --- a/Eigen/src/Core/Flagged.h +++ b/Eigen/src/Core/Flagged.h @@ -101,6 +101,11 @@ template clas }; /** \returns an expression of *this with added flags + * + * Example: \include MatrixBase_marked.cpp + * Output: \verbinclude MatrixBase_marked.out + * + * \sa class Flagged, extract(), part() */ template template @@ -112,6 +117,11 @@ MatrixBase::marked() const /** \returns an expression of *this with the following flags removed: * EvalBeforeNestingBit and EvalBeforeAssigningBit. + * + * Example: \include MatrixBase_lazy.cpp + * Output: \verbinclude MatrixBase_lazy.out + * + * \sa class Flagged, marked() */ template inline const Flagged diff --git a/Eigen/src/Core/InverseProduct.h b/Eigen/src/Core/InverseProduct.h index 057590259..4a3579bbf 100755 --- a/Eigen/src/Core/InverseProduct.h +++ b/Eigen/src/Core/InverseProduct.h @@ -25,11 +25,19 @@ #ifndef EIGEN_INVERSEPRODUCT_H #define EIGEN_INVERSEPRODUCT_H -/** \returns the product of the inverse of *this with \a other. +/** \returns the product of the inverse of \c *this with \a other. * - * This function computes the inverse-matrix matrix product inverse(*this) * \a other - * It works as a forward (resp. backward) substitution if *this is an upper (resp. lower) + * This function computes the inverse-matrix matrix product inverse(\c*this) * \a other + * It works as a forward (resp. backward) substitution if \c *this is an upper (resp. lower) * triangular matrix. + * + * It is required that \c *this be marked as either an upper or a lower triangular matrix, as + * can be done by marked(), and as is automatically the case with expressions such as those returned + * by extract(). + * Example: \include MatrixBase_marked.cpp + * Output: \verbinclude MatrixBase_marked.out + * + * \sa marked(), extract() */ template template diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 27d60d078..82d11f16e 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -136,10 +136,10 @@ template class MatrixBase CoeffReadCost = ei_traits::CoeffReadCost }; + /** Default constructor. Just checks at compile-time for self-consistency of the flags. */ MatrixBase() { - assert(!( (Flags&UnitDiagBit && Flags&ZeroDiagBit) - || (Flags&UpperTriangularBit && Flags&LowerTriangularBit) )); + ei_assert(ei_are_flags_consistent::ret); } /** This is the "real scalar" type; if the \a Scalar type is already real numbers @@ -170,7 +170,7 @@ template class MatrixBase inline bool isVector() const { return rows()==1 || cols()==1; } //@} - /// \name Default return types + /// \internal \name Default return types //@{ /** Represents a constant matrix */ typedef CwiseNullaryOp,Derived> ConstantReturnType; @@ -289,7 +289,6 @@ template class MatrixBase template typename OtherDerived::Eval inverseProduct(const MatrixBase& other) const; - //@} /** \name Dot product and related notions @@ -420,7 +419,7 @@ template class MatrixBase bool isMuchSmallerThan(const MatrixBase& other, RealScalar prec = precision()) const; - bool isEqualToConstant(const Scalar& value, RealScalar prec = precision()) const; + bool isApproxToConstant(const Scalar& value, RealScalar prec = precision()) const; bool isZero(RealScalar prec = precision()) const; bool isOnes(RealScalar prec = precision()) const; bool isIdentity(RealScalar prec = precision()) const; diff --git a/Eigen/src/Core/Part.h b/Eigen/src/Core/Part.h index 74c29f203..647e6cf2d 100644 --- a/Eigen/src/Core/Part.h +++ b/Eigen/src/Core/Part.h @@ -26,33 +26,67 @@ #ifndef EIGEN_PART_H #define EIGEN_PART_H +/** \class Part + * + * \brief Pseudo-expression allowing to write to a special part of a matrix + * + * This lvalue-only pseudo-expression allows to perform special operations + * on a matrix, such as writing only to the upper (above diagonal) part. + * + * It is the return type of MatrixBase::part() and most of the time this is + * the only way that it is used. + * + * \sa class Extract, MatrixBase::part() + */ template class Part { public: - Part(MatrixType& matrix) : m_matrix(matrix) {} + Part(MatrixType& matrix); + /** \sa operator=(), MatrixBase::lazyAssign() */ template void lazyAssign(const Other& other); + /** \sa MatrixBase::operator=() */ template void operator=(const Other& other); + /** \sa MatrixBase::operator+=() */ template void operator+=(const Other& other); + /** \sa MatrixBase::operator-=() */ template void operator-=(const Other& other); + /** \sa MatrixBase::operator*=() */ void operator*=(const typename ei_traits::Scalar& other); + /** \sa MatrixBase::operator/=() */ void operator/=(const typename ei_traits::Scalar& other); + /** \sa MatrixBase::setConstant() */ void setConstant(const typename ei_traits::Scalar& value); + /** \sa MatrixBase::setZero() */ void setZero(); + /** \sa MatrixBase::setOnes() */ void setOnes(); + /** \sa MatrixBase::setRandom() */ void setRandom(); + /** \sa MatrixBase::setIdentity() */ void setIdentity(); private: MatrixType& m_matrix; }; +template +inline Part::Part(MatrixType& matrix) + : m_matrix(matrix) +{ + ei_assert(ei_are_flags_consistent::ret); +} + template template inline void Part::operator=(const Other& other) { if(Other::Flags & EvalBeforeAssigningBit) - lazyAssign(other.eval()); + { + typename ei_eval::type other_evaluated(other.rows(), other.cols()); + other_evaluated.template part().lazyAssign(other); + lazyAssign(other_evaluated); + } else lazyAssign(other.derived()); } @@ -210,6 +244,16 @@ inline void Part::setRandom() *this = MatrixType::random(m_matrix.rows(), m_matrix.cols()); } +/** \returns a lvalue pseudo-expression allowing to perform special operations on \c *this. + * + * The \a Mode parameter can have the following values: \c Upper, \c StrictlyUpper, \c Lower, + * \c StrictlyLower, \c SelfAdjoint. + * + * Example: \include MatrixBase_part.cpp + * Output: \verbinclude MatrixBase_part.out + * + * \sa class Part, MatrixBase::extract(), MatrixBase::marked() + */ template template inline Part MatrixBase::part() diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index a31e73bb9..717e3e072 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -135,6 +135,7 @@ typedef typename Eigen::NumTraits::Real RealScalar; \ typedef typename Base::PacketScalar PacketScalar; \ typedef typename Eigen::ei_nested::type Nested; \ typedef typename Eigen::ei_eval::type Eval; \ +typedef typename Eigen::Inverse InverseType; \ enum { RowsAtCompileTime = Base::RowsAtCompileTime, \ ColsAtCompileTime = Base::ColsAtCompileTime, \ MaxRowsAtCompileTime = Base::MaxRowsAtCompileTime, \ diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index f1edf7d6f..792f65b33 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -210,4 +210,11 @@ template struct ei_nested >::ret type; }; +template struct ei_are_flags_consistent +{ + enum { ret = !( (Flags&UnitDiagBit && Flags&ZeroDiagBit) + || (Flags&UpperTriangularBit && Flags&LowerTriangularBit) ) + }; +}; + #endif // EIGEN_META_H -- cgit v1.2.3