gEconpy.solvers.gensys.qzswitch#
- gEconpy.solvers.gensys.qzswitch(i, A, B, Q, Z)#
Christopher Sim’s qzswitch.
Takes upper-triangular matrices A, B, orthonormal matrices Q, Z, and interchanges diagonal elements i and i+1 of both A and B, while maintaining Q’AZ’ and Q’BZ’ unchanged. If diagonal elements of A and B are zero at matching positions, the returned A will have zeros at both positions on the diagonal. This is natural behavior if this routine is used to drive all zeros on the diagonal of A to the lower right, but in this case the qz transformation is not unique and it is not possible simply to switch the positions of the diagonal elements of both A and B.
- Parameters:
- i
int Index of matrix diagonal to switch.
- A
np.ndarray Upper-triangular matrix.
- B
np.ndarray Upper-triangular matrix.
- Q
np.ndarray Matrix of left Schur vectors.
- Z
np.ndarray Matrix of right Schur vectors.
- i
- Returns:
tupleofnp.ndarray- Contains four elements:
- Anp.ndarray
Upper-triangular matrix with switched diagonal elements.
- Bnp.ndarray
Upper-triangular matrix with switched diagonal elements.
- Qnp.ndarray
Orthonormal matrix of left Schur vectors.
- Znp.ndarray
Orthonormal matrix of right Schur vectors.
Notes
Originally part of gensys. Adapted from http://sims.princeton.edu/yftp/gensys/mfiles/gensys.m