Rate This Document
Findability
Accuracy
Completeness
Readability

?(or,un)gql

Generate a real/complex matrix Q with orthogonal columns. The matrix is defined as the first N columns of the product of K M-order elementary reflectors, i.e. Q=H(k)...H(2)H(1), where H is returned by calling ?geqlf.

Interface Definition

C interface:

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

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

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

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

Fortran interface:

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

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

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

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

Parameters

Parameter

Type

Description

Input/Output

m

Integer

Number of rows in Q. m ≥ 0

Input

n

Integer

Number of columns in Q. m ≥ n ≥ 0

Input

k

Integer

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

Input

a

  • A single-precision floating-point array in sorgql
  • A double-precision floating-point array in dorgql
  • A single-precision complex array in cungql
  • A double-precision complex array in zungql

Dimension (lda, n).

  • If a is used as an input, column i must contain the elementary reflector H(i) vector, where H(i) is returned by ?geqlf.
  • If it is used as an output, it is an m*n matrix Q.

Input/Output

lda

Integer

Leading dimension of matrix A. lda ≥ max(1, M)

Input

tau

  • A single-precision floating-point array in sorgql
  • A double-precision floating-point array in dorgql
  • A single-precision complex array in cungql
  • A double-precision complex array in zungql

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

Input

work

  • A single-precision floating-point array in sorgql
  • A double-precision floating-point array in dorgql
  • A single-precision complex array in cungql
  • A double-precision complex array in zungql

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, N). For the optimal performance, lwork ≥ N*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 = m; 
    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 */ 
    dorgql_(&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 */ 
    dorgql_(&m, &n, &k, a, &lda, tau, work, &lwork, &info); 
    free(work); 
    /* 
     * Output: 
     * A output (stored in column-major) 
     *   -0.001005       -0.000771       0.004959        0.000000 
     *   0.956417        0.131450        0.398383        0.000000 
     *   0.237698        -1.275024       -0.978923       0.000000 
     *   -0.000000       -0.000000       -0.000000       1.000000 
     */

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 DORGQL(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 DORGQL(m, n, k, a, lda, tau, work, lwork, info) 
        DEALLOCATE(work) 
 * 
 * Output: 
 * A output (stored in column-major) 
 *   -0.001005       -0.000771       0.004959        0.000000 
 *   0.956417        0.131450        0.398383        0.000000 
 *   0.237698        -1.275024       -0.978923       0.000000 
 *   -0.000000       -0.000000       -0.000000       1.000000