31 #include <Eigen/Dense> 32 #include <Eigen/Eigenvalues> 46 const Eigen::MatrixXcd& T = A_schur.
matrixT();
47 const Eigen::MatrixXcd& U = A_schur.
matrixU();
50 Eigen::MatrixXcd F = U.adjoint() * Q * U;
52 const int n = A.rows();
53 Eigen::MatrixXcd Y(n, n);
58 Eigen::MatrixXcd lhs(n, n);
61 Eigen::MatrixXcd T_adjoint = T.adjoint();
65 for (
int k = n - 1; k >= 0; --k)
67 Eigen::VectorXcd rhs = F.col(k) + T * Y * T_adjoint.col(k);
70 const std::complex<double> factor = T_adjoint(k, k);
77 Y.col(k) = lhs_svd.
solve(rhs);
79 if (k > 0) lhs.setIdentity();
83 X = (U * Y * U.adjoint()).
real();
92 Eigen::VectorXcd eigvals_A = A.eigenvalues();
94 for (
int i = 0; i < eigvals_A.size(); ++i)
96 for (
int j = i; j < eigvals_A.size(); ++j)
98 std::complex<double> product = eigvals_A[i] * eigvals_A[j];
bool have_equal_size(const Eigen::MatrixBase< DerivedA > &matrix1, const Eigen::MatrixBase< DerivedB > &matrix2)
Determine if two matrices exhibit equal sizes/dimensions.
bool approx_equal(double a, double b, double epsilon=1e-6)
Check if two doubles are appoximately equal.
bool is_square(const Eigen::MatrixBase< Derived > &matrix)
Determine if a given matrix is square.
ComputationInfo info() const
Reports whether previous computation was successful.
const Solve< JacobiSVD< _MatrixType, QRPreconditioner >, Rhs > solve(const MatrixBase< Rhs > &b) const
MatrixType A(a, *n, *n, *lda)
A matrix or vector expression mapping an existing expression.
static bool hasUniqueSolution(const Eigen::Ref< const Eigen::MatrixXd > &A)
Determine if the Lyapunov equation exhibits a unique solution.
const ComplexMatrixType & matrixU() const
Returns the unitary matrix in the Schur decomposition.
Two-sided Jacobi SVD decomposition of a rectangular matrix.
static bool solve(const Eigen::Ref< const Eigen::MatrixXd > &A, const Eigen::Ref< const Eigen::MatrixXd > &Q, Eigen::MatrixXd &X)
Solve discrete-time Lyapunov equation.
JacobiSVD & compute(const MatrixType &matrix, unsigned int computationOptions)
Method performing the decomposition of given matrix using custom options.
Performs a complex Schur decomposition of a real or complex square matrix.
const ComplexMatrixType & matrixT() const
Returns the triangular matrix in the Schur decomposition.