{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Q is transposed versus the equivalent function in Matlab."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "versionadded",
          "base_type": "neutral",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "versionadded 0.11.0"
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "AA",
              "annotation": "(N, N) ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Generalized Schur form of A."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "BB",
              "annotation": "(N, N) ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Generalized Schur form of B."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "Q",
              "annotation": "(N, N) ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The left Schur vectors."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "Z",
              "annotation": "(N, N) ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The right Schur vectors."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "QZ decomposition for generalized eigenvalues of a pair of matrices."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "A",
              "annotation": "(N, N) array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "2-D array to decompose"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "B",
              "annotation": "(N, N) array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "2-D array to decompose"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "output",
              "annotation": "{'real', 'complex'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Construct the real or complex QZ decomposition for real matrices. Default is 'real'."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "lwork",
              "annotation": "int, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Work array size. If None or -1, it is automatically computed."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "sort",
              "annotation": "{None, callable, 'lhp', 'rhp', 'iuc', 'ouc'}, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "NOTE: THIS INPUT IS DISABLED FOR NOW. Use ordqz instead."
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Specifies whether the upper eigenvalues should be sorted. A callable may be passed that, given an eigenvalue, returns a boolean denoting whether the eigenvalue should be sorted to the top-left (True). For real matrix pairs, the sort function takes three real arguments (alphar, alphai, beta). The eigenvalue "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x = (alphar + alphai*1j)/beta"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ". For complex matrix pairs or output='complex', the sort function takes two complex arguments (alpha, beta). The eigenvalue "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "x = (alpha/beta)"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ".  Alternatively, string parameters may be used:"
                    }
                  ]
                },
                {
                  "__type": "Blockquote",
                  "__tag": 4059,
                  "children": [
                    {
                      "__type": "BulletList",
                      "__tag": 4053,
                      "ordered": false,
                      "start": 1,
                      "children": [
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "'lhp'   Left-hand plane (x.real < 0.0)"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "'rhp'   Right-hand plane (x.real > 0.0)"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "'iuc'   Inside the unit circle (x*x.conjugate() < 1.0)"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "__type": "ListItem",
                          "__tag": 4054,
                          "children": [
                            {
                              "__type": "Paragraph",
                              "__tag": 4045,
                              "children": [
                                {
                                  "__type": "Text",
                                  "__tag": 4046,
                                  "value": "'ouc'   Outside the unit circle (x*x.conjugate() > 1.0)"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Defaults to None (no sorting)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "overwrite_a",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Whether to overwrite data in a (may improve performance)"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "overwrite_b",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Whether to overwrite data in b (may improve performance)"
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "check_finite",
              "annotation": "bool, optional",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If true checks the elements of "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "A"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " and "
                    },
                    {
                      "__type": "ParamRef",
                      "__tag": 4071,
                      "name": "B"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " are finite numbers. If false does no checking and passes matrix through to underlying algorithm."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The QZ, or generalized Schur, decomposition for a pair of n-by-n matrices (A,B) is      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "(A,B) = (Q @ AA @ Z*, Q @ BB @ Z*)",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "where AA, BB is in generalized Schur form if BB is upper-triangular with non-negative diagonal and AA is upper-triangular, or for real QZ decomposition ("
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "output='real'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") block upper triangular with 1x1 and 2x2 blocks. In this case, the 1x1 blocks correspond to real generalized eigenvalues and 2x2 blocks are 'standardized' by making the corresponding elements of BB have the form      "
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "[ a 0 ]\n[ 0 b ]",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "and the pair of corresponding 2x2 blocks in AA and BB will have a complex conjugate pair of generalized eigenvalues. If ("
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "output='complex'"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ") or A and B are complex matrices, Z' denotes the conjugate-transpose of Z. Q and Z are unitary matrices."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The documentation is written assuming array arguments are of specified \"core\" shapes. However, array argument(s) of this function may have additional \"batch\" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see "
            },
            {
              "__type": "InlineRole",
              "__tag": 4003,
              "value": "linalg_batch",
              "domain": null,
              "role": "ref",
              "inventory": null
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " for details. Note that calls with zero-size batches are unsupported and will raise a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "ValueError"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/linalg/_decomp_qz.py",
  "item_line": 146,
  "item_type": "function",
  "aliases": [
    "scipy.linalg.qz"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\nfrom scipy.linalg import qz\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "A = np.array([[1, 2, -1], [5, 5, 5], [2, 4, -8]])\nB = np.array([[1, 1, -3], [3, 1, -1], [5, 6, -2]])\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nCompute the decomposition.  The QZ decomposition is not unique, so\ndepending on the underlying library that is used, there may be\ndifferences in the signs of coefficients in the following output.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "AA, BB, Q, Z = qz(A, B)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "AA\nBB\nQ\nZ\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nVerify the QZ decomposition.  With real output, we only need the\ntranspose of ``Z`` in the following expressions.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "Q @ AA @ Z.T  # Should be A\nQ @ BB @ Z.T  # Should be B\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nRepeat the decomposition, but with ``output='complex'``.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "AA, BB, Q, Z = qz(A, B, output='complex')\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nFor conciseness in the output, we use ``np.set_printoptions()`` to set\nthe output precision of NumPy arrays to 3 and display tiny values as 0.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "np.set_printoptions(precision=3, suppress=True)\n",
        "execution_status": "success"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "AA\nBB\nQ\nZ\n",
        "execution_status": "failure"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nWith complex arrays, we must use ``Z.conj().T`` in the following\nexpressions to verify the decomposition.\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "Q @ AA @ Z.conj().T  # Should be A\nQ @ BB @ Z.conj().T  # Should be B\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [
    {
      "__type": "SeeAlsoItem",
      "__tag": 4028,
      "name": {
        "__type": "CrossRef",
        "__tag": 4002,
        "value": "ordqz",
        "reference": {
          "__type": "LocalRef",
          "__tag": 4022,
          "kind": "module",
          "path": "scipy.linalg._decomp_qz:ordqz"
        },
        "kind": "module"
      },
      "descriptions": [],
      "type": "func"
    }
  ],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "A",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "B",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "output",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "real"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "lwork",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "sort",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "None"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "overwrite_a",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "overwrite_b",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "check_finite",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "True"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "qz"
  },
  "references": null,
  "qa": "scipy.linalg._decomp_qz:qz",
  "arbitrary": [],
  "local_refs": [
    "A",
    "AA",
    "B",
    "BB",
    "Q",
    "Z",
    "check_finite",
    "lwork",
    "output",
    "overwrite_a",
    "overwrite_b",
    "sort"
  ]
}