Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ sylvester_solver() [2/2]

template<typename MatA , typename MatB , typename MatC , require_all_matrix_t< MatA, MatB, MatC > * = nullptr, require_all_bt_arithmetic< MatA, MatB, MatC > * = nullptr>
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
MatAtype of A (real or complex arithmetic scalars)
MatBtype of B (real or complex arithmetic scalars)
MatCtype of C (real or complex arithmetic scalars)
Parameters
[in]An x n matrix
[in]Bm x m matrix
[in]Cn x m matrix
Returns
complex n x m solution X
Exceptions
std::invalid_argumentif 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
MatAtype of A (real or complex, var or double scalars)
MatBtype of B (real or complex, var or double scalars)
MatCtype of C (real or complex, var or double scalars)
Parameters
[in]An x n matrix
[in]Bm x m matrix
[in]Cn x m matrix
Returns
complex n x m solution X with std::complex<var> entries
Exceptions
std::invalid_argumentif A or B is not square, or if the dimensions of C do not match

Definition at line 35 of file sylvester_solver.hpp.