| auto stan::math::sylvester_solver |
( |
MatA && |
A, |
|
|
MatB && |
B, |
|
|
MatC && |
C |
|
) |
| |
|
inline |
Solve the Sylvester equation A X + X B = C for X.
Solve the Sylvester equation A X + X B = C for X, reverse mode.
With complex Schur decompositions A = U S U^H and B = V T V^H the equation reduces to S Y + Y T = U^H C V, solved column by column, and X = U Y V^H. A unique solution requires lambda_i(A) + mu_j(B) != 0 for all eigenvalues of A and B.
- Template Parameters
-
| MatA | type of A (real or complex arithmetic scalars) |
| MatB | type of B (real or complex arithmetic scalars) |
| MatC | type of C (real or complex arithmetic scalars) |
- Parameters
-
| [in] | A | n x n matrix |
| [in] | B | m x m matrix |
| [in] | C | n x m matrix |
- Returns
- complex n x m solution X
- Exceptions
-
| std::invalid_argument | if A or B is not square, or if the dimensions of C do not match |
Forward pass as in prim. With G the adjoint of X (real part: adjoint of Re X, imaginary part: adjoint of Im X) and Z the solution of A^H Z + Z B^H = G, the gradients are grad_A = -Z X^H, grad_B = -X^H Z, grad_C = Z. Complex inputs receive Re and Im of their gradient; real inputs receive only the real part.
- Template Parameters
-
| MatA | type of A (real or complex, var or double scalars) |
| MatB | type of B (real or complex, var or double scalars) |
| MatC | type of C (real or complex, var or double scalars) |
- Parameters
-
| [in] | A | n x n matrix |
| [in] | B | m x m matrix |
| [in] | C | n x m matrix |
- Returns
- complex n x m solution X with std::complex<var> entries
- Exceptions
-
| std::invalid_argument | if A or B is not square, or if the dimensions of C do not match |
Definition at line 35 of file sylvester_solver.hpp.