XLPack 6.1
Excel VBA Numerical Library Reference Manual
Loading...
Searching...
No Matches

◆ Zggglm()

Sub Zggglm ( N As  Long,
M As  Long,
P As  Long,
A() As  Complex,
B() As  Complex,
D() As  Complex,
X() As  Complex,
Y() As  Complex,
Info As  Long 
)

General Gauss-Markov linear model (GLM) problem of complex matrices

Purpose
This routine solves a general Gauss-Markov linear model (GLM) problem:
minimize || y ||_2 subject to d = A*x + B*y
x
where A is an N x M matrix, B is an N x P matrix, and d is a given N-vector. It is assumed that M <= N <= M + P, and
rank(A) = M and rank(A B) = N
Under these assumptions, the constrained equation is always consistent, and there is a unique solution x and a minimal 2-norm solution y, which is obtained using a generalized QR factorization of the matrices (A, B) given by
A = Q*(R), B = Q*T*Z
(0)
In particular, if matrix B is square nonsingular, then the problem GLM is equivalent to the following weighted linear least squares problem
minimize || inv(B)*(d - A*x) ||_2
x
Parameters
[in]NNumber of rows of the matrices A and B. (N >= 0) (If N = 0, returns without
[in]MNumber of columns of the matrix A. (0 <= M <= N)
[in]PNumber of columns of the matrix B. (N - M <= P)
[in,out]A()Array A(LA1 - 1, LA2 - 1) (LA1 >= N, LA2 >= M)
[in] N x M matrix A.
[out] The upper triangular part of the array A() contains the M x M upper triangular matrix R.
[in,out]B()Array B(LB1 - 1, LB2 - 1) (LB1 >= N, LB2 >= P)
[in] N x P matrix B.
[out] If N <= P, the upper triangle of the subarray B(0 to N-1, P-N to P-1) contains the N x N upper triangular matrix T. If N > P, the elements on and above the (N-P)-th subdiagonal contain the N x P upper trapezoidal matrix T.
[in,out]D()Array D(LD - 1) (LD >= N)
[in] D() is the left hand side of the GLM equation.
[out] D() is destroyed.
[out]X()Array X(LX - 1) (LX >= M)
[out]Y()Array Y(LY - 1) (LY >= P)
X() and Y() are the solutions of the GLM problem.
[out]Info= 0: Successful exit.
= -1: The argument N had an illegal value. (N < 0)
= -2: The argument M had an illegal value. (M < 0 or M > N)
= -3: The argument P had an illegal value. (P < 0 or P < N - M)
= -4: The argument A() is invalid.
= -5: The argument B() is invalid.
= -6: The argument D() is invalid.
= -7: The argument X() is invalid.
= -8: The argument Y() is invalid.
= 1: The upper triangular factor R associated with A in the generalized QR factorization of the pair (A, B) is singular, so that rank(A) < M. The least squares solution could not be computed.
= 2: The bottom N-M x N-M part of the upper trapezoidal factor T associated with B in the generalized QR factorization of the pair (A, B) is singular, so that rank(A B) < N. The least squares solution could not be computed.
Reference
LAPACK
Example Program
Solve a general Gauss-Markov linear model (GLM) problem, i.e. find x which minimizes || y ||_2 subject to d = A*x + B*y, where
( -0.82+0.83i 0.18-0.94i -0.18-0.12i )
A = ( -0.76-0.24i 0.57-0.16i -0.08-0.27i )
( 1.90+0.26i -0.98+0.54i 0.21+0.28i )
( 0.50-0.30i -0.31+0.37i 0.22+0.19i )
( 1 0 0 0 )
B = ( 0 1 0 0 )
( 0 0 1 0 )
( 0 0 0 1 )
( 1.7126-0.6648i )
d = ( 0.8697+0.7604i )
( -2.1048-1.6171i )
( -0.9297+0.1252i )
Sub EX_Zggglm()
Const M = 3, N = 4, P = 4
Dim A(N - 1, M - 1) As Complex, B(N - 1, P - 1) As Complex
Dim C(M - 1) As Complex, D(P - 1) As Complex
Dim X(M - 1) As Complex, Y(P - 1) As Complex
Dim S As Double, Info As Long
A(0, 0) = Cmplx(-0.82, 0.83): A(0, 1) = Cmplx(0.18, -0.94): A(0, 2) = Cmplx(-0.18, -0.12)
A(1, 0) = Cmplx(-0.76, -0.24): A(1, 1) = Cmplx(0.57, -0.16): A(1, 2) = Cmplx(-0.08, -0.27)
A(2, 0) = Cmplx(1.9, 0.26): A(2, 1) = Cmplx(-0.98, 0.54): A(2, 2) = Cmplx(0.21, 0.28)
A(3, 0) = Cmplx(0.5, -0.3): A(3, 1) = Cmplx(-0.31, 0.37): A(3, 2) = Cmplx(0.22, 0.19)
B(0, 0) = Cmplx(1): B(0, 1) = Cmplx(0): B(0, 2) = Cmplx(0): B(0, 3) = Cmplx(0)
B(1, 0) = Cmplx(0): B(1, 1) = Cmplx(1): B(1, 2) = Cmplx(0): B(1, 3) = Cmplx(0)
B(2, 0) = Cmplx(0): B(2, 1) = Cmplx(0): B(2, 2) = Cmplx(1): B(2, 3) = Cmplx(0)
B(3, 0) = Cmplx(0): B(3, 1) = Cmplx(0): B(3, 2) = Cmplx(0): B(3, 3) = Cmplx(1)
D(0) = Cmplx(1.7126, -0.6648): D(1) = Cmplx(0.8697, 0.7604)
D(2) = Cmplx(-2.1048, -1.6171): D(3) = Cmplx(-0.9297, 0.1252)
Call Zggglm(N, M, P, A(), B(), D(), X(), Y(), Info)
S = Dznrm2(P, Y(0))
Debug.Print "X ="
Debug.Print Creal(X(0)), Cimag(X(0)), Creal(X(1)), Cimag(X(1))
Debug.Print Creal(X(2)), Cimag(X(2))
Debug.Print "SumSq =", S, "Info =", Info
End Sub
Example Results
X =
-0.819999999999999 -0.939999999999999 0.740000000000001 0.200000000000002
0.480000000000002 0.21
SumSq = 1.06144666256319E-16 Info = 0