## Stata 15 help for mf_ghessenbergd

```
[M-5] ghessenbergd() -- Generalized Hessenberg decomposition

Syntax

void   ghessenbergd(numeric matrix A, B, H, R, U, V)

void  _ghessenbergd(numeric matrix A, B,       U, V)

Description

ghessenbergd(A, B, H, R, U, V) computes the generalized Hessenberg
decomposition of two general, real or complex, square matrices, A and B,
returning the upper Hessenberg form matrix in H, the upper triangular
matrix in R, and the orthogonal (unitary) matrices in U and V.

_ghessenbergd(A, B, U, V) mirrors ghessenbergd(), the difference being
that it returns H in A and R in B.

_ghessenbergd_la() is the interface into the LAPACK routines used to
implement the above function; see [M-1] LAPACK.  Its direct use is not
recommended.

Remarks

The generalized Hessenberg decomposition of two square, numeric matrices
(A and B) can be written as

U' * A * V = H
U' * B * V = R

where H is in upper Hessenberg form, R is upper triangular, and U and V
are orthogonal matrices if A and B are real or are unitary matrices
otherwise.

In the example below, we define A and B, obtain the generalized
Hessenberg decomposition, and list H and Q.

: A = (6, 2, 8, -1\-3, -4, -6, 4\0, 8, 4, 1\-8, -7, -3, 5)

: B = (8, 0, -8, -1\-6, -2, -6, -1\-7, -6, 2, -6\1, -7, 9, 2)

: ghessenbergd(A, B, H=., R=., U=., V=.)

: H
1              2              3              4
+-------------------------------------------------------------+
1 |  -4.735680169    1.363736029    5.097381347    3.889763589  |
2 |   9.304479208   -8.594240253   -7.993282943    4.803411217  |
3 |             0    4.553169015    3.236266637   -2.147709419  |
4 |             0              0    6.997043028   -3.524816722  |
+-------------------------------------------------------------+

: R
1              2              3              4
+-------------------------------------------------------------+
1 |  -12.24744871   -1.089095534   -1.848528639   -5.398470103  |
2 |             0   -5.872766311    8.891361089     3.86967647  |
3 |             0              0    9.056748937    1.366322731  |
4 |             0              0              0    8.357135399  |
+-------------------------------------------------------------+

Conformability

ghessenbergd(A, B, H, R, U, V):
input:
A:  n x n
B:  n x n
output:
H:  n x n
R:  n x n
U:  n x n
V:  n x n

_ghessenbergd(A, B, U, V):
input:
A:  n x n
B:  n x n
output:
A:  n x n
B:  n x n
U:  n x n
V:  n x n

Diagnostics

_ghessenbergd() aborts with error if A or B is a view.

ghessenbergd() and _ghessenbergd() return missing results if A or B
contains missing values.

Source code

ghessenbergd.mata, _ghessenbergd.mata

```