Rate This Document
Findability
Accuracy
Completeness
Readability

?(or,un)glq

Generate a real or complex number matrix Q with orthonormal rows. The matrix is defined as the first M rows of the product of K N-order elementary reflectors, i.e. Q=H(k)...H(2)H(1), where H is returned by ?gelqf.

Interface Definition

C interface:

void sorglq_(const int *m, const int *n, const int *k, float *a, const int *lda, const float *tau, float *work, const int *lwork, int *info);

void dorglq_(const int *m, const int *n, const int *k, double *a, const int *lda, const double *tau, double *work, const int *lwork, int *info);

void cunglq_(const int *m, const int *n, const int *k, float_Complex *a, const int *lda, const float_Complex *tau, float_Complex *work, const int *lwork, int *info);

void zunglq_(const int *m, const int *n, const int *k, double_Complex *a, const int *lda, const double_Complex *tau, double_Complex *work, const int *lwork, int *info);

Fortran interface:

SORGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);

DORGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);

CUNGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);

ZUNGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);

Parameters

Parameter

Type

Description

Input/Output

m

Integer

Number of rows in matrix Q. m ≥ 0

Input

n

Integer

Number of columns in matrix Q. n ≥ m

Input

k

Integer

Number of elementary reflectors whose product defines matrix Q. m ≥ k ≥ 0

Input

a

  • A single-precision floating-point array in sorglq.
  • A double-precision floating-point array in dorglq.
  • A single-precision complex number array in cunglq.
  • A double-precision complex number array in zunglq.

Dimension (lda, n).

  • When a is used as an input, row i must contain the basic reflector H(i) vector, where H(i) is returned by ?gelqf.
  • When a is used as an output, it is an m*n matrix Q.

Input/Output

lda

Integer

Leading dimension of matrix A. ldamax(1, m)

Input

tau

  • A single-precision floating-point array in sorglq.
  • A double-precision floating-point array in dorglq.
  • A single-precision complex number array in cunglq.
  • A double-precision complex number array in zunglq.

tau(i) must contain the constant factor of the elementary reflector H(i), which is returned by ?gelqf.

Input

work

  • A single-precision floating-point array in sorglq.
  • A double-precision floating-point array in dorglq.
  • A single-precision complex number array in cunglq.
  • A double-precision complex number array in zunglq.

Number of dimensions, max(1, lwork). If info = 0, work(1) returns the optimal lwork value.

Output

lwork

Integer

Number of dimensions of the work array. lwork ≥ max(1, m). For the optimal performance, lwork ≥ m*nb, where nb is the optimal block size. If lwork = -1, this routine calculates only the optimal size of the work array and returns the first value of the work array.

Input

info

Integer

  • info = 0: The execution is successful.
  • info < 0: If the value of info is -i, the ith parameter is invalid.

Output

Dependencies

#include "klapack.h"

Examples

C interface:

    int m = 4; 
    int n = 4; 
    int k = 4; 
    int lda = 4; 
    int info = 0; 
    double tau[4] = {1.003949, 1.125229, 1.978923, 0.000000}; 
    double *work = NULL; 
    double qwork; 
    int lwork = -1; 
    /* 
     * tau: 
     *   1.003949  1.125229  1.978923  0.000000 
     * A (4x4, stored in column-major): 
     *   -1.036040  -0.892502   -0.120115  -0.425611 
     *   0.654120   0.468127    0.644302   -0.601906 
     *   -0.135860  0.502159    1.077637   -0.103204 
     *   -0.480109  -1.207226   0.162668   0.227483 
     */ 
    double a[] = {-1.036040, 0.654120,  0.135860, -0.480109, 
                  -0.892502, 0.468127,  0.502159, -1.207226, 
                  -0.120115, 0.644302,  1.077637,  0.162668, 
                  -0.425611, -0.601906, -0.103204, 0.227483}; 
    /* Query optimal work size */ 
    dorglq_(&m, &n, &k, a, &lda, tau, &qwork, &lwork, &info); 
    if (info != 0) { 
        return ERROR; 
    } 
    lwork = (int)qwork; 
    work = (double *)malloc(sizeof(double) * lwork); 
    /* Calculate Q */ 
    dorglq_(&m, &n, &k, a, &lda, tau, work, &lwork, &info); 
    free(work); 
    /* 
     * Output: 
     * A output (stored in column-major) 
     *   -0.003949  0.089763  0.576860   0.811886 
     *   0.896027  -0.205343  0.333180   -0.209669 
     *   0.427292   0.639078  -0.551720  0.323428 
     *   0.120589  -0.735769  -0.501826  0.438490 
     */

Fortran interface:

        PARAMETER (m = 4) 
        PARAMETER (n = 4) 
        PARAMETER (k = 4) 
        PARAMETER (lda = 4) 
        INTEGER :: info = 0 
        REAL(8) :: tau(4) 
        REAL(8) :: qwork(1) 
        INTEGER :: lwork = -1 
        REAL(8), ALLOCATABLE :: work(:) 
* 
*       tau: 
*         1.003949  1.125229  1.978923  0.000000 
*       A (4x4, stored in column-major): 
*         -1.036040  -0.892502   -0.120115  -0.425611 
*         0.654120   0.468127    0.644302   -0.601906 
*         -0.135860  0.502159    1.077637   -0.103204 
*         -0.480109  -1.207226   0.162668   0.227483
 
* 
        DATA tau /1.003949, 1.125229, 1.978923, 0.000000/ 
        REAL(8) :: a(m, n) 
        DATA a / -1.036040, 0.654120,  0.135860, -0.480109, 
     $           -0.892502, 0.468127,  0.502159, -1.207226, 
     $           -0.120115, 0.644302,  1.077637,  0.162668, 
     $           -0.425611, -0.601906, -0.103204, 0.227483 / 
 
        EXTERNAL DORGLQ 
*       Query optimal work size 
        CALL DORGLQ(m, n, k, a, lda, tau, qwork, lwork, info) 
        IF (info.NE.0) THEN 
            CALL EXIT(1) 
        END IF 
        lwork = INT(qwork(1)) 
        ALLOCATE(work(lwork)) 
*       Calculate Q 
        CALL DORGLQ(m, n, k, a, lda, tau, work, lwork, info) 
        DEALLOCATE(work) 
 
*       Output: 
*       A output (stored in column-major) 
*        -0.003949  0.089763  0.576860   0.811886 
*        0.896027  -0.205343  0.333180   -0.209669 
*        0.427292   0.639078  -0.551720  0.323428 
*        0.120589  -0.735769  -0.501826  0.438490