33 #include <Eigen/Cholesky> 35 #include <Eigen/Dense> 46 assert(A.rows() == B.rows());
47 assert(R.rows() == B.cols());
49 const int p = A.rows();
52 Eigen::MatrixXd R_inv_B_t = R_cholesky.
solve(B.transpose());
53 Eigen::MatrixXd A_inv_trans = A.inverse().transpose();
58 Eigen::MatrixXd H(2 * p, 2 * p);
59 H << A + B * R_inv_B_t * A_inv_trans * Q, -B * R_inv_B_t * A_inv_trans, -A_inv_trans * Q, A_inv_trans;
66 *G = G_cholesky.
solve(B.transpose()) * X * A;
74 assert(H.rows() % 2 == 0);
79 Eigen::MatrixXd T = schur.matrixT();
80 Eigen::MatrixXd U = schur.matrixU();
86 const int p = H.rows() / 2;
88 if (!success || p != subspace_dim)
return false;
98 X = U1_svd.
solve(U.block(p, 0, p, p).transpose());
106 assert(A.rows() == B.rows());
107 assert(A.rows() == G.cols());
108 assert(G.rows() == B.cols());
110 Eigen::VectorXcd
eig = (A - B * G).eigenvalues();
111 for (
int i = 0; i < eig.size(); ++i)
113 if (
std::abs(eig[i]) >= 1)
return false;
Robust Cholesky decomposition of a matrix with pivoting.
bool have_equal_size(const Eigen::MatrixBase< DerivedA > &matrix1, const Eigen::MatrixBase< DerivedB > &matrix2)
Determine if two matrices exhibit equal sizes/dimensions.
Performs a real Schur decomposition of a square matrix.
static bool isInsideUnitCircle(const Eigen::Ref< const Eigen::MatrixXd > &block)
bool is_square(const Eigen::MatrixBase< Derived > &matrix)
Determine if a given matrix is square.
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
MatrixType A(a, *n, *n, *lda)
bool reorder_schur_blocks(Eigen::Ref< Eigen::MatrixXd > T, Eigen::Ref< Eigen::MatrixXd > Q, Predicate predicate, int *subspace_dim, bool standardize)
const Solve< LDLT, Rhs > solve(const MatrixBase< Rhs > &b) const
static bool isClosedLoopStable(const Eigen::Ref< const Eigen::MatrixXd > &A, const Eigen::Ref< const Eigen::MatrixXd > &B, const Eigen::Ref< const Eigen::MatrixXd > &G)
Determine if the closed-loop system is stable.
SelfAdjointEigenSolver< PlainMatrixType > eig(mat, computeVectors?ComputeEigenvectors:EigenvaluesOnly)
static bool solve(const Eigen::Ref< const Eigen::MatrixXd > &A, const Eigen::Ref< const Eigen::MatrixXd > &B, const Eigen::Ref< const Eigen::MatrixXd > &Q, const Eigen::Ref< const Eigen::MatrixXd > &R, Eigen::MatrixXd &X, Eigen::MatrixXd *G=nullptr)
Solve discrete-time algebraic Riccati equation.
A matrix or vector expression mapping an existing expression.
static bool solveRiccatiHamiltonianSchur(const Eigen::MatrixXd &H, Eigen::MatrixXd &X)
Solve Hamiltonian via Schur method.
Two-sided Jacobi SVD decomposition of a rectangular matrix.
MatrixType B(b, *n, *nrhs, *ldb)