# Control theory¶

The following algorithms draw heavily from the second chapter of Nicholas J. Higham’s “Functions of Matrices: Theory and Computation” and depend heavily on the matrix sign function. They have only undergone cursory testing.

## Sylvester¶

As long as both $$A$$ and $$B$$ only have eigenvalues in the open right-half plane, the following routines solve for $$X$$ in the Sylvester equation

$A X + X B = C$

via computing $$\text{sgn}(W)$$, where

$\begin{split}W = \begin{pmatrix} A & -C \\ 0 & -B \end{pmatrix}.\end{split}$
void Sylvester(const Matrix<F> &A, const Matrix<F> &B, const Matrix<F> &C, Matrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())
void Sylvester(const DistMatrix<F> &A, const DistMatrix<F> &B, const DistMatrix<F> &C, DistMatrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())

One may also directly pass in $$W$$ in order to save space.

void Sylvester(int m, Matrix<F> &W, Matrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())
void Sylvester(int m, DistMatrix<F> &W, DistMatrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())

## Lyapunov¶

A special case of the Sylvester solver, where $$B = A^H$$.

void Lyapunov(const Matrix<F> &A, const Matrix<F> &C, Matrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())
void Lyapunov(const DistMatrix<F> &A, const DistMatrix<F> &C, DistMatrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())

## Algebraic Ricatti¶

Under suitable conditions, the following routines solve for $$X$$ in the algebraic Ricatti equation

$X K X - A^H X - X A = L,$

where both $$K$$ and $$L$$ are Hermitian.

void Ricatti(UpperOrLower uplo, const Matrix<F> &A, const Matrix<F> &K, const Matrix<F> &L, Matrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())
void Ricatti(UpperOrLower uplo, const DistMatrix<F> &A, const DistMatrix<F> &K, const DistMatrix<F> &L, DistMatrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())

Alternatively, one may directly fill the matrix $$W$$.

void Ricatti(Matrix<F> &W, Matrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())
void Ricatti(DistMatrix<F> &W, DistMatrix<F> &X, SignCtrl<Base<F>> signCtrl = SignCtrl<Base<F>>())