Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zggglm (f08zp)

## Purpose

nag_lapack_zggglm (f08zp) solves a complex general Gauss–Markov linear (least squares) model problem.

## Syntax

[a, b, d, x, y, info] = f08zp(a, b, d, 'm', m, 'n', n, 'p', p)
[a, b, d, x, y, info] = nag_lapack_zggglm(a, b, d, 'm', m, 'n', n, 'p', p)

## Description

nag_lapack_zggglm (f08zp) solves the complex general Gauss–Markov linear model (GLM) problem
 minimize ‖y‖2  subject to  d = Ax + By x
$minimize x ‖y‖2 subject to d=Ax+By$
where A$A$ is an m$m$ by n$n$ matrix, B$B$ is an m$m$ by p$p$ matrix and d$d$ is an m$m$ element vector. It is assumed that nmn + p$n\le m\le n+p$, rank(A) = n$\mathrm{rank}\left(A\right)=n$ and rank(E) = m$\mathrm{rank}\left(E\right)=m$, where E =
 ( A B )
$E=\left(\begin{array}{cc}A& B\end{array}\right)$. Under these assumptions, the problem has a unique solution x$x$ and a minimal 2$2$-norm solution y$y$, which is obtained using a generalized QR$QR$ factorization of the matrices A$A$ and B$B$.
In particular, if the matrix B$B$ is square and nonsingular, then the GLM problem is equivalent to the weighted linear least squares problem
 minimize ‖B − 1(d − Ax)‖2. x
$minimize x ‖ B-1 (d-Ax) ‖2 .$

## References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia
Anderson E, Bai Z and Dongarra J (1992) Generalized QR factorization and its applications Linear Algebra Appl. (Volume 162–164) 243–271

## Parameters

### Compulsory Input Parameters

1:     a(lda, : $:$) – complex array
The first dimension of the array a must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The m$m$ by n$n$ matrix A$A$.
2:     b(ldb, : $:$) – complex array
The first dimension of the array b must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
The second dimension of the array must be at least max (1,p)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{p}}\right)$
The m$m$ by p$p$ matrix B$B$.
3:     d(m) – complex array
m, the dimension of the array, must satisfy the constraint m0${\mathbf{m}}\ge 0$.
The left-hand side vector d$d$ of the GLM equation.

### Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The dimension of the array d and the first dimension of the array b. (An error is raised if these dimensions are not equal.)
m$m$, the number of rows of the matrices A$A$ and B$B$.
Constraint: m0${\mathbf{m}}\ge 0$.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
n$n$, the number of columns of the matrix A$A$.
Constraint: 0nm$0\le {\mathbf{n}}\le {\mathbf{m}}$.
3:     p – int64int32nag_int scalar
Default: The second dimension of the array b.
p$p$, the number of columns of the matrix B$B$.
Constraint: pmn${\mathbf{p}}\ge {\mathbf{m}}-{\mathbf{n}}$.

### Input Parameters Omitted from the MATLAB Interface

lda ldb work lwork

### Output Parameters

1:     a(lda, : $:$) – complex array
The first dimension of the array a will be max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
2:     b(ldb, : $:$) – complex array
The first dimension of the array b will be max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
The second dimension of the array will be max (1,p)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{p}}\right)$
3:     d(m) – complex array
4:     x(n) – complex array
The solution vector x$x$ of the GLM problem.
5:     y(p) – complex array
The solution vector y$y$ of the GLM problem.
6:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: m, 2: n, 3: p, 4: a, 5: lda, 6: b, 7: ldb, 8: d, 9: x, 10: y, 11: work, 12: lwork, 13: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
INFO = 1${\mathbf{INFO}}=1$
The upper triangular factor R$R$ associated with A$A$ in the generalized RQ$RQ$ factorization of the pair (A,B)$\left(A,B\right)$ is singular, so that rank(A) < m$\mathrm{rank}\left(A\right); the least squares solution could not be computed.
INFO = 2${\mathbf{INFO}}=2$
The bottom (NM)$\left(N-M\right)$ by (NM)$\left(N-M\right)$ part of the upper trapezoidal factor T$T$ associated with B$B$ in the generalized QR$QR$ factorization of the pair (A,B)$\left(A,B\right)$ is singular, so that rank
 ( A B )
< N
$\mathrm{rank}\left(\begin{array}{cc}A& B\end{array}\right); the least squares solutions could not be computed.

## Accuracy

For an error analysis, see Anderson et al. (1992). See also Section 4.6 of Anderson et al. (1999).

When p = mn$p=m\ge n$, the total number of real floating point operations is approximately (8/3)(2m3n3) + 16nm2$\frac{8}{3}\left(2{m}^{3}-{n}^{3}\right)+16n{m}^{2}$; when p = m = n$p=m=n$, the total number of real floating point operations is approximately (56/3)m3$\frac{56}{3}{m}^{3}$.

## Example

```function nag_lapack_zggglm_example
a = [ 0.96 - 0.81i,  -0.03 + 0.96i,  -0.91 + 2.06i;
-0.98 + 1.98i,  -1.2 + 0.19i,  -0.66 + 0.42i;
0.62 - 0.46i,  1.01 + 0.02i,  0.63 - 0.17i;
1.08 - 0.28i,  0.2 - 0.12i,  -0.07 + 1.23i];
b = [ 0.5 - 1i,  0 + 0i,  0 + 0i,  0 + 0i;
0 + 0i,  1 - 2i,  0 + 0i,  0 + 0i;
0 + 0i,  0 + 0i,  2 - 3i,  0 + 0i;
0 + 0i,  0 + 0i,  0 + 0i,  5 - 4i];
d = [ 6 - 0.4i;
-5.27 + 0.9i;
2.72 - 2.13i;
-1.3 - 2.8i];
[aOut, bOut, dOut, x, y, info] = nag_lapack_zggglm(a, b, d)
```
```

aOut =

-2.8809 + 0.0000i  -0.5597 - 1.2116i   0.3523 - 1.2597i
-0.3484 + 0.4420i   1.3009 + 0.0000i   1.5520 - 0.4961i
0.1787 - 0.0821i  -0.5245 - 0.0361i   1.8059 + 0.0000i
0.2839 - 0.0130i  -0.2338 + 0.4152i  -0.3539 - 0.7964i

bOut =

1.8936 + 0.0000i  -1.3320 + 0.3960i   0.1213 - 1.4943i   1.4096 + 0.7140i
0.3756 - 0.1350i   1.9049 + 0.0000i  -2.7958 - 0.0662i   0.4497 - 0.1602i
0.1262 + 0.0131i   0.1989 + 0.0903i   4.1872 + 0.0000i  -1.5248 + 1.9624i
-0.0015 + 0.0595i   0.1014 + 0.1408i   0.3901 + 0.3498i  -3.8214 + 0.0000i

dOut =

-0.9846 + 1.9950i
3.9929 - 4.9748i
-3.0026 + 0.9994i
-0.0057 + 0.0007i

x =

-0.9846 + 1.9950i
3.9929 - 4.9748i
-3.0026 + 0.9994i

y =

0.0001 - 0.0005i
0.0011 - 0.0009i
0.0038 - 0.0018i
0.0020 + 0.0030i

info =

0

```
```function f08zp_example
a = [ 0.96 - 0.81i,  -0.03 + 0.96i,  -0.91 + 2.06i;
-0.98 + 1.98i,  -1.2 + 0.19i,  -0.66 + 0.42i;
0.62 - 0.46i,  1.01 + 0.02i,  0.63 - 0.17i;
1.08 - 0.28i,  0.2 - 0.12i,  -0.07 + 1.23i];
b = [ 0.5 - 1i,  0 + 0i,  0 + 0i,  0 + 0i;
0 + 0i,  1 - 2i,  0 + 0i,  0 + 0i;
0 + 0i,  0 + 0i,  2 - 3i,  0 + 0i;
0 + 0i,  0 + 0i,  0 + 0i,  5 - 4i];
d = [ 6 - 0.4i;
-5.27 + 0.9i;
2.72 - 2.13i;
-1.3 - 2.8i];
[aOut, bOut, dOut, x, y, info] = f08zp(a, b, d)
```
```

aOut =

-2.8809 + 0.0000i  -0.5597 - 1.2116i   0.3523 - 1.2597i
-0.3484 + 0.4420i   1.3009 + 0.0000i   1.5520 - 0.4961i
0.1787 - 0.0821i  -0.5245 - 0.0361i   1.8059 + 0.0000i
0.2839 - 0.0130i  -0.2338 + 0.4152i  -0.3539 - 0.7964i

bOut =

1.8936 + 0.0000i  -1.3320 + 0.3960i   0.1213 - 1.4943i   1.4096 + 0.7140i
0.3756 - 0.1350i   1.9049 + 0.0000i  -2.7958 - 0.0662i   0.4497 - 0.1602i
0.1262 + 0.0131i   0.1989 + 0.0903i   4.1872 + 0.0000i  -1.5248 + 1.9624i
-0.0015 + 0.0595i   0.1014 + 0.1408i   0.3901 + 0.3498i  -3.8214 + 0.0000i

dOut =

-0.9846 + 1.9950i
3.9929 - 4.9748i
-3.0026 + 0.9994i
-0.0057 + 0.0007i

x =

-0.9846 + 1.9950i
3.9929 - 4.9748i
-3.0026 + 0.9994i

y =

0.0001 - 0.0005i
0.0011 - 0.0009i
0.0038 - 0.0018i
0.0020 + 0.0030i

info =

0

```