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:
iint

Index of matrix diagonal to switch.

Anp.ndarray

Upper-triangular matrix.

Bnp.ndarray

Upper-triangular matrix.

Qnp.ndarray

Matrix of left Schur vectors.

Znp.ndarray

Matrix of right Schur vectors.

Returns:
tuple of np.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