# ?gelq2

Computes the LQ factorization of a general rectangular matrix using an unblocked algorithm.

## Syntax

call sgelq2( m, n, a, lda, tau, work, info )

call dgelq2( m, n, a, lda, tau, work, info )

call cgelq2( m, n, a, lda, tau, work, info )

call zgelq2( m, n, a, lda, tau, work, info )

## Description

The routine computes an LQ factorization of a real/complex m-by-n matrix A as `A = L*Q`.

The routine does not form the matrix Q explicitly. Instead, Q is represented as a product of min(m, n) elementary reflectors :

`Q = H(k) ... H(2) H(1)` (or `Q = H(k)' ... H(2)' H(1)'` for complex flavors), where `k = min(m, n)`

Each H(i) has the form

`H(i) = I - tau*v*v'`

where tau is a real/complex scalar stored in tau(i), and v is a real/complex vector with `v(1:i-1) = 0` and `v(i) = 1`.

On exit, `v(i+1:n)` is stored in `a(i, i+1:n)`.

## Input Parameters

m

  INTEGER. The number of rows in the matrix A (`m ≥ 0`).

n

  INTEGER. The number of columns in A (`n ≥ 0`).

a, work

  REAL for sgelq2

  DOUBLE PRECISION for dgelq2

  COMPLEX for cgelq2

  COMPLEX*16 for zgelq2.

  Arrays: a(lda,*) contains the m-by-n matrix A. The second dimension of a must be at least `max(1, n)`.

  work(m) is a workspace array.

lda

  INTEGER. The first dimension of a; at least max(1, m).

## Output Parameters

a

  Overwritten by the factorization data as follows:

  on exit, the elements on and below the diagonal of the array a contain the m-by-min(n,m) lower trapezoidal matrix L (L is lower triangular if `n ≥ m`); the elements above the diagonal, with the array tau, represent the orthogonal/unitary matrix Q as a product of min(n,m) elementary reflectors.

tau

  REAL for sgelq2

  DOUBLE PRECISION for dgelq2

  COMPLEX for cgelq2

  COMPLEX*16 for zgelq2.

  Array, DIMENSION at least `max(1, min(m, n))`.

  Contains scalar factors of the elementary reflectors.

info

  INTEGER.

  If `info = 0`, the execution is successful.

  If `info = -i`, the i-th parameter had an illegal value.

Parent topic: Auxiliary Routines