mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Implement and document MatrixBase::sqrt().
This commit is contained in:
@@ -53,6 +53,7 @@ namespace Eigen {
|
||||
* - \ref matrixbase_matrixfunction "MatrixBase::matrixFunction()", for computing general matrix functions
|
||||
* - \ref matrixbase_sin "MatrixBase::sin()", for computing the matrix sine
|
||||
* - \ref matrixbase_sinh "MatrixBase::sinh()", for computing the matrix hyperbolic sine
|
||||
* - \ref matrixbase_sqrt "MatrixBase::sqrt()", for computing the matrix square root
|
||||
*
|
||||
* These methods are the main entry points to this module.
|
||||
*
|
||||
@@ -246,7 +247,7 @@ Output: \verbinclude MatrixSine.out
|
||||
|
||||
|
||||
|
||||
\section matrixbase_sinh const MatrixBase::sinh()
|
||||
\section matrixbase_sinh MatrixBase::sinh()
|
||||
|
||||
Compute the matrix hyperbolic sine.
|
||||
|
||||
@@ -262,6 +263,74 @@ This function calls \ref matrixbase_matrixfunction "matrixFunction()" with StdSt
|
||||
Example: \include MatrixSinh.cpp
|
||||
Output: \verbinclude MatrixSinh.out
|
||||
|
||||
|
||||
\section matrixbase_sqrt MatrixBase::sqrt()
|
||||
|
||||
Compute the matrix square root.
|
||||
|
||||
\code
|
||||
const MatrixSquareRootReturnValue<Derived> MatrixBase<Derived>::sqrt() const
|
||||
\endcode
|
||||
|
||||
\param[in] M invertible matrix whose square root is to be computed.
|
||||
\returns expression representing the matrix square root of \p M.
|
||||
|
||||
The matrix square root of \f$ M \f$ is the matrix \f$ M^{1/2} \f$
|
||||
whose square is the original matrix; so if \f$ S = M^{1/2} \f$ then
|
||||
\f$ S^2 = M \f$.
|
||||
|
||||
In the <b>real case</b>, the matrix \f$ M \f$ should be invertible and
|
||||
it should have no eigenvalues which are real and negative (pairs of
|
||||
complex conjugate eigenvalues are allowed). In that case, the matrix
|
||||
has a square root which is also real, and this is the square root
|
||||
computed by this function.
|
||||
|
||||
The matrix square root is computed by first reducing the matrix to
|
||||
quasi-triangular form with the real Schur decomposition. The square
|
||||
root of the quasi-triangular matrix can then be computed directly. The
|
||||
cost is approximately \f$ 25 n^3 \f$ real flops for the real Schur
|
||||
decomposition and \f$ 3\frac13 n^3 \f$ real flops for the remainder
|
||||
(though the computation time in practice is likely more than this
|
||||
indicates).
|
||||
|
||||
Details of the algorithm can be found in: Nicholas J. Highan,
|
||||
"Computing real square roots of a real matrix", <em>Linear Algebra
|
||||
Appl.</em>, 88/89:405–430, 1987.
|
||||
|
||||
If the matrix is <b>positive-definite symmetric</b>, then the square
|
||||
root is also positive-definite symmetric. In this case, it is best to
|
||||
use SelfAdjointEigenSolver::operatorSqrt() to compute it.
|
||||
|
||||
In the <b>complex case</b>, the matrix \f$ M \f$ should be invertible;
|
||||
this is a restriction of the algorithm. The square root computed by
|
||||
this algorithm is the one whose eigenvalues have an argument in the
|
||||
interval \f$ (-\frac12\pi, \frac12\pi] \f$. This is the usual branch
|
||||
cut.
|
||||
|
||||
The computation is the same as in the real case, except that the
|
||||
complex Schur decomposition is used to reduce the matrix to a
|
||||
triangular matrix. The theoretical cost is the same. Details are in:
|
||||
Åke Björck and Scen Hammarling, "A Schur method for the
|
||||
square root of a matrix", <em>Linear Algebra Appl.</em>,
|
||||
52/53:127–140, 1983.
|
||||
|
||||
Example: The following program checks that the square root of
|
||||
\f[ \left[ \begin{array}{cc}
|
||||
\cos(\frac13\pi) & -\sin(\frac13\pi) \\
|
||||
\sin(\frac13\pi) & \cos(\frac13\pi)
|
||||
\end{array} \right], \f]
|
||||
corresponding to a rotation over 60 degrees, is a rotation over 30 degrees:
|
||||
\f[ \left[ \begin{array}{cc}
|
||||
\cos(\frac16\pi) & -\sin(\frac16\pi) \\
|
||||
\sin(\frac16\pi) & \cos(\frac16\pi)
|
||||
\end{array} \right]. \f]
|
||||
|
||||
\include MatrixSquareRoot.cpp
|
||||
Output: \verbinclude MatrixSquareRoot.out
|
||||
|
||||
\sa class RealSchur, class ComplexSchur, class MatrixSquareRoot,
|
||||
SelfAdjointEigenSolver::operatorSqrt().
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user