The LA_GM_LINEAR_MODEL function is used to solve a general Gauss-Markov linear model problem:

minimize_{x}*||y||*_{2 }with constraint *d* = *Ax + By*

where *A* is an *m*-column by *n*-row array, *B* is a *p*-column by *n*-row array, and *d* is an *n*-element input vector with *m* ≤ *n* ≤ *m+p*.

The following items should be noted:

- If
*A*has full column rank*m*and the array (*A B*) has full row rank*n*, then there is a unique solution*x*and a minimal 2-norm solution*y*. - If
*B*is square and nonsingular then the problem is equivalent to a weighted linear least-squares problem, minimize_{x}*||B*^{-1}*(Ax - d)||*_{2}. - If
*B*is the identity matrix then the problem reduces to the ordinary linear least-squares problem, minimize_{x}*||Ax - d||*_{2}.

LA_ GM_LINEAR_MODEL is based on the following LAPACK routines:

Output Type |
LAPACK Routine |

Float |
sggglm |

Double |
dggglm |

Complex |
cggglm |

Double complex |
zggglm |

## Examples

Given the constraint equation *d = Ax + By*, (where *A*, *B*, and *d* are defined in the program below) the following example program solves the general Gauss-Markov problem:

`; Define some example coefficient arrays:`

a = [[2, 7, 4], $

[5, 1, 3], $

[3, 3, 6], $

[4, 5, 2]]

b = [[-3, 2], $

[1, 5], $

[2, 9], $

[4, 1]]

; Define a sample left-hand side vector D:

d = [-1, 2, -3, 4]

; Find and print the solution x:

`x = LA_GM_LINEAR_MODEL(a, b, d, y)`

PRINT, 'LA_GM_LINEAR_MODEL solution:'

`PRINT, X`

PRINT, 'LA_GM_LINEAR_MODEL 2-norm solution:'

`PRINT, Y`

When this program is compiled and run, IDL prints:

LA_GM_LINEAR_MODEL solution:

1.04668 0.350346 -1.28445

`LA_GM_LINEAR_MODEL 2-norm solution:`

0.151716 0.0235733

## Syntax

*Result* = LA_GM_LINEAR_MODEL( *A*, *B*, *D*, *Y* [, /DOUBLE] )

## Return Value

The result (*x*) is an *m*-element vector whose type is identical to *A*.

## Arguments

### A

The *m*-by-*n* array used in the constraint equation.

### B

The* p*-by-*n* array used in the constraint equation.

### D

An *n*-element input vector used in the constraint equation.

### Y

Set this argument to a named variable, which will contain the *p*-element output vector.

## Keywords

### DOUBLE

Set this keyword to use double-precision for computations and to return a double-precision (real or complex) result. Set DOUBLE = 0 to use single-precision for computations and to return a single-precision (real or complex) result. The default is /DOUBLE if *A* is double precision, otherwise the default is DOUBLE = 0.

## Version History

5.6 |
Introduced |

## Resources and References

For details see Anderson et al., *LAPACK Users' Guide*, 3rd ed., SIAM, 1999.

## See Also

LA_LEAST_SQUARE_EQUALITY, LA_LEAST_SQUARES