diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-07-21 00:34:46 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-07-21 00:34:46 +0000 |
commit | c10f069b6b9f0dd4bb313341d1969bd7e1cf9338 (patch) | |
tree | 95934f5bc632a391dfa149783226b1543b24ff41 /Eigen | |
parent | ce425d92f1c1d199c8428c46b4c4ea3be81b137b (diff) |
* Merge Extract and Part to the Part expression.
Renamed "MatrixBase::extract() const" to "MatrixBase::part() const"
* Renamed static functions identity, zero, ones, random with an upper case
first letter: Identity, Zero, Ones and Random.
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/Core | 1 | ||||
-rw-r--r-- | Eigen/src/Array/Random.h | 8 | ||||
-rw-r--r-- | Eigen/src/Cholesky/Cholesky.h | 6 | ||||
-rw-r--r-- | Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/CwiseNullaryOp.h | 92 | ||||
-rwxr-xr-x | Eigen/src/Core/Extract.h | 155 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 30 | ||||
-rw-r--r-- | Eigen/src/Core/Part.h | 243 | ||||
-rw-r--r-- | Eigen/src/Core/util/StaticAssert.h | 5 | ||||
-rw-r--r-- | Eigen/src/Geometry/Quaternion.h | 8 | ||||
-rw-r--r-- | Eigen/src/Geometry/Transform.h | 8 | ||||
-rw-r--r-- | Eigen/src/LU/Inverse.h | 2 | ||||
-rwxr-xr-x | Eigen/src/QR/HessenbergDecomposition.h | 2 | ||||
-rw-r--r-- | Eigen/src/QR/QR.h | 6 | ||||
-rw-r--r-- | Eigen/src/QR/SelfAdjointEigenSolver.h | 2 | ||||
-rwxr-xr-x | Eigen/src/QR/Tridiagonalization.h | 4 |
16 files changed, 255 insertions, 321 deletions
diff --git a/Eigen/Core b/Eigen/Core index 6c6de3ab5..a233222e0 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -57,7 +57,6 @@ namespace Eigen { #include "src/Core/IO.h" #include "src/Core/Swap.h" #include "src/Core/CommaInitializer.h" -#include "src/Core/Extract.h" #include "src/Core/Part.h" #include "src/Core/CacheFriendlyProduct.h" diff --git a/Eigen/src/Array/Random.h b/Eigen/src/Array/Random.h index 97a34433a..9f3a916cf 100644 --- a/Eigen/src/Array/Random.h +++ b/Eigen/src/Array/Random.h @@ -53,7 +53,7 @@ struct ei_functor_traits<ei_scalar_random_op<Scalar> > */ template<typename Derived> inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> -MatrixBase<Derived>::random(int rows, int cols) +MatrixBase<Derived>::Random(int rows, int cols) { return NullaryExpr(rows, cols, ei_scalar_random_op<Scalar>()); } @@ -78,7 +78,7 @@ MatrixBase<Derived>::random(int rows, int cols) */ template<typename Derived> inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> -MatrixBase<Derived>::random(int size) +MatrixBase<Derived>::Random(int size) { return NullaryExpr(size, ei_scalar_random_op<Scalar>()); } @@ -98,7 +98,7 @@ MatrixBase<Derived>::random(int size) */ template<typename Derived> inline const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> -MatrixBase<Derived>::random() +MatrixBase<Derived>::Random() { return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>()); } @@ -115,7 +115,7 @@ MatrixBase<Derived>::random() template<typename Derived> inline Derived& MatrixBase<Derived>::setRandom() { - return *this = random(rows(), cols()); + return *this = Random(rows(), cols()); } #endif // EIGEN_RANDOM_H diff --git a/Eigen/src/Cholesky/Cholesky.h b/Eigen/src/Cholesky/Cholesky.h index dd4fc6e38..5c5e6cfc7 100644 --- a/Eigen/src/Cholesky/Cholesky.h +++ b/Eigen/src/Cholesky/Cholesky.h @@ -58,7 +58,7 @@ template<typename MatrixType> class Cholesky compute(matrix); } - Extract<MatrixType, Lower> matrixL(void) const + Part<MatrixType, Lower> matrixL(void) const { return m_matrix; } @@ -79,7 +79,7 @@ template<typename MatrixType> class Cholesky bool m_isPositiveDefinite; }; -/** Compute / recompute the Cholesky decomposition A = LL^* = U^*U of \a matrix +/** Computes / recomputes the Cholesky decomposition A = LL^* = U^*U of \a matrix */ template<typename MatrixType> void Cholesky<MatrixType>::compute(const MatrixType& a) @@ -124,7 +124,7 @@ typename Derived::Eval Cholesky<MatrixType>::solve(const MatrixBase<Derived> &b) const int size = m_matrix.rows(); ei_assert(size==b.rows()); - return m_matrix.adjoint().template extract<Upper>().inverseProduct(matrixL().inverseProduct(b)); + return m_matrix.adjoint().template part<Upper>().inverseProduct(matrixL().inverseProduct(b)); } /** \cholesky_module diff --git a/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h b/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h index 2572b88a2..0dcedf0dc 100644 --- a/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h +++ b/Eigen/src/Cholesky/CholeskyWithoutSquareRoot.h @@ -58,7 +58,7 @@ template<typename MatrixType> class CholeskyWithoutSquareRoot } /** \returns the lower triangular matrix L */ - Extract<MatrixType, UnitLower> matrixL(void) const + Part<MatrixType, UnitLower> matrixL(void) const { return m_matrix; } @@ -136,7 +136,7 @@ typename Derived::Eval CholeskyWithoutSquareRoot<MatrixType>::solve(const Matrix const int size = m_matrix.rows(); ei_assert(size==b.rows()); - return m_matrix.adjoint().template extract<UnitUpper>() + return m_matrix.adjoint().template part<UnitUpper>() .inverseProduct( (matrixL() .inverseProduct(b)) diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index 6df351201..343be79a1 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -32,7 +32,7 @@ * \param NullaryOp template functor implementing the operator * * This class represents an expression of a generic nullary operator. - * It is the return type of the ones(), zero(), constant(), identity() and random() functions, + * It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() functions, * and most of the time this is the only way it is used. * * However, if you want to write a function returning such an expression, you @@ -113,7 +113,7 @@ class CwiseNullaryOp : ei_no_assignment_operator, * the returned matrix. Must be compatible with this MatrixBase type. * * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so zero() should be used + * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used * instead. * * The template parameter \a CustomNullaryOp is the type of the functor. @@ -136,7 +136,7 @@ MatrixBase<Derived>::NullaryExpr(int rows, int cols, const CustomNullaryOp& func * \only_for_vectors * * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so zero() should be used + * it is redundant to pass \a size as argument, so Zero() should be used * instead. * * The template parameter \a CustomNullaryOp is the type of the functor. @@ -176,7 +176,7 @@ MatrixBase<Derived>::NullaryExpr(const CustomNullaryOp& func) * the returned matrix. Must be compatible with this MatrixBase type. * * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so zero() should be used + * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used * instead. * * The template parameter \a CustomNullaryOp is the type of the functor. @@ -185,7 +185,7 @@ MatrixBase<Derived>::NullaryExpr(const CustomNullaryOp& func) */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::constant(int rows, int cols, const Scalar& value) +MatrixBase<Derived>::Constant(int rows, int cols, const Scalar& value) { return NullaryExpr(rows, cols, ei_scalar_constant_op<Scalar>(value)); } @@ -198,7 +198,7 @@ MatrixBase<Derived>::constant(int rows, int cols, const Scalar& value) * \only_for_vectors * * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so zero() should be used + * it is redundant to pass \a size as argument, so Zero() should be used * instead. * * The template parameter \a CustomNullaryOp is the type of the functor. @@ -207,7 +207,7 @@ MatrixBase<Derived>::constant(int rows, int cols, const Scalar& value) */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::constant(int size, const Scalar& value) +MatrixBase<Derived>::Constant(int size, const Scalar& value) { return NullaryExpr(size, ei_scalar_constant_op<Scalar>(value)); } @@ -223,7 +223,7 @@ MatrixBase<Derived>::constant(int size, const Scalar& value) */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::constant(const Scalar& value) +MatrixBase<Derived>::Constant(const Scalar& value) { EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value)); @@ -242,12 +242,12 @@ bool MatrixBase<Derived>::isApproxToConstant /** Sets all coefficients in this expression to \a value. * - * \sa class CwiseNullaryOp, zero(), ones() + * \sa class CwiseNullaryOp, Zero(), Ones() */ template<typename Derived> Derived& MatrixBase<Derived>::setConstant(const Scalar& value) { - return *this = constant(rows(), cols(), value); + return derived() = Constant(rows(), cols(), value); } // zero: @@ -258,7 +258,7 @@ Derived& MatrixBase<Derived>::setConstant(const Scalar& value) * the returned matrix. Must be compatible with this MatrixBase type. * * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so zero() should be used + * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used * instead. * * \addexample Zero \label How to take get a zero matrix @@ -266,13 +266,13 @@ Derived& MatrixBase<Derived>::setConstant(const Scalar& value) * Example: \include MatrixBase_zero_int_int.cpp * Output: \verbinclude MatrixBase_zero_int_int.out * - * \sa zero(), zero(int) + * \sa Zero(), Zero(int) */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::zero(int rows, int cols) +MatrixBase<Derived>::Zero(int rows, int cols) { - return constant(rows, cols, Scalar(0)); + return Constant(rows, cols, Scalar(0)); } /** \returns an expression of a zero vector. @@ -283,19 +283,19 @@ MatrixBase<Derived>::zero(int rows, int cols) * \only_for_vectors * * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so zero() should be used + * it is redundant to pass \a size as argument, so Zero() should be used * instead. * * Example: \include MatrixBase_zero_int.cpp * Output: \verbinclude MatrixBase_zero_int.out * - * \sa zero(), zero(int,int) + * \sa Zero(), Zero(int,int) */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::zero(int size) +MatrixBase<Derived>::Zero(int size) { - return constant(size, Scalar(0)); + return Constant(size, Scalar(0)); } /** \returns an expression of a fixed-size zero matrix or vector. @@ -306,13 +306,13 @@ MatrixBase<Derived>::zero(int size) * Example: \include MatrixBase_zero.cpp * Output: \verbinclude MatrixBase_zero.out * - * \sa zero(int), zero(int,int) + * \sa Zero(int), Zero(int,int) */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::zero() +MatrixBase<Derived>::Zero() { - return constant(Scalar(0)); + return Constant(Scalar(0)); } /** \returns true if *this is approximately equal to the zero matrix, @@ -321,7 +321,7 @@ MatrixBase<Derived>::zero() * Example: \include MatrixBase_isZero.cpp * Output: \verbinclude MatrixBase_isZero.out * - * \sa class CwiseNullaryOp, zero() + * \sa class CwiseNullaryOp, Zero() */ template<typename Derived> bool MatrixBase<Derived>::isZero @@ -339,7 +339,7 @@ bool MatrixBase<Derived>::isZero * Example: \include MatrixBase_setZero.cpp * Output: \verbinclude MatrixBase_setZero.out * - * \sa class CwiseNullaryOp, zero() + * \sa class CwiseNullaryOp, Zero() */ template<typename Derived> Derived& MatrixBase<Derived>::setZero() @@ -355,7 +355,7 @@ Derived& MatrixBase<Derived>::setZero() * the returned matrix. Must be compatible with this MatrixBase type. * * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so ones() should be used + * it is redundant to pass \a rows and \a cols as arguments, so Ones() should be used * instead. * * \addexample One \label How to get a matrix with all coefficients equal one @@ -363,13 +363,13 @@ Derived& MatrixBase<Derived>::setZero() * Example: \include MatrixBase_ones_int_int.cpp * Output: \verbinclude MatrixBase_ones_int_int.out * - * \sa ones(), ones(int), isOnes(), class Ones + * \sa Ones(), Ones(int), isOnes(), class Ones */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::ones(int rows, int cols) +MatrixBase<Derived>::Ones(int rows, int cols) { - return constant(rows, cols, Scalar(1)); + return Constant(rows, cols, Scalar(1)); } /** \returns an expression of a vector where all coefficients equal one. @@ -380,19 +380,19 @@ MatrixBase<Derived>::ones(int rows, int cols) * \only_for_vectors * * This variant is meant to be used for dynamic-size vector types. For fixed-size types, - * it is redundant to pass \a size as argument, so ones() should be used + * it is redundant to pass \a size as argument, so Ones() should be used * instead. * * Example: \include MatrixBase_ones_int.cpp * Output: \verbinclude MatrixBase_ones_int.out * - * \sa ones(), ones(int,int), isOnes(), class Ones + * \sa Ones(), Ones(int,int), isOnes(), class Ones */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::ones(int size) +MatrixBase<Derived>::Ones(int size) { - return constant(size, Scalar(1)); + return Constant(size, Scalar(1)); } /** \returns an expression of a fixed-size matrix or vector where all coefficients equal one. @@ -403,13 +403,13 @@ MatrixBase<Derived>::ones(int size) * Example: \include MatrixBase_ones.cpp * Output: \verbinclude MatrixBase_ones.out * - * \sa ones(int), ones(int,int), isOnes(), class Ones + * \sa Ones(int), Ones(int,int), isOnes(), class Ones */ template<typename Derived> const typename MatrixBase<Derived>::ConstantReturnType -MatrixBase<Derived>::ones() +MatrixBase<Derived>::Ones() { - return constant(Scalar(1)); + return Constant(Scalar(1)); } /** \returns true if *this is approximately equal to the matrix where all coefficients @@ -418,7 +418,7 @@ MatrixBase<Derived>::ones() * Example: \include MatrixBase_isOnes.cpp * Output: \verbinclude MatrixBase_isOnes.out * - * \sa class CwiseNullaryOp, ones() + * \sa class CwiseNullaryOp, Ones() */ template<typename Derived> bool MatrixBase<Derived>::isOnes @@ -432,7 +432,7 @@ bool MatrixBase<Derived>::isOnes * Example: \include MatrixBase_setOnes.cpp * Output: \verbinclude MatrixBase_setOnes.out * - * \sa class CwiseNullaryOp, ones() + * \sa class CwiseNullaryOp, Ones() */ template<typename Derived> Derived& MatrixBase<Derived>::setOnes() @@ -448,7 +448,7 @@ Derived& MatrixBase<Derived>::setOnes() * the returned matrix. Must be compatible with this MatrixBase type. * * This variant is meant to be used for dynamic-size matrix types. For fixed-size types, - * it is redundant to pass \a rows and \a cols as arguments, so identity() should be used + * it is redundant to pass \a rows and \a cols as arguments, so Identity() should be used * instead. * * \addexample Identity \label How to get an identity matrix @@ -456,11 +456,11 @@ Derived& MatrixBase<Derived>::setOnes() * Example: \include MatrixBase_identity_int_int.cpp * Output: \verbinclude MatrixBase_identity_int_int.out * - * \sa identity(), setIdentity(), isIdentity() + * \sa Identity(), setIdentity(), isIdentity() */ template<typename Derived> inline const typename MatrixBase<Derived>::IdentityReturnType -MatrixBase<Derived>::identity(int rows, int cols) +MatrixBase<Derived>::Identity(int rows, int cols) { return NullaryExpr(rows, cols, ei_scalar_identity_op<Scalar>()); } @@ -473,11 +473,11 @@ MatrixBase<Derived>::identity(int rows, int cols) * Example: \include MatrixBase_identity.cpp * Output: \verbinclude MatrixBase_identity.out * - * \sa identity(int,int), setIdentity(), isIdentity() + * \sa Identity(int,int), setIdentity(), isIdentity() */ template<typename Derived> inline const typename MatrixBase<Derived>::IdentityReturnType -MatrixBase<Derived>::identity() +MatrixBase<Derived>::Identity() { EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived) return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_identity_op<Scalar>()); @@ -490,7 +490,7 @@ MatrixBase<Derived>::identity() * Example: \include MatrixBase_isIdentity.cpp * Output: \verbinclude MatrixBase_isIdentity.out * - * \sa class CwiseNullaryOp, identity(), identity(int,int), setIdentity() + * \sa class CwiseNullaryOp, Identity(), Identity(int,int), setIdentity() */ template<typename Derived> bool MatrixBase<Derived>::isIdentity @@ -520,12 +520,12 @@ bool MatrixBase<Derived>::isIdentity * Example: \include MatrixBase_setIdentity.cpp * Output: \verbinclude MatrixBase_setIdentity.out * - * \sa class CwiseNullaryOp, identity(), identity(int,int), isIdentity() + * \sa class CwiseNullaryOp, Identity(), Identity(int,int), isIdentity() */ template<typename Derived> inline Derived& MatrixBase<Derived>::setIdentity() { - return *this = identity(rows(), cols()); + return derived() = Identity(rows(), cols()); } /** \returns an expression of the i-th unit (basis) vector. @@ -538,7 +538,7 @@ template<typename Derived> const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(int size, int i) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); - return BasisReturnType(SquareMatrixType::identity(size,size), i); + return BasisReturnType(SquareMatrixType::Identity(size,size), i); } /** \returns an expression of the i-th unit (basis) vector. @@ -553,7 +553,7 @@ template<typename Derived> const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(int i) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); - return BasisReturnType(SquareMatrixType::identity(),i); + return BasisReturnType(SquareMatrixType::Identity(),i); } /** \returns an expression of the X axis unit vector (1{,0}^*) diff --git a/Eigen/src/Core/Extract.h b/Eigen/src/Core/Extract.h deleted file mode 100755 index ff84d0ece..000000000 --- a/Eigen/src/Core/Extract.h +++ /dev/null @@ -1,155 +0,0 @@ -// This file is part of Eigen, a lightweight C++ template library -// for linear algebra. Eigen itself is part of the KDE project. -// -// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr> -// Copyright (C) 2008 Benoit Jacob <jacob@math.jussieu.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_EXTRACT_H -#define EIGEN_EXTRACT_H - -/** \class Extract - * - * \brief Expression of a triangular matrix extracted from a given matrix - * - * \param MatrixType the type of the object in which we are taking the triangular part - * \param Mode the kind of triangular matrix expression to construct. Can be Upper, StrictlyUpper, - * UnitUpper, Lower, StrictlyLower, UnitLower. This is in fact a bit field; it must have either - * UpperTriangularBit or LowerTriangularBit, and additionnaly it may have either ZeroDiagBit or - * UnitDiagBit. - * - * This class represents an expression of the upper or lower triangular part of - * a square matrix, possibly with a further assumption on the diagonal. It is the return type - * of MatrixBase::extract() and most of the time this is the only way it is used. - * - * \sa MatrixBase::extract() - */ -template<typename MatrixType, unsigned int Mode> -struct ei_traits<Extract<MatrixType, Mode> > -{ - typedef typename MatrixType::Scalar Scalar; - typedef typename ei_nested<MatrixType>::type MatrixTypeNested; - typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; - enum { - RowsAtCompileTime = MatrixType::RowsAtCompileTime, - ColsAtCompileTime = MatrixType::ColsAtCompileTime, - MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - Flags = (_MatrixTypeNested::Flags & ~(PacketAccessBit | LinearAccessBit | DirectAccessBit)) | Mode, - CoeffReadCost = _MatrixTypeNested::CoeffReadCost - }; -}; - -template<typename MatrixType, unsigned int Mode> class Extract - : public MatrixBase<Extract<MatrixType, Mode> > -{ - public: - - EIGEN_GENERIC_PUBLIC_INTERFACE(Extract) - - inline Extract(const MatrixType& matrix) : m_matrix(matrix) {} - - EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Extract) - - inline int rows() const { return m_matrix.rows(); } - inline int cols() const { return m_matrix.cols(); } - - inline Scalar coeff(int row, int col) const - { - if(Flags & LowerTriangularBit ? col>row : row>col) - return (Flags & SelfAdjointBit) ? ei_conj(m_matrix.coeff(col, row)) : (Scalar)0; - if(Flags & UnitDiagBit) - return col==row ? (Scalar)1 : m_matrix.coeff(row, col); - else if(Flags & ZeroDiagBit) - return col==row ? (Scalar)0 : m_matrix.coeff(row, col); - else - return m_matrix.coeff(row, col); - } - - protected: - - const typename MatrixType::Nested m_matrix; -}; - -/** \returns an expression of a triangular matrix extracted from the current matrix - * - * The parameter \a Mode can have the following values: \c Upper, \c StrictlyUpper, \c UnitUpper, - * \c Lower, \c StrictlyLower, \c UnitLower. - * - * \addexample ExtractExample \label How to extract a triangular part of an arbitrary matrix - * - * Example: \include MatrixBase_extract.cpp - * Output: \verbinclude MatrixBase_extract.out - * - * \sa class Extract, part(), marked() - */ -template<typename Derived> -template<unsigned int Mode> -const Extract<Derived, Mode> MatrixBase<Derived>::extract() const -{ - return derived(); -} - -/** \returns true if *this is approximately equal to an upper triangular matrix, - * within the precision given by \a prec. - * - * \sa isLower(), extract(), part(), marked() - */ -template<typename Derived> -bool MatrixBase<Derived>::isUpper(RealScalar prec) const -{ - if(cols() != rows()) return false; - RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1); - for(int j = 0; j < cols(); j++) - for(int i = 0; i <= j; i++) - { - RealScalar absValue = ei_abs(coeff(i,j)); - if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue; - } - for(int j = 0; j < cols()-1; j++) - for(int i = j+1; i < rows(); i++) - if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnUpperPart, prec)) return false; - return true; -} - -/** \returns true if *this is approximately equal to a lower triangular matrix, - * within the precision given by \a prec. - * - * \sa isUpper(), extract(), part(), marked() - */ -template<typename Derived> -bool MatrixBase<Derived>::isLower(RealScalar prec) const -{ - if(cols() != rows()) return false; - RealScalar maxAbsOnLowerPart = static_cast<RealScalar>(-1); - for(int j = 0; j < cols(); j++) - for(int i = j; i < rows(); i++) - { - RealScalar absValue = ei_abs(coeff(i,j)); - if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue; - } - for(int j = 1; j < cols(); j++) - for(int i = 0; i < j; i++) - if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnLowerPart, prec)) return false; - return true; -} - -#endif // EIGEN_EXTRACT_H diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index bd4b64b05..78bab6163 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -376,15 +376,15 @@ template<typename Derived> class MatrixBase const DiagonalCoeffs<Derived> diagonal() const; template<unsigned int Mode> Part<Derived, Mode> part(); - template<unsigned int Mode> const Extract<Derived, Mode> extract() const; + template<unsigned int Mode> const Part<Derived, Mode> part() const; static const ConstantReturnType - constant(int rows, int cols, const Scalar& value); + Constant(int rows, int cols, const Scalar& value); static const ConstantReturnType - constant(int size, const Scalar& value); + Constant(int size, const Scalar& value); static const ConstantReturnType - constant(const Scalar& value); + Constant(const Scalar& value); template<typename CustomNullaryOp> static const CwiseNullaryOp<CustomNullaryOp, Derived> @@ -396,14 +396,14 @@ template<typename Derived> class MatrixBase static const CwiseNullaryOp<CustomNullaryOp, Derived> NullaryExpr(const CustomNullaryOp& func); - static const ConstantReturnType zero(int rows, int cols); - static const ConstantReturnType zero(int size); - static const ConstantReturnType zero(); - static const ConstantReturnType ones(int rows, int cols); - static const ConstantReturnType ones(int size); - static const ConstantReturnType ones(); - static const IdentityReturnType identity(); - static const IdentityReturnType identity(int rows, int cols); + static const ConstantReturnType Zero(int rows, int cols); + static const ConstantReturnType Zero(int size); + static const ConstantReturnType Zero(); + static const ConstantReturnType Ones(int rows, int cols); + static const ConstantReturnType Ones(int size); + static const ConstantReturnType Ones(); + static const IdentityReturnType Identity(); + static const IdentityReturnType Identity(int rows, int cols); static const BasisReturnType Unit(int size, int i); static const BasisReturnType Unit(int i); static const BasisReturnType UnitX(); @@ -521,9 +521,9 @@ template<typename Derived> class MatrixBase const PartialRedux<Derived,Horizontal> rowwise() const; const PartialRedux<Derived,Vertical> colwise() const; - static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random(int rows, int cols); - static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random(int size); - static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random(); + static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int rows, int cols); + static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(int size); + static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> Random(); /////////// LU module /////////// diff --git a/Eigen/src/Core/Part.h b/Eigen/src/Core/Part.h index a0553923a..cd349855d 100644 --- a/Eigen/src/Core/Part.h +++ b/Eigen/src/Core/Part.h @@ -28,58 +28,120 @@ /** \class Part * - * \brief Pseudo-expression allowing to write to a special part of a matrix + * \brief Expression of a triangular matrix extracted from a given matrix * - * This lvalue-only pseudo-expression allows to perform special operations - * on a matrix, such as writing only to the upper (above diagonal) part. + * \param MatrixType the type of the object in which we are taking the triangular part + * \param Mode the kind of triangular matrix expression to construct. Can be Upper, StrictlyUpper, + * UnitUpper, Lower, StrictlyLower, UnitLower. This is in fact a bit field; it must have either + * UpperTriangularBit or LowerTriangularBit, and additionnaly it may have either ZeroDiagBit or + * UnitDiagBit. * - * It is the return type of MatrixBase::part() and most of the time this is - * the only way that it is used. + * This class represents an expression of the upper or lower triangular part of + * a square matrix, possibly with a further assumption on the diagonal. It is the return type + * of MatrixBase::part() and most of the time this is the only way it is used. * - * \sa class Extract, MatrixBase::part() + * \sa MatrixBase::part() */ template<typename MatrixType, unsigned int Mode> -class Part +struct ei_traits<Part<MatrixType, Mode> > +{ + typedef typename MatrixType::Scalar Scalar; + typedef typename ei_nested<MatrixType>::type MatrixTypeNested; + typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested; + enum { + RowsAtCompileTime = MatrixType::RowsAtCompileTime, + ColsAtCompileTime = MatrixType::ColsAtCompileTime, + MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, + MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, + Flags = (_MatrixTypeNested::Flags & ~(PacketAccessBit | LinearAccessBit | DirectAccessBit)) | Mode, + CoeffReadCost = _MatrixTypeNested::CoeffReadCost + }; +}; + +template<typename MatrixType, unsigned int Mode> class Part + : public MatrixBase<Part<MatrixType, Mode> > { public: - Part(MatrixType& matrix); - /** \sa operator=(), MatrixBase::lazyAssign() */ - template<typename Other> void lazyAssign(const Other& other); - /** \sa MatrixBase::operator=() */ - template<typename Other> void operator=(const Other& other); + + EIGEN_GENERIC_PUBLIC_INTERFACE(Part) + + inline Part(const MatrixType& matrix) : m_matrix(matrix) + { ei_assert(ei_are_flags_consistent<Mode>::ret); } + /** \sa MatrixBase::operator+=() */ - template<typename Other> void operator+=(const Other& other); + template<typename Other> Part& operator+=(const Other& other); /** \sa MatrixBase::operator-=() */ - template<typename Other> void operator-=(const Other& other); + template<typename Other> Part& operator-=(const Other& other); /** \sa MatrixBase::operator*=() */ - void operator*=(const typename ei_traits<MatrixType>::Scalar& other); + Part& operator*=(const typename ei_traits<MatrixType>::Scalar& other); /** \sa MatrixBase::operator/=() */ - void operator/=(const typename ei_traits<MatrixType>::Scalar& other); - /** \sa MatrixBase::setConstant() */ - void setConstant(const typename ei_traits<MatrixType>::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; + Part& operator/=(const typename ei_traits<MatrixType>::Scalar& other); + + /** \sa operator=(), MatrixBase::lazyAssign() */ + template<typename Other> void lazyAssign(const Other& other); + /** \sa MatrixBase::operator=() */ + template<typename Other> Part& operator=(const Other& other); + + inline int rows() const { return m_matrix.rows(); } + inline int cols() const { return m_matrix.cols(); } + + inline Scalar coeff(int row, int col) const + { + if(Flags & LowerTriangularBit ? col>row : row>col) + return (Flags & SelfAdjointBit) ? ei_conj(m_matrix.coeff(col, row)) : (Scalar)0; + if(Flags & UnitDiagBit) + return col==row ? (Scalar)1 : m_matrix.coeff(row, col); + else if(Flags & ZeroDiagBit) + return col==row ? (Scalar)0 : m_matrix.coeff(row, col); + else + return m_matrix.coeff(row, col); + } + + inline Scalar coeffRef(int row, int col) const + { + EIGEN_STATIC_ASSERT(!(Flags & UnitDiagBit), writting_to_triangular_part_with_unit_diag_is_not_supported); + EIGEN_STATIC_ASSERT(!(Flags & SelfAdjointBit), default_writting_to_selfadjoint_not_supported); + ei_assert( (Mode==Upper && col>=row) + || (Mode==Lower && col<=row) + || (Mode==StrictlyUpper && col>row) + || (Mode==StrictlyLower && col<row)); + return m_matrix.coeffRef(row, col); + } + + /** discard any writes to a row */ + const Block<Part, 1, ColsAtCompileTime> row(int i) { return Base::row(i); } + const Block<Part, 1, ColsAtCompileTime> row(int i) const { return Base::row(i); } + /** discard any writes to a column */ + const Block<Part, RowsAtCompileTime, 1> col(int i) { return Base::col(i); } + const Block<Part, RowsAtCompileTime, 1> col(int i) const { return Base::col(i); } + + protected: + + const typename MatrixType::Nested m_matrix; }; -template<typename MatrixType, unsigned int Mode> -inline Part<MatrixType, Mode>::Part(MatrixType& matrix) - : m_matrix(matrix) +/** \returns an expression of a triangular matrix extracted from the current matrix + * + * The parameter \a Mode can have the following values: \c Upper, \c StrictlyUpper, \c UnitUpper, + * \c Lower, \c StrictlyLower, \c UnitLower. + * + * \addexample PartExample \label How to extract a triangular part of an arbitrary matrix + * + * Example: \include MatrixBase_extract.cpp + * Output: \verbinclude MatrixBase_extract.out + * + * \sa class Part, part(), marked() + */ +template<typename Derived> +template<unsigned int Mode> +const Part<Derived, Mode> MatrixBase<Derived>::part() const { - ei_assert(ei_are_flags_consistent<Mode>::ret); + return derived(); } template<typename MatrixType, unsigned int Mode> template<typename Other> -inline void Part<MatrixType, Mode>::operator=(const Other& other) +inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator=(const Other& other) { if(Other::Flags & EvalBeforeAssigningBit) { @@ -89,6 +151,7 @@ inline void Part<MatrixType, Mode>::operator=(const Other& other) } else lazyAssign(other.derived()); + return *this; } template<typename Derived1, typename Derived2, unsigned int Mode, int UnrollCount> @@ -204,76 +267,98 @@ void Part<MatrixType, Mode>::lazyAssign(const Other& other) ei_part_assignment_impl <MatrixType, Other, Mode, unroll ? int(MatrixType::SizeAtCompileTime) : Dynamic - >::run(m_matrix, other.derived()); + >::run(m_matrix.const_cast_derived(), other.derived()); } -template<typename MatrixType, unsigned int Mode> -template<typename Other> inline void Part<MatrixType, Mode>::operator+=(const Other& other) -{ - *this = m_matrix + other; -} - -template<typename MatrixType, unsigned int Mode> -template<typename Other> inline void Part<MatrixType, Mode>::operator-=(const Other& other) +/** \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. + * + * \addexample PartExample \label How to write to a triangular part of a matrix + * + * Example: \include MatrixBase_part.cpp + * Output: \verbinclude MatrixBase_part.out + * + * \sa class Part, MatrixBase::extract(), MatrixBase::marked() + */ +template<typename Derived> +template<unsigned int Mode> +inline Part<Derived, Mode> MatrixBase<Derived>::part() { - *this = m_matrix - other; + return Part<Derived, Mode>(derived()); } -template<typename MatrixType, unsigned int Mode> -inline void Part<MatrixType, Mode>::operator*= -(const typename ei_traits<MatrixType>::Scalar& other) +/** \returns true if *this is approximately equal to an upper triangular matrix, + * within the precision given by \a prec. + * + * \sa isLower(), extract(), part(), marked() + */ +template<typename Derived> +bool MatrixBase<Derived>::isUpper(RealScalar prec) const { - *this = m_matrix * other; + if(cols() != rows()) return false; + RealScalar maxAbsOnUpperPart = static_cast<RealScalar>(-1); + for(int j = 0; j < cols(); j++) + for(int i = 0; i <= j; i++) + { + RealScalar absValue = ei_abs(coeff(i,j)); + if(absValue > maxAbsOnUpperPart) maxAbsOnUpperPart = absValue; + } + for(int j = 0; j < cols()-1; j++) + for(int i = j+1; i < rows(); i++) + if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnUpperPart, prec)) return false; + return true; } -template<typename MatrixType, unsigned int Mode> -inline void Part<MatrixType, Mode>::operator/= -(const typename ei_traits<MatrixType>::Scalar& other) +/** \returns true if *this is approximately equal to a lower triangular matrix, + * within the precision given by \a prec. + * + * \sa isUpper(), extract(), part(), marked() + */ +template<typename Derived> +bool MatrixBase<Derived>::isLower(RealScalar prec) const { - *this = m_matrix / other; + if(cols() != rows()) return false; + RealScalar maxAbsOnLowerPart = static_cast<RealScalar>(-1); + for(int j = 0; j < cols(); j++) + for(int i = j; i < rows(); i++) + { + RealScalar absValue = ei_abs(coeff(i,j)); + if(absValue > maxAbsOnLowerPart) maxAbsOnLowerPart = absValue; + } + for(int j = 1; j < cols(); j++) + for(int i = 0; i < j; i++) + if(!ei_isMuchSmallerThan(coeff(i, j), maxAbsOnLowerPart, prec)) return false; + return true; } template<typename MatrixType, unsigned int Mode> -inline void Part<MatrixType, Mode>::setConstant(const typename ei_traits<MatrixType>::Scalar& value) +template<typename Other> +inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator+=(const Other& other) { - *this = MatrixType::constant(m_matrix.rows(), m_matrix.cols(), value); + return *this = m_matrix + other; } template<typename MatrixType, unsigned int Mode> -inline void Part<MatrixType, Mode>::setZero() +template<typename Other> +inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator-=(const Other& other) { - setConstant((typename ei_traits<MatrixType>::Scalar)(0)); + return *this = m_matrix - other; } template<typename MatrixType, unsigned int Mode> -inline void Part<MatrixType, Mode>::setOnes() +inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator*= +(const typename ei_traits<MatrixType>::Scalar& other) { - setConstant((typename ei_traits<MatrixType>::Scalar)(1)); + return *this = m_matrix * other; } template<typename MatrixType, unsigned int Mode> -inline void Part<MatrixType, Mode>::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. - * - * \addexample PartExample \label How to write to a triangular part of a matrix - * - * Example: \include MatrixBase_part.cpp - * Output: \verbinclude MatrixBase_part.out - * - * \sa class Part, MatrixBase::extract(), MatrixBase::marked() - */ -template<typename Derived> -template<unsigned int Mode> -inline Part<Derived, Mode> MatrixBase<Derived>::part() +inline Part<MatrixType, Mode>& Part<MatrixType, Mode>::operator/= +(const typename ei_traits<MatrixType>::Scalar& other) { - return Part<Derived, Mode>(derived()); + return *this = m_matrix / other; } #endif // EIGEN_PART_H diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index 6979e4ac1..751f8f878 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -61,7 +61,10 @@ this_method_is_only_for_vectors_of_a_specific_size, you_did_a_programming_error, you_called_a_fixed_size_method_on_a_dynamic_size_matrix_or_vector, - unaligned_load_and_store_operations_unimplemented_on_AltiVec + unaligned_load_and_store_operations_unimplemented_on_AltiVec, + scalar_type_must_be_floating_point, + default_writting_to_selfadjoint_not_supported, + writting_to_triangular_part_with_unit_diag_is_not_supported }; }; diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index ab6994b4b..55d85ef57 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -132,11 +132,11 @@ public: operator Matrix3 () const { return toRotationMatrix(); } /** \returns a quaternion representing an identity rotation - * \sa MatrixBase::identity() + * \sa MatrixBase::Identity() */ - inline static Quaternion identity() { return Quaternion(1, 0, 0, 0); } + inline static Quaternion Identity() { return Quaternion(1, 0, 0, 0); } - /** \sa Quaternion::identity(), MatrixBase::setIdentity() + /** \sa Quaternion::Identity(), MatrixBase::setIdentity() */ inline Quaternion& setIdentity() { m_coeffs << 1, 0, 0, 0; return *this; } @@ -328,7 +328,7 @@ inline Quaternion<Scalar> Quaternion<Scalar>::inverse() const else { // return an invalid result to flag the error - return Quaternion(Coefficients::zero()); + return Quaternion(Coefficients::Zero()); } } diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 73e268e13..3da958aa7 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -240,7 +240,7 @@ template<typename OtherDerived> Transform<Scalar,Dim>& Transform<Scalar,Dim>::scale(const MatrixBase<OtherDerived> &other) { - EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,Dim); + EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)); affine() = (affine() * other.asDiagonal()).lazy(); return *this; } @@ -254,7 +254,7 @@ template<typename OtherDerived> Transform<Scalar,Dim>& Transform<Scalar,Dim>::prescale(const MatrixBase<OtherDerived> &other) { - EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,Dim); + EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)); m_matrix.template block<Dim,HDim>(0,0) = (other.asDiagonal() * m_matrix.template block<Dim,HDim>(0,0)).lazy(); return *this; } @@ -268,7 +268,7 @@ template<typename OtherDerived> Transform<Scalar,Dim>& Transform<Scalar,Dim>::translate(const MatrixBase<OtherDerived> &other) { - EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,Dim); + EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)); translation() += affine() * other; return *this; } @@ -282,7 +282,7 @@ template<typename OtherDerived> Transform<Scalar,Dim>& Transform<Scalar,Dim>::pretranslate(const MatrixBase<OtherDerived> &other) { - EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,Dim); + EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)); translation() += other; return *this; } diff --git a/Eigen/src/LU/Inverse.h b/Eigen/src/LU/Inverse.h index d6b2d5eb6..cfe90161a 100644 --- a/Eigen/src/LU/Inverse.h +++ b/Eigen/src/LU/Inverse.h @@ -305,7 +305,7 @@ inline void MatrixBase<Derived>::computeInverse(typename ei_eval<Derived>::type { typedef typename ei_eval<Derived>::type MatrixType; ei_assert(rows() == cols()); - ei_assert(NumTraits<Scalar>::HasFloatingPoint); + EIGEN_STATIC_ASSERT(NumTraits<Scalar>::HasFloatingPoint,scalar_type_must_be_floating_point); ei_compute_inverse<MatrixType>::run(eval(), result); } diff --git a/Eigen/src/QR/HessenbergDecomposition.h b/Eigen/src/QR/HessenbergDecomposition.h index 880997563..a3591d118 100755 --- a/Eigen/src/QR/HessenbergDecomposition.h +++ b/Eigen/src/QR/HessenbergDecomposition.h @@ -209,7 +209,7 @@ typename HessenbergDecomposition<MatrixType>::MatrixType HessenbergDecomposition<MatrixType>::matrixQ(void) const { int n = m_matrix.rows(); - MatrixType matQ = MatrixType::identity(n,n); + MatrixType matQ = MatrixType::Identity(n,n); for (int i = n-2; i>=0; i--) { Scalar tmp = m_matrix.coeff(i+1,i); diff --git a/Eigen/src/QR/QR.h b/Eigen/src/QR/QR.h index 704594320..d1fd2ae7a 100644 --- a/Eigen/src/QR/QR.h +++ b/Eigen/src/QR/QR.h @@ -57,11 +57,11 @@ template<typename MatrixType> class QR bool isFullRank() const { return ei_isMuchSmallerThan(m_hCoeffs.cwise().abs().minCoeff(), Scalar(1)); } /** \returns a read-only expression of the matrix R of the actual the QR decomposition */ - const Extract<NestByValue<MatrixRBlockType>, Upper> + const Part<NestByValue<MatrixRBlockType>, Upper> matrixR(void) const { int cols = m_qr.cols(); - return MatrixRBlockType(m_qr, 0, 0, cols, cols).nestByValue().template extract<Upper>(); + return MatrixRBlockType(m_qr, 0, 0, cols, cols).nestByValue().template part<Upper>(); } MatrixType matrixQ(void) const; @@ -144,7 +144,7 @@ MatrixType QR<MatrixType>::matrixQ(void) const // and v_k is the k-th Householder vector [1,m_qr(k+1,k), m_qr(k+2,k), ...] int rows = m_qr.rows(); int cols = m_qr.cols(); - MatrixType res = MatrixType::identity(rows, cols); + MatrixType res = MatrixType::Identity(rows, cols); for (int k = cols-1; k >= 0; k--) { // to make easier the computation of the transformation, let's temporarily diff --git a/Eigen/src/QR/SelfAdjointEigenSolver.h b/Eigen/src/QR/SelfAdjointEigenSolver.h index c8386cdda..a54986ba5 100644 --- a/Eigen/src/QR/SelfAdjointEigenSolver.h +++ b/Eigen/src/QR/SelfAdjointEigenSolver.h @@ -79,6 +79,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver void compute(const MatrixType& matA, const MatrixType& matB, bool computeEigenvectors = true); + /** \returns the computed eigen vectors as a matrix of column vectors */ MatrixType eigenvectors(void) const { #ifndef NDEBUG @@ -87,6 +88,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver return m_eivec; } + /** \returns the computed eigen values */ RealVectorType eigenvalues(void) const { return m_eivalues; } protected: diff --git a/Eigen/src/QR/Tridiagonalization.h b/Eigen/src/QR/Tridiagonalization.h index bcb4a2b59..78c6c2b1c 100755 --- a/Eigen/src/QR/Tridiagonalization.h +++ b/Eigen/src/QR/Tridiagonalization.h @@ -215,7 +215,7 @@ void Tridiagonalization<MatrixType>::_compute(MatrixType& matA, CoeffVectorType& matA.col(i).coeffRef(i+1) = 1; // let's use the end of hCoeffs to store temporary values - hCoeffs.end(n-i-1) = h * (matA.corner(BottomRight,n-i-1,n-i-1).template extract<Lower|SelfAdjoint>() + hCoeffs.end(n-i-1) = h * (matA.corner(BottomRight,n-i-1,n-i-1).template part<Lower|SelfAdjoint>() * matA.col(i).end(n-i-1)); @@ -261,7 +261,7 @@ typename Tridiagonalization<MatrixType>::MatrixType Tridiagonalization<MatrixType>::matrixQ(void) const { int n = m_matrix.rows(); - MatrixType matQ = MatrixType::identity(n,n); + MatrixType matQ = MatrixType::Identity(n,n); for (int i = n-2; i>=0; i--) { Scalar tmp = m_matrix.coeff(i+1,i); |