Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
 Eigen-unsupported  3.3.9
Matrix functions module

## Detailed Description

This module aims to provide various methods for the computation of matrix functions.

#include <unsupported/Eigen/MatrixFunctions>

at the start of your source file.

This module defines the following MatrixBase methods.

These methods are the main entry points to this module.

Matrix functions are defined as follows. Suppose that $$f$$ is an entire function (that is, a function on the complex plane that is everywhere complex differentiable). Then its Taylor series

$f(0) + f'(0) x + \frac{f''(0)}{2} x^2 + \frac{f'''(0)}{3!} x^3 + \cdots$

converges to $$f(x)$$. In this case, we can define the matrix function by the same series:

$f(M) = f(0) + f'(0) M + \frac{f''(0)}{2} M^2 + \frac{f'''(0)}{3!} M^3 + \cdots$

## Classes

class  Eigen::MatrixComplexPowerReturnValue< Derived >
Proxy for the matrix power of some matrix (expression). More...

struct  Eigen::MatrixExponentialReturnValue< Derived >
Proxy for the matrix exponential of some matrix (expression). More...

class  Eigen::MatrixFunctionReturnValue< Derived >
Proxy for the matrix function of some matrix (expression). More...

class  Eigen::MatrixLogarithmReturnValue< Derived >
Proxy for the matrix logarithm of some matrix (expression). More...

class  Eigen::MatrixPower< MatrixType >
Class for computing matrix powers. More...

class  Eigen::MatrixPowerAtomic< MatrixType >
Class for computing matrix powers. More...

class  Eigen::MatrixPowerParenthesesReturnValue< MatrixType >
Proxy for the matrix power of some matrix. More...

class  Eigen::MatrixPowerReturnValue< Derived >
Proxy for the matrix power of some matrix (expression). More...

class  Eigen::MatrixSquareRootReturnValue< Derived >
Proxy for the matrix square root of some matrix (expression). More...

## Functions

template<typename MatrixType , typename ResultType >
void Eigen::matrix_sqrt_quasi_triangular (const MatrixType &arg, ResultType &result)
Compute matrix square root of quasi-triangular matrix. More...

template<typename MatrixType , typename ResultType >
void Eigen::matrix_sqrt_triangular (const MatrixType &arg, ResultType &result)
Compute matrix square root of triangular matrix. More...

# MatrixBase methods defined in the MatrixFunctions module

The remainder of the page documents the following MatrixBase methods which are defined in the MatrixFunctions module.

## MatrixBase::cos()

Compute the matrix cosine.

const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::cos() const
Parameters
 [in] M a square matrix.
Returns
expression representing $$\cos(M)$$.

This function computes the matrix cosine. Use ArrayBase::cos() for computing the entry-wise cosine.

The implementation calls matrixFunction() with StdStemFunctions::cos().

sin() for an example.

## MatrixBase::cosh()

Compute the matrix hyberbolic cosine.

const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::cosh() const
Parameters
 [in] M a square matrix.
Returns
expression representing $$\cosh(M)$$

This function calls matrixFunction() with StdStemFunctions::cosh().

sinh() for an example.

## MatrixBase::exp()

Compute the matrix exponential.

const MatrixExponentialReturnValue<Derived> MatrixBase<Derived>::exp() const
Parameters
 [in] M matrix whose exponential is to be computed.
Returns
expression representing the matrix exponential of M.

The matrix exponential of $$M$$ is defined by

$\exp(M) = \sum_{k=0}^\infty \frac{M^k}{k!}.$

The matrix exponential can be used to solve linear ordinary differential equations: the solution of $$y' = My$$ with the initial condition $$y(0) = y_0$$ is given by $$y(t) = \exp(M) y_0$$.

The matrix exponential is different from applying the exp function to all the entries in the matrix. Use ArrayBase::exp() if you want to do the latter.

The cost of the computation is approximately $$20 n^3$$ for matrices of size $$n$$. The number 20 depends weakly on the norm of the matrix.

The matrix exponential is computed using the scaling-and-squaring method combined with Padé approximation. The matrix is first rescaled, then the exponential of the reduced matrix is computed approximant, and then the rescaling is undone by repeated squaring. The degree of the Padé approximant is chosen such that the approximation error is less than the round-off error. However, errors may accumulate during the squaring phase.

Details of the algorithm can be found in: Nicholas J. Higham, "The scaling and squaring method for the matrix exponential revisited," SIAM J. Matrix Anal. Applic., 26:1179–1193, 2005.

Example: The following program checks that

$\exp \left[ \begin{array}{ccc} 0 & \frac14\pi & 0 \\ -\frac14\pi & 0 & 0 \\ 0 & 0 & 0 \end{array} \right] = \left[ \begin{array}{ccc} \frac12\sqrt2 & -\frac12\sqrt2 & 0 \\ \frac12\sqrt2 & \frac12\sqrt2 & 0 \\ 0 & 0 & 1 \end{array} \right].$

This corresponds to a rotation of $$\frac14\pi$$ radians around the z-axis.

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
const double pi = std::acos(-1.0);
MatrixXd A(3,3);
A << 0, -pi/4, 0,
pi/4, 0, 0,
0, 0, 0;
std::cout << "The matrix A is:\n" << A << "\n\n";
std::cout << "The matrix exponential of A is:\n" << A.exp() << "\n\n";
}

Output:

The matrix A is:
0 -0.785398         0
0.785398         0         0
0         0         0

The matrix exponential of A is:
0.707107 -0.707107         0
0.707107  0.707107         0
0         0         1


Note
M has to be a matrix of float, double, long double complex<float>, complex<double>, or complex<long double> .

## MatrixBase::log()

Compute the matrix logarithm.

const MatrixLogarithmReturnValue<Derived> MatrixBase<Derived>::log() const
Parameters
 [in] M invertible matrix whose logarithm is to be computed.
Returns
expression representing the matrix logarithm root of M.

The matrix logarithm of $$M$$ is a matrix $$X$$ such that $$\exp(X) = M$$ where exp denotes the matrix exponential. As for the scalar logarithm, the equation $$\exp(X) = M$$ may have multiple solutions; this function returns a matrix whose eigenvalues have imaginary part in the interval $$(-\pi,\pi]$$.

The matrix logarithm is different from applying the log function to all the entries in the matrix. Use ArrayBase::log() if you want to do the latter.

In the real case, the matrix $$M$$ should be invertible and it should have no eigenvalues which are real and negative (pairs of complex conjugate eigenvalues are allowed). In the complex case, it only needs to be invertible.

This function computes the matrix logarithm using the Schur-Parlett algorithm as implemented by MatrixBase::matrixFunction(). The logarithm of an atomic block is computed by MatrixLogarithmAtomic, which uses direct computation for 1-by-1 and 2-by-2 blocks and an inverse scaling-and-squaring algorithm for bigger blocks, with the square roots computed by MatrixBase::sqrt().

Details of the algorithm can be found in Section 11.6.2 of: Nicholas J. Higham, Functions of Matrices: Theory and Computation, SIAM 2008. ISBN 978-0-898716-46-7.

Example: The following program checks that

$\log \left[ \begin{array}{ccc} \frac12\sqrt2 & -\frac12\sqrt2 & 0 \\ \frac12\sqrt2 & \frac12\sqrt2 & 0 \\ 0 & 0 & 1 \end{array} \right] = \left[ \begin{array}{ccc} 0 & \frac14\pi & 0 \\ -\frac14\pi & 0 & 0 \\ 0 & 0 & 0 \end{array} \right].$

This corresponds to a rotation of $$\frac14\pi$$ radians around the z-axis. This is the inverse of the example used in the documentation of exp().

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
using std::sqrt;
MatrixXd A(3,3);
A << 0.5*sqrt(2), -0.5*sqrt(2), 0,
0.5*sqrt(2), 0.5*sqrt(2), 0,
0, 0, 1;
std::cout << "The matrix A is:\n" << A << "\n\n";
std::cout << "The matrix logarithm of A is:\n" << A.log() << "\n";
}

Output:

The matrix A is:
0.707107 -0.707107         0
0.707107  0.707107         0
0         0         1

The matrix logarithm of A is:
-4.93649e-17    -0.785398            0
0.785398  -1.7268e-16            0
0            0            0

Note
M has to be a matrix of float, double, long double, complex<float>, complex<double>, or complex<long double>.
MatrixBase::exp(), MatrixBase::matrixFunction(), class MatrixLogarithmAtomic, MatrixBase::sqrt().

## MatrixBase::pow()

Compute the matrix raised to arbitrary real power.

const MatrixPowerReturnValue<Derived> MatrixBase<Derived>::pow(RealScalar p) const
Parameters
 [in] M base of the matrix power, should be a square matrix. [in] p exponent of the matrix power.

The matrix power $$M^p$$ is defined as $$\exp(p \log(M))$$, where exp denotes the matrix exponential, and log denotes the matrix logarithm. This is different from raising all the entries in the matrix to the p-th power. Use ArrayBase::pow() if you want to do the latter.

If p is complex, the scalar type of M should be the type of p . $$M^p$$ simply evaluates into $$\exp(p \log(M))$$. Therefore, the matrix $$M$$ should meet the conditions to be an argument of matrix logarithm.

If p is real, it is casted into the real scalar type of M. Then this function computes the matrix power using the Schur-Padé algorithm as implemented by class MatrixPower. The exponent is split into integral part and fractional part, where the fractional part is in the interval $$(-1, 1)$$. The main diagonal and the first super-diagonal is directly computed.

If M is singular with a semisimple zero eigenvalue and p is positive, the Schur factor $$T$$ is reordered with Givens rotations, i.e.

$T = \left[ \begin{array}{cc} T_1 & T_2 \\ 0 & 0 \end{array} \right]$

where $$T_1$$ is invertible. Then $$T^p$$ is given by

$T^p = \left[ \begin{array}{cc} T_1^p & T_1^{-1} T_1^p T_2 \\ 0 & 0 \end{array}. \right]$

Warning
Fractional power of a matrix with a non-semisimple zero eigenvalue is not well-defined. We introduce an assertion failure against inaccurate result, e.g.
#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
int main()
{
Eigen::Matrix4d A;
A << 0, 0, 2, 3,
0, 0, 4, 5,
0, 0, 6, 7,
0, 0, 8, 9;
std::cout << A.pow(0.37) << std::endl;
// The 1 makes eigenvalue 0 non-semisimple.
A.coeffRef(0, 1) = 1;
// This fails if EIGEN_NO_DEBUG is undefined.
std::cout << A.pow(0.37) << std::endl;
return 0;
}

Details of the algorithm can be found in: Nicholas J. Higham and Lijing Lin, "A Schur-Pad&eacute; algorithm for fractional powers of a matrix," SIAM J. Matrix Anal. Applic., 32(3):1056–1078, 2011.

Example: The following program checks that

$\left[ \begin{array}{ccc} \cos1 & -\sin1 & 0 \\ \sin1 & \cos1 & 0 \\ 0 & 0 & 1 \end{array} \right]^{\frac14\pi} = \left[ \begin{array}{ccc} \frac12\sqrt2 & -\frac12\sqrt2 & 0 \\ \frac12\sqrt2 & \frac12\sqrt2 & 0 \\ 0 & 0 & 1 \end{array} \right].$

This corresponds to $$\frac14\pi$$ rotations of 1 radian around the z-axis.

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
const double pi = std::acos(-1.0);
Matrix3d A;
A << cos(1), -sin(1), 0,
sin(1), cos(1), 0,
0 , 0 , 1;
std::cout << "The matrix A is:\n" << A << "\n\n"
"The matrix power A^(pi/4) is:\n" << A.pow(pi/4) << std::endl;
return 0;
}

Output:

The matrix A is:
0.540302 -0.841471         0
0.841471  0.540302         0
0         0         1

The matrix power A^(pi/4) is:
0.707107 -0.707107         0
0.707107  0.707107         0
0         0         1


MatrixBase::pow() is user-friendly. However, there are some circumstances under which you should use class MatrixPower directly. MatrixPower can save the result of Schur decomposition, so it's better for computing various powers for the same matrix.

Example:

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
Matrix4cd A = Matrix4cd::Random();
std::cout << "The matrix A is:\n" << A << "\n\n"
"A^3.1 is:\n" << Apow(3.1) << "\n\n"
"A^3.3 is:\n" << Apow(3.3) << "\n\n"
"A^3.7 is:\n" << Apow(3.7) << "\n\n"
"A^3.9 is:\n" << Apow(3.9) << std::endl;
return 0;
}

Output:

The matrix A is:
(-0.999984,-0.736924)   (0.358593,0.869386)  (0.342299,-0.984604)  (0.692334,0.0538576)
(0.511211,-0.0826997) (-0.232996,0.0388327) (-0.233169,-0.866316)   (-0.81607,0.307838)
(0.0655345,-0.562082)  (0.661931,-0.930856)  (-0.165028,0.373545)  (-0.168001,0.402381)
(-0.905911,0.357729) (-0.893077,0.0594004)   (0.177953,0.860873)   (0.820642,0.524396)

A^3.1 is:
(1.72257,-2.70381)    (0.540963,2.36827)   (-0.251785,1.67974)    (0.950068,2.03845)
(-0.23814,1.24213)  (-0.609708,-1.09702)  (-0.648231,0.741588)   (0.20442,-0.107284)
(-0.0669646,0.564601)   (-1.61565,0.462499)  (-0.133892,-1.74235) (-0.775622,-0.685425)
(0.569705,-0.891909)       (2.08793,2.034)  (-1.74387,-0.697262)   (-0.731061,0.50819)

A^3.3 is:
(0.517932,-3.33724)     (1.80778,3.00124)   (-0.52531,0.712117)      (1.2568,1.77262)
(0.322937,1.24027)  (-1.03234,-0.738796)   (-0.607212,1.08789)   (0.129478,0.241952)
(-0.0639215,0.565523)    (-1.88075,0.29941)   (0.558837,-1.43905)  (-0.46048,-0.962814)
(0.231218,-0.612453)     (2.06105,2.17664)   (-1.68847,-1.78817)  (-1.06043,0.0580043)

A^3.7 is:
(-2.51153,-2.39874)    (3.75928,2.36133)   (-1.4382,-1.49702)  (0.984644,0.217559)
(1.19503,0.413517)   (-1.4841,0.476423)  (-0.221745,1.46307)  (0.215741,0.949732)
(-0.138804,0.395192) (-1.86781,-0.104239)  (1.79945,-0.389005)  (0.479043,-1.30024)
(-0.252036,0.456531)    (1.12154,1.66307)  (-0.97941,-3.59713)  (-1.78738,-1.11224)

A^3.9 is:
(-3.59685,-0.772441)    (3.88211,1.13013)  (-1.94382,-2.35807) (0.278649,-0.817206)
(1.25945,-0.286285)   (-1.33603,1.14294)  (0.0492397,1.42702)   (0.398577,1.16056)
(-0.228683,0.270377)  (-1.57779,-0.30702)   (2.21812,0.286616)    (1.02455,-1.3175)
(-0.239687,1.06545)   (0.252353,1.09621)  (-0.300805,-4.0949)  (-2.06483,-1.68965)

Note
M has to be a matrix of float, double, long double, complex<float>, complex<double>, or complex<long double> .
MatrixBase::exp(), MatrixBase::log(), class MatrixPower.

## MatrixBase::matrixFunction()

Compute a matrix function.

const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::matrixFunction(typename internal::stem_function<typename internal::traits<Derived>::Scalar>::type f) const
Parameters
 [in] M argument of matrix function, should be a square matrix. [in] f an entire function; f(x,n) should compute the n-th derivative of f at x.
Returns
expression representing f applied to M.

Suppose that M is a matrix whose entries have type Scalar. Then, the second argument, f, should be a function with prototype

ComplexScalar f(ComplexScalar, int)

where ComplexScalar = std::complex<Scalar> if Scalar is real (e.g., float or double) and ComplexScalar = Scalar if Scalar is complex. The return value of f(x,n) should be $$f^{(n)}(x)$$, the n-th derivative of f at x.

This routine uses the algorithm described in: Philip Davies and Nicholas J. Higham, "A Schur-Parlett algorithm for computing matrix functions", SIAM J. Matrix Anal. Applic., 25:464–485, 2003.

The actual work is done by the MatrixFunction class.

Example: The following program checks that

$\exp \left[ \begin{array}{ccc} 0 & \frac14\pi & 0 \\ -\frac14\pi & 0 & 0 \\ 0 & 0 & 0 \end{array} \right] = \left[ \begin{array}{ccc} \frac12\sqrt2 & -\frac12\sqrt2 & 0 \\ \frac12\sqrt2 & \frac12\sqrt2 & 0 \\ 0 & 0 & 1 \end{array} \right].$

This corresponds to a rotation of $$\frac14\pi$$ radians around the z-axis. This is the same example as used in the documentation of exp().

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
std::complex<double> expfn(std::complex<double> x, int)
{
return std::exp(x);
}
int main()
{
const double pi = std::acos(-1.0);
MatrixXd A(3,3);
A << 0, -pi/4, 0,
pi/4, 0, 0,
0, 0, 0;
std::cout << "The matrix A is:\n" << A << "\n\n";
std::cout << "The matrix exponential of A is:\n"
<< A.matrixFunction(expfn) << "\n\n";
}

Output:

The matrix A is:
0 -0.785398         0
0.785398         0         0
0         0         0

The matrix exponential of A is:
0.707107 -0.707107         0
0.707107  0.707107         0
0         0         1



Note that the function expfn is defined for complex numbers x, even though the matrix A is over the reals. Instead of expfn, we could also have used StdStemFunctions::exp:

A.matrixFunction(StdStemFunctions<std::complex<double> >::exp, &B);

## MatrixBase::sin()

Compute the matrix sine.

const MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::sin() const
Parameters
 [in] M a square matrix.
Returns
expression representing $$\sin(M)$$.

This function computes the matrix sine. Use ArrayBase::sin() for computing the entry-wise sine.

The implementation calls matrixFunction() with StdStemFunctions::sin().

Example:

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
MatrixXd A = MatrixXd::Random(3,3);
std::cout << "A = \n" << A << "\n\n";
MatrixXd sinA = A.sin();
std::cout << "sin(A) = \n" << sinA << "\n\n";
MatrixXd cosA = A.cos();
std::cout << "cos(A) = \n" << cosA << "\n\n";
// The matrix functions satisfy sin^2(A) + cos^2(A) = I,
// like the scalar functions.
std::cout << "sin^2(A) + cos^2(A) = \n" << sinA*sinA + cosA*cosA << "\n\n";
}

Output:

A =
-0.999984 -0.0826997  -0.905911
-0.736924  0.0655345   0.357729
0.511211  -0.562082   0.358593

sin(A) =
-0.881303 -0.0321424  -0.888534
-0.684161   0.156012   0.445595
0.537715   -0.60819   0.423229

cos(A) =
0.738326  -0.288915  -0.254717
-0.416758    1.08005  -0.413302
-0.0532373    0.15058    1.27214

sin^2(A) + cos^2(A) =
1 3.33067e-16   4.996e-16
0           1 3.33067e-16
-2.498e-16 1.66533e-16           1



## MatrixBase::sinh()

Compute the matrix hyperbolic sine.

MatrixFunctionReturnValue<Derived> MatrixBase<Derived>::sinh() const
Parameters
 [in] M a square matrix.
Returns
expression representing $$\sinh(M)$$

This function calls matrixFunction() with StdStemFunctions::sinh().

Example:

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
MatrixXf A = MatrixXf::Random(3,3);
std::cout << "A = \n" << A << "\n\n";
MatrixXf sinhA = A.sinh();
std::cout << "sinh(A) = \n" << sinhA << "\n\n";
MatrixXf coshA = A.cosh();
std::cout << "cosh(A) = \n" << coshA << "\n\n";
// The matrix functions satisfy cosh^2(A) - sinh^2(A) = I,
// like the scalar functions.
std::cout << "cosh^2(A) - sinh^2(A) = \n" << coshA*coshA - sinhA*sinhA << "\n\n";
}

Output:

A =
-0.999984 -0.0826997  -0.905911
-0.736924  0.0655345   0.357729
0.511211  -0.562082   0.358593

sinh(A) =
-1.13098  -0.139217  -0.933352
-0.801852 -0.0246179   0.264086
0.486648  -0.516361   0.299619

cosh(A) =
1.33805  0.298607  0.297644
0.456231  0.944925  0.407519
0.0332949 -0.130653  0.736565

cosh^2(A) - sinh^2(A) =
1            0 -5.96046e-08
-2.38419e-07            1 -1.19209e-07
1.49012e-08 -2.23517e-07            1



## MatrixBase::sqrt()

Compute the matrix square root.

const MatrixSquareRootReturnValue<Derived> MatrixBase<Derived>::sqrt() const
Parameters
 [in] M invertible matrix whose square root is to be computed.
Returns
expression representing the matrix square root of M.

The matrix square root of $$M$$ is the matrix $$M^{1/2}$$ whose square is the original matrix; so if $$S = M^{1/2}$$ then $$S^2 = M$$. This is different from taking the square root of all the entries in the matrix; use ArrayBase::sqrt() if you want to do the latter.

In the real case, the matrix $$M$$ 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 $$25 n^3$$ real flops for the real Schur decomposition and $$3\frac13 n^3$$ 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", Linear Algebra Appl., 88/89:405–430, 1987.

If the matrix is positive-definite symmetric, then the square root is also positive-definite symmetric. In this case, it is best to use SelfAdjointEigenSolver::operatorSqrt() to compute it.

In the complex case, the matrix $$M$$ 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 $$(-\frac12\pi, \frac12\pi]$$. 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 Sven Hammarling, "A Schur method for the square root of a matrix", Linear Algebra Appl., 52/53:127–140, 1983.

Example: The following program checks that the square root of

$\left[ \begin{array}{cc} \cos(\frac13\pi) & -\sin(\frac13\pi) \\ \sin(\frac13\pi) & \cos(\frac13\pi) \end{array} \right],$

corresponding to a rotation over 60 degrees, is a rotation over 30 degrees:

$\left[ \begin{array}{cc} \cos(\frac16\pi) & -\sin(\frac16\pi) \\ \sin(\frac16\pi) & \cos(\frac16\pi) \end{array} \right].$

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
const double pi = std::acos(-1.0);
MatrixXd A(2,2);
A << cos(pi/3), -sin(pi/3),
sin(pi/3), cos(pi/3);
std::cout << "The matrix A is:\n" << A << "\n\n";
std::cout << "The matrix square root of A is:\n" << A.sqrt() << "\n\n";
std::cout << "The square of the last matrix is:\n" << A.sqrt() * A.sqrt() << "\n";
}

Output:

The matrix A is:
0.5 -0.866025
0.866025       0.5

The matrix square root of A is:
0.866025     -0.5
0.5 0.866025

The square of the last matrix is:
0.5 -0.866025
0.866025       0.5

class RealSchur, class ComplexSchur, class MatrixSquareRoot, SelfAdjointEigenSolver::operatorSqrt().

## ◆ matrix_sqrt_quasi_triangular()

template<typename MatrixType , typename ResultType >
 void Eigen::matrix_sqrt_quasi_triangular ( const MatrixType & arg, ResultType & result )

Compute matrix square root of quasi-triangular matrix.

Template Parameters
 MatrixType type of arg, the argument of matrix square root, expected to be an instantiation of the Matrix class template. ResultType type of result, where result is to be stored.
Parameters
 [in] arg argument of matrix square root. [out] result matrix square root of upper Hessenberg part of arg.

This function computes the square root of the upper quasi-triangular matrix stored in the upper Hessenberg part of arg. Only the upper Hessenberg part of result is updated, the rest is not touched. See MatrixBase::sqrt() for details on how this computation is implemented.

MatrixSquareRoot, MatrixSquareRootQuasiTriangular

## ◆ matrix_sqrt_triangular()

template<typename MatrixType , typename ResultType >
 void Eigen::matrix_sqrt_triangular ( const MatrixType & arg, ResultType & result )

Compute matrix square root of triangular matrix.

Template Parameters
 MatrixType type of arg, the argument of matrix square root, expected to be an instantiation of the Matrix class template. ResultType type of result, where result is to be stored.
Parameters
 [in] arg argument of matrix square root. [out] result matrix square root of upper triangular part of arg.

Only the upper triangular part (including the diagonal) of result is updated, the rest is not touched. See MatrixBase::sqrt() for details on how this computation is implemented.