From 247f2b0ffa734d2133db9bb81a48cb4b5620d145 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 15 Sep 2008 15:45:41 +0000 Subject: * block() for vectors ---> segment() * documentation improvements, especially in quickstart guide --- Eigen/src/Core/Block.h | 32 ++++++++++++++++---------------- Eigen/src/Core/MatrixBase.h | 8 ++++---- Eigen/src/Core/SolveTriangular.h | 6 +++--- Eigen/src/Core/util/Constants.h | 4 ++++ Eigen/src/QR/SelfAdjointEigenSolver.h | 2 +- 5 files changed, 28 insertions(+), 24 deletions(-) (limited to 'Eigen/src') diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 71ad6d5f1..f1a095769 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -318,27 +318,27 @@ inline const typename BlockReturnType::Type MatrixBase return typename BlockReturnType::Type(derived(), startRow, startCol, blockRows, blockCols); } -/** \returns a dynamic-size expression of a block in *this. +/** \returns a dynamic-size expression of a segment (i.e. a vector block) in *this. * * \only_for_vectors * - * \addexample BlockIntInt \label How to reference a sub-vector (dynamic size) + * \addexample SegmentIntInt \label How to reference a sub-vector (dynamic size) * - * \param start the first coefficient in the block - * \param size the number of coefficients in the block + * \param start the first coefficient in the segment + * \param size the number of coefficients in the segment * - * Example: \include MatrixBase_block_int_int.cpp - * Output: \verbinclude MatrixBase_block_int_int.out + * Example: \include MatrixBase_segment_int_int.cpp + * Output: \verbinclude MatrixBase_segment_int_int.out * * \note Even though the returned expression has dynamic size, in the case * when it is applied to a fixed-size vector, it inherits a fixed maximal size, * which means that evaluating it does not cause a dynamic memory allocation. * - * \sa class Block, block(int) + * \sa class Block, segment(int) */ template inline typename BlockReturnType::SubVectorType MatrixBase - ::block(int start, int size) + ::segment(int start, int size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); return typename BlockReturnType::SubVectorType(derived(), RowsAtCompileTime == 1 ? 0 : start, @@ -347,10 +347,10 @@ inline typename BlockReturnType::SubVectorType MatrixBase ColsAtCompileTime == 1 ? 1 : size); } -/** This is the const version of block(int,int).*/ +/** This is the const version of segment(int,int).*/ template inline const typename BlockReturnType::SubVectorType -MatrixBase::block(int start, int size) const +MatrixBase::segment(int start, int size) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); return typename BlockReturnType::SubVectorType(derived(), RowsAtCompileTime == 1 ? 0 : start, @@ -451,7 +451,7 @@ MatrixBase::end(int size) const ColsAtCompileTime == 1 ? 1 : size); } -/** \returns a fixed-size expression of a sub-vector of \c *this +/** \returns a fixed-size expression of a segment (i.e. a vector block) in \c *this * * \only_for_vectors * @@ -459,15 +459,15 @@ MatrixBase::end(int size) const * * \param start the index of the first element of the sub-vector * - * Example: \include MatrixBase_template_int.cpp - * Output: \verbinclude MatrixBase_template_int.out + * Example: \include MatrixBase_template_int_segment.cpp + * Output: \verbinclude MatrixBase_template_int_segment.out * * \sa class Block */ template template inline typename BlockReturnType::SubVectorType -MatrixBase::block(int start) +MatrixBase::segment(int start) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); return Block::block(int start) ColsAtCompileTime == 1 ? 0 : start); } -/** This is the const version of block(int).*/ +/** This is the const version of segment(int).*/ template template inline const typename BlockReturnType::SubVectorType -MatrixBase::block(int start) const +MatrixBase::segment(int start) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived); return Block class MatrixBase const typename BlockReturnType::Type block(int startRow, int startCol, int blockRows, int blockCols) const; - typename BlockReturnType::SubVectorType block(int start, int size); - const typename BlockReturnType::SubVectorType block(int start, int size) const; + typename BlockReturnType::SubVectorType segment(int start, int size); + const typename BlockReturnType::SubVectorType segment(int start, int size) const; typename BlockReturnType::SubVectorType start(int size); const typename BlockReturnType::SubVectorType start(int size) const; @@ -379,8 +379,8 @@ template class MatrixBase template typename BlockReturnType::SubVectorType end(); template const typename BlockReturnType::SubVectorType end() const; - template typename BlockReturnType::SubVectorType block(int start); - template const typename BlockReturnType::SubVectorType block(int start) const; + template typename BlockReturnType::SubVectorType segment(int start); + template const typename BlockReturnType::SubVectorType segment(int start) const; DiagonalCoeffs diagonal(); const DiagonalCoeffs diagonal() const; diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h index aaebc5989..e77d9e238 100755 --- a/Eigen/src/Core/SolveTriangular.h +++ b/Eigen/src/Core/SolveTriangular.h @@ -119,8 +119,8 @@ struct ei_solve_triangular_selector int remainingSize = IsLower ? i-startBlock : startBlock-i; Scalar tmp = other.coeff(i,c) - btmp.coeff(IsLower ? remainingSize : 3-remainingSize) - - ( lhs.row(i).block(IsLower ? startBlock : i+1, remainingSize) - * other.col(c).block(IsLower ? startBlock : i+1, remainingSize)).coeff(0,0); + - ( lhs.row(i).segment(IsLower ? startBlock : i+1, remainingSize) + * other.col(c).segment(IsLower ? startBlock : i+1, remainingSize)).coeff(0,0); if (Lhs::Flags & UnitDiagBit) other.coeffRef(i,c) = tmp; @@ -172,7 +172,7 @@ struct ei_solve_triangular_selector other.coeffRef(i,c) /= lhs.coeff(i,i); int remainingSize = IsLower ? endBlock-i-1 : i-endBlock-1; if (remainingSize>0) - other.col(c).block((IsLower ? i : endBlock) + 1, remainingSize) -= + other.col(c).segment((IsLower ? i : endBlock) + 1, remainingSize) -= other.coeffRef(i,c) * Block(lhs, (IsLower ? i : endBlock) + 1, i, remainingSize, 1); btmp.coeffRef(IsLower ? i-startBlock : remainingSize) = -other.coeffRef(i,c); diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index e852fffa0..3fb5f918d 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -34,6 +34,10 @@ const int Dynamic = 10000; * These are the possible bits which can be OR'ed to constitute the flags of a matrix or * expression. * + * It is important to note that these flags are a purely compile-time notion. They are a compile-time property of + * an expression type, implemented as enum's. They are not stored in memory at runtime, and they do not incur any + * runtime overhead. + * * \sa MatrixBase::Flags */ diff --git a/Eigen/src/QR/SelfAdjointEigenSolver.h b/Eigen/src/QR/SelfAdjointEigenSolver.h index 765af7d21..9e929620c 100644 --- a/Eigen/src/QR/SelfAdjointEigenSolver.h +++ b/Eigen/src/QR/SelfAdjointEigenSolver.h @@ -204,7 +204,7 @@ void SelfAdjointEigenSolver::compute(const MatrixType& matrix, bool for (int i = 0; i < n-1; i++) { int k; - m_eivalues.block(i,n-i).minCoeff(&k); + m_eivalues.segment(i,n-i).minCoeff(&k); if (k > 0) { std::swap(m_eivalues[i], m_eivalues[k+i]); -- cgit v1.2.3