Go to the documentation of this file.
10 #ifndef EIGEN_MATRIX_SQUARE_ROOT
11 #define EIGEN_MATRIX_SQUARE_ROOT
19 template <
typename MatrixType,
typename ResultType>
27 sqrtT.template block<2,2>(
i,
i)
28 = (
es.eigenvectors() *
es.eigenvalues().cwiseSqrt().asDiagonal() *
es.eigenvectors().inverse()).
real();
34 template <
typename MatrixType,
typename ResultType>
39 sqrtT.coeffRef(
i,
j) = (
T.coeff(
i,
j) - tmp) / (sqrtT.coeff(
i,
i) + sqrtT.coeff(
j,
j));
43 template <
typename MatrixType,
typename ResultType>
49 rhs -= sqrtT.block(
i,
i+1, 1,
j-
i-1) * sqrtT.block(
i+1,
j,
j-
i-1, 2);
51 A += sqrtT.template block<2,2>(
j,
j).transpose();
52 sqrtT.template block<1,2>(
i,
j).transpose() =
A.fullPivLu().solve(rhs.transpose());
56 template <
typename MatrixType,
typename ResultType>
62 rhs -= sqrtT.block(
i,
i+2, 2,
j-
i-2) * sqrtT.block(
i+2,
j,
j-
i-2, 1);
64 A += sqrtT.template block<2,2>(
i,
i);
65 sqrtT.template block<2,1>(
i,
j) =
A.fullPivLu().solve(rhs);
69 template <
typename MatrixType>
74 coeffMatrix.
coeffRef(0,0) =
A.coeff(0,0) +
B.coeff(0,0);
75 coeffMatrix.
coeffRef(1,1) =
A.coeff(0,0) +
B.coeff(1,1);
76 coeffMatrix.
coeffRef(2,2) =
A.coeff(1,1) +
B.coeff(0,0);
77 coeffMatrix.
coeffRef(3,3) =
A.coeff(1,1) +
B.coeff(1,1);
94 result = coeffMatrix.fullPivLu().solve(rhs);
96 X.coeffRef(0,0) =
result.coeff(0);
97 X.coeffRef(0,1) =
result.coeff(1);
98 X.coeffRef(1,0) =
result.coeff(2);
99 X.coeffRef(1,1) =
result.coeff(3);
103 template <
typename MatrixType,
typename ResultType>
111 C -= sqrtT.block(
i,
i+2, 2,
j-
i-2) * sqrtT.block(
i+2,
j,
j-
i-2, 2);
114 sqrtT.template block<2,2>(
i,
j) =
X;
119 template <
typename MatrixType,
typename ResultType>
125 if (
i ==
size - 1 ||
T.coeff(
i+1,
i) == 0) {
127 sqrtT.coeffRef(
i,
i) =
sqrt(
T.coeff(
i,
i));
138 template <
typename MatrixType,
typename ResultType>
143 if (
T.coeff(
j,
j-1) != 0)
146 if (
i > 0 &&
T.coeff(
i,
i-1) != 0)
148 bool iBlockIs2x2 = (
i <
size - 1) && (
T.coeff(
i+1,
i) != 0);
149 bool jBlockIs2x2 = (
j <
size - 1) && (
T.coeff(
j+1,
j) != 0);
150 if (iBlockIs2x2 && jBlockIs2x2)
152 else if (iBlockIs2x2 && !jBlockIs2x2)
154 else if (!iBlockIs2x2 && jBlockIs2x2)
156 else if (!iBlockIs2x2 && !jBlockIs2x2)
179 template <
typename MatrixType,
typename ResultType>
203 template <
typename MatrixType,
typename ResultType>
253 template <
typename MatrixType>
257 template <
typename ResultType>
279 template <
typename MatrixType>
283 template <
typename ResultType>
298 result =
U * (sqrtT.template triangularView<Upper>() *
U.adjoint());
316 template<
typename Derived>
class MatrixSquareRootReturnValue
317 :
public ReturnByValue<MatrixSquareRootReturnValue<Derived> >
335 template <
typename ResultType>
340 DerivedEvalType tmp(
m_src);
352 template<
typename Derived>
359 template <
typename Derived>
368 #endif // EIGEN_MATRIX_FUNCTION
EigenSolver< MatrixXf > es
Namespace containing all symbols from the Eigen library.
void matrix_sqrt_quasi_triangular(const MatrixType &arg, ResultType &result)
Compute matrix square root of quasi-triangular matrix.
void matrix_sqrt_quasi_triangular_1x1_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
Derived::PlainObject ReturnType
void matrix_sqrt_quasi_triangular_2x2_diagonal_block(const MatrixType &T, Index i, ResultType &sqrtT)
Proxy for the matrix square root of some matrix (expression).
void matrix_sqrt_quasi_triangular_diagonal(const MatrixType &T, ResultType &sqrtT)
Eigen::Triplet< double > T
cout<< "Here is a random 4x4 matrix, A:"<< endl<< A<< endl<< endl;ComplexSchur< MatrixXcf > schurOfA(A, false)
MatrixType::PlainObject PlainType
Helper struct for computing matrix square roots of general matrices.
MatrixType::PlainObject PlainType
m m block(1, 0, 2, 2)<< 4
void matrix_sqrt_quasi_triangular_2x2_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
const DerivedNested m_src
Performs a real Schur decomposition of a square matrix.
static void run(const MatrixType &arg, ResultType &result)
MatrixSquareRootReturnValue(const Derived &src)
Constructor.
static void run(const MatrixType &arg, ResultType &result)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
A small structure to hold a non zero as a triplet (i,j,value).
void matrix_sqrt_triangular(const MatrixType &arg, ResultType &result)
Compute matrix square root of triangular matrix.
const AutoDiffScalar< DerType > & real(const AutoDiffScalar< DerType > &x)
Matrix< Scalar, Dynamic, Dynamic > C
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE Scalar & coeff(Index rowId, Index colId) const
void evalTo(ResultType &result) const
Compute the matrix square root.
Computes eigenvalues and eigenvectors of general matrices.
void matrix_sqrt_quasi_triangular_2x1_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
The matrix class, also used for vectors and row-vectors.
void matrix_sqrt_quasi_triangular_off_diagonal(const MatrixType &T, ResultType &sqrtT)
void matrix_sqrt_quasi_triangular_1x2_off_diagonal_block(const MatrixType &T, Index i, Index j, ResultType &sqrtT)
EIGEN_CONSTEXPR Index size(const T &x)
internal::ref_selector< Derived >::type DerivedNested
Performs a complex Schur decomposition of a real or complex square matrix.
Jet< T, N > sqrt(const Jet< T, N > &f)
static void run(const MatrixType &arg, ResultType &result)
Compute the matrix square root.
void matrix_sqrt_quasi_triangular_solve_auxiliary_equation(MatrixType &X, const MatrixType &A, const MatrixType &B, const MatrixType &C)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:10