From 1c783e252fc7bbe44fb6fb793ebea2f7ad21a083 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 26 Jun 2010 18:49:50 +0200 Subject: extend the quick ref table page --- doc/QuickReference.dox | 227 +++++++++++++++++++++++++++++-------------------- 1 file changed, 134 insertions(+), 93 deletions(-) diff --git a/doc/QuickReference.dox b/doc/QuickReference.dox index 63e5d5dcc..47939e67b 100644 --- a/doc/QuickReference.dox +++ b/doc/QuickReference.dox @@ -8,6 +8,9 @@ namespace Eigen { - \ref QuickRef_Map - \ref QuickRef_ArithmeticOperators - \ref QuickRef_Coeffwise + - \ref QuickRef_Reductions + - \ref QuickRef_Blocks + - \ref QuickRef_DiagTriSymm \n
@@ -333,6 +336,12 @@ row2 = row1 * mat1; row1 *= mat1; mat3 = mat1 * mat2; mat3 *= mat1; \endcode +transpose et adjoint \matrixworld\code +mat1 = mat2.transpose(); mat1.transposeInPlace(); +mat1 = mat2.adjoint(); mat1.adjointInPlace(); +\endcode + + \link MatrixBase::dot() dot \endlink \& inner products \matrixworld\code scalar = col1.adjoint() * col2; scalar = (col1.adjoint() * col2).value(); @@ -342,6 +351,13 @@ scalar = vec1.dot(vec2);\endcode outer product \matrixworld\code mat = col1 * col2.transpose();\endcode + + +\link MatrixBase::norm() norm \endlink and \link MatrixBase::normalized() normalization \endlink \matrixworld\code +scalar = vec1.norm(); scalar = vec1.squaredNorm() +vec2 = vec1.normalized(); vec1.normalize(); // inplace \endcode + + \link MatrixBase::cross() cross product \endlink \matrixworld\code #include @@ -403,13 +419,8 @@ array1.tan() std::tan(array1) -*/ - -// FIXME I stopped here - -/** top -\section TutorialCoreReductions Reductions +\section QuickRef_Reductions Reductions Eigen provides several reduction methods such as: \link DenseBase::minCoeff() minCoeff() \endlink, \link DenseBase::maxCoeff() maxCoeff() \endlink, @@ -440,8 +451,7 @@ Also note that maxCoeff and minCoeff can takes optional arguments returning the - -top\section TutorialCoreMatrixBlocks Matrix blocks +top\section QuickRef_Blocks Matrix blocks Read-write access to a \link DenseBase::col(int) column \endlink or a \link DenseBase::row(int) row \endlink of a matrix (or array): @@ -469,8 +479,8 @@ Read-write access to sub-matrices: \link DenseBase::block(int,int,int,int) (more) \endlink \code mat1.block(i,j)\endcode \link DenseBase::block(int,int) (more) \endlink - the \c rows x \c cols sub-matrix \n starting from position (\c i,\c j) - \code + the \c rows x \c cols sub-matrix \n starting from position (\c i,\c j) +\code mat1.topLeftCorner(rows,cols) mat1.topRightCorner(rows,cols) mat1.bottomLeftCorner(rows,cols) @@ -481,168 +491,199 @@ Read-write access to sub-matrices: mat1.bottomLeftCorner() mat1.bottomRightCorner()\endcode the \c rows x \c cols sub-matrix \n taken in one of the four corners - - - - -top\section TutorialCoreDiagonalMatrices Diagonal matrices -\matrixworld - - - - + - + mat1.topRows() + mat1.bottomRows() + mat1.leftCols() + mat1.rightCols()\endcode +
-\link MatrixBase::asDiagonal() make a diagonal matrix \endlink from a vector \n -this product is automatically optimized !\code -mat3 = mat1 * vec2.asDiagonal();\endcode -
Access \link MatrixBase::diagonal() the diagonal of a matrix \endlink as a vector (read/write)
\code + mat1.topRows(rows) + mat1.bottomRows(rows) + mat1.leftCols(cols) + mat1.rightCols(cols)\endcode \code - vec1 = mat1.diagonal(); - mat1.diagonal() = vec1; - \endcode -
specialized versions of block() when the block fit two corners
-top -\section TutorialCoreTransposeAdjoint Transpose and Adjoint operations - - - - -
-\link DenseBase::transpose() transposition \endlink (read-write)\code -mat3 = mat1.transpose() * mat2; -mat3.transpose() = mat1 * mat2.transpose(); -\endcode -
-\link MatrixBase::adjoint() adjoint \endlink (read only) \matrixworld\n\code -mat3 = mat1.adjoint() * mat2; -\endcode -
- +top\section QuickRef_DiagTriSymm Diagonal, Triangular, and Self-adjoint matrices +(matrix world \matrixworld) -top -\section TutorialCoreDotNorm Dot-product, vector norm, normalization \matrixworld +\subsection QuickRef_Diagonal Diagonal matrices - -
-\link MatrixBase::dot() Dot-product \endlink of two vectors -\code vec1.dot(vec2);\endcode +\link MatrixBase::asDiagonal() make a diagonal matrix \endlink \n from a vector \code +mat1 = vec1.asDiagonal();\endcode
-\link MatrixBase::norm() norm \endlink of a vector \n -\link MatrixBase::squaredNorm() squared norm \endlink of a vector -\code vec.norm(); \endcode \n \code vec.squaredNorm() \endcode +Declare a diagonal matrix\code +DiagonalMatrix diag1(size); +diag1.diagonal() = vector;\endcode
-returns a \link MatrixBase::normalized() normalized \endlink vector \n -\link MatrixBase::normalize() normalize \endlink a vector -\code -vec3 = vec1.normalized(); -vec1.normalize();\endcode -
+Access \link MatrixBase::diagonal() the diagonal and super/sub diagonals of a matrix \endlink as a vector (read/write) + \code +vec1 = mat1.diagonal(); mat1.diagonal() = vec1; // main diagonal +vec1 = mat1.diagonal(+n); mat1.diagonal(+n) = vec1; // n-th super diagonal +vec1 = mat1.diagonal(-n); mat1.diagonal(-n) = vec1; // n-th sub diagonal +vec1 = mat1.diagonal<1>(); mat1.diagonal<1>() = vec1; // first super diagonal +vec1 = mat1.diagonal<-2>(); mat1.diagonal<-2>() = vec1; // second sub diagonal +\endcode + +Optimized products and inverse + \code +mat3 = scalar * diag1 * mat1; +mat3 += scalar * mat1 * vec1.asDiagonal(); +mat3 = vec1.asDiagonal().inverse() * mat1 +mat3 = mat1 * diag1.inverse() +\endcode + + -top -\section TutorialCoreTriangularMatrix Dealing with triangular matrices \matrixworld +\subsection QuickRef_TriangularView Triangular views -Currently, Eigen does not provide any explicit triangular matrix, with storage class. Instead, we -can reference a triangular part of a square matrix or expression to perform special treatment on it. -This is achieved by the class TriangularView and the MatrixBase::triangularView template function. -Note that the opposite triangular part of the matrix is never referenced, and so it can, e.g., store -a second triangular matrix. +TriangularView allows to get views on a triangular part of a dense matrix and perform optimized operations on it. The opposite triangular is never referenced and can be +used to store other information.
Reference a read/write triangular part of a given \n matrix (or expression) m with optional unit diagonal: \code -m.triangularView() -m.triangularView() -m.triangularView() -m.triangularView()\endcode +m.triangularView() +\endcode \n +\c Xxx = Upper, Lower, StrictlyUpper, StrictlyLower, UnitUpper, UnitLower
Writing to a specific triangular part:\n (only the referenced triangular part is evaluated) \code -m1.triangularView() = m2 + m3 \endcode +m1.triangularView() = m2 + m3 \endcode
Conversion to a dense matrix setting the opposite triangular part to zero: \code -m2 = m1.triangularView()\endcode +m2 = m1.triangularView()\endcode
Products: \code -m3 += s1 * m1.adjoint().triangularView() * m2 -m3 -= s1 * m2.conjugate() * m1.adjoint().triangularView() \endcode +m3 += s1 * m1.adjoint().triangularView() * m2 +m3 -= s1 * m2.conjugate() * m1.adjoint().triangularView() \endcode
Solving linear equations:\n(\f$ m_2 := m_1^{-1} m_2 \f$) \code -m1.triangularView().solveInPlace(m2) -m1.adjoint().triangularView().solveInPlace(m2)\endcode +m1.triangularView().solveInPlace(m2) +m1.adjoint().triangularView().solveInPlace(m2)\endcode
-top -\section TutorialCoreSelfadjointMatrix Dealing with symmetric/selfadjoint matrices \matrixworld +\subsection QuickRef_SelfadjointMatrix Symmetric/selfadjoint views Just as for triangular matrix, you can reference any triangular part of a square matrix to see it a selfadjoint -matrix to perform special and optimized operations. Again the opposite triangular is never referenced and can be +matrix and perform special and optimized operations. Again the opposite triangular is never referenced and can be used to store other information.
Conversion to a dense matrix: \code -m2 = m.selfadjointView();\endcode +m2 = m.selfadjointView();\endcode
Product with another general matrix or vector: \code -m3 = s1 * m1.conjugate().selfadjointView() * m3; -m3 -= s1 * m3.adjoint() * m1.selfadjointView();\endcode +m3 = s1 * m1.conjugate().selfadjointView() * m3; +m3 -= s1 * m3.adjoint() * m1.selfadjointView();\endcode
Rank 1 and rank K update: \code // fast version of m1 += s1 * m2 * m2.adjoint(): -m1.selfadjointView().rankUpdate(m2,s1); +m1.selfadjointView().rankUpdate(m2,s1); // fast version of m1 -= m2.adjoint() * m2: -m1.selfadjointView().rankUpdate(m2.adjoint(),-1); \endcode +m1.selfadjointView().rankUpdate(m2.adjoint(),-1); \endcode
Rank 2 update: (\f$ m += s u v^* + s v u^* \f$) \code -m.selfadjointView().rankUpdate(u,v,s); +m.selfadjointView().rankUpdate(u,v,s); \endcode
Solving linear equations:\n(\f$ m_2 := m_1^{-1} m_2 \f$) \code // via a standard Cholesky factorization -m1.selfadjointView().llt().solveInPlace(m2); +m1.selfadjointView().llt().solveInPlace(m2); // via a Cholesky factorization with pivoting -m1.selfadjointView().ldlt().solveInPlace(m2); +m1.selfadjointView().ldlt().solveInPlace(m2); \endcode
+*/ -top -\section TutorialCoreSpecialTopics Special Topics +/* + + + + + + -\ref TopicLazyEvaluation "Lazy Evaluation and Aliasing": Thanks to expression templates, Eigen is able to apply lazy evaluation wherever that is beneficial. + + -*/ + + +
+\link MatrixBase::asDiagonal() make a diagonal matrix \endlink \n from a vector \code +mat1 = vec1.asDiagonal();\endcode +
+Declare a diagonal matrix\code +DiagonalMatrix diag1(size); +diag1.diagonal() = vector;\endcode +
Access \link MatrixBase::diagonal() the diagonal and super/sub diagonals of a matrix \endlink as a vector (read/write)\code +vec1 = mat1.diagonal(); mat1.diagonal() = vec1; // main diagonal +vec1 = mat1.diagonal(+n); mat1.diagonal(+n) = vec1; // n-th super diagonal +vec1 = mat1.diagonal(-n); mat1.diagonal(-n) = vec1; // n-th sub diagonal +vec1 = mat1.diagonal<1>(); mat1.diagonal<1>() = vec1; // first super diagonal +vec1 = mat1.diagonal<-2>(); mat1.diagonal<-2>() = vec1; // second sub diagonal +\endcode
View on a triangular part of a matrix (read/write)\code +mat2 = mat1.triangularView(); +// Xxx = Upper, Lower, StrictlyUpper, StrictlyLower, UnitUpper, UnitLower +mat1.triangularView() = mat2 + mat3; // only the upper part is evaluated and referenced +\endcode
View a triangular part as a symmetric/self-adjoint matrix (read/write)\code +mat2 = mat1.selfadjointView(); // Xxx = Upper or Lower +mat1.selfadjointView() = mat2 + mat2.adjoint(); // evaluated and write to the upper triangular part only +\endcode
+ +Optimized products: +\code +mat3 += scalar * vec1.asDiagonal() * mat1 +mat3 += scalar * mat1 * vec1.asDiagonal() +mat3.noalias() += scalar * mat1.triangularView() * mat2 +mat3.noalias() += scalar * mat2 * mat1.triangularView() +mat3.noalias() += scalar * mat1.selfadjointView() * mat2 +mat3.noalias() += scalar * mat2 * mat1.selfadjointView() +mat1.selfadjointView().rankUpdate(mat2); +mat1.selfadjointView().rankUpdate(mat2.adjoint(), scalar); +\endcode + +Inverse products: (all are optimized) +\code +mat3 = vec1.asDiagonal().inverse() * mat1 +mat3 = mat1 * diag1.inverse() +mat1.triangularView().solveInPlace(mat2) +mat1.triangularView().solveInPlace(mat2) +mat2 = mat1.selfadjointView().llt().solve(mat2) +\endcode + +*/ } -- cgit v1.2.3