Rate This Document
Findability
Accuracy
Completeness
Readability

?(or,un)gtr

Generate an orthogonal matrix Q through reflector factors computed by a call to SYTRD.

Interface Definition

C interface:

sorgtr_(const char *uplo, const int *n, float *a, const int *lda, const float *tau, float *work, const int *lwork, int *info);

dorgtr_(const char *uplo, const int *n, double *a, const int *lda, const double *tau, double *work, const int *lwork, int *info);

cungtr_(const char *uplo, const int *n, float _Complex *a, const int *lda, const float _Complex *tau, float _Complex *work, const int *lwork, int *info);

zungtr_(const char *uplo, const int *n, double _Complex *a, const int *lda, const double _Complex *tau, double _Complex *work, const int *lwork, int *info);

Fortran interface:

SORGTR(UPLO, N, A, LDA, TAU, WORK, LWORK, INFO);

DORGTR(UPLO, N, A, LDA, TAU, WORK, LWORK, INFO);

CUNGTR(UPLO, N, A, LDA, TAU, WORK, LWORK, INFO);

ZUNGTR(UPLO, N, A, LDA, TAU, WORK, LWORK, INFO);

Parameters

Parameter

Type

Description

Input/Output

uplo

Character

  • 'U': Stores the upper triangular part of A.
  • 'L': Stores the lower triangular part of A.

Input

n

Integer

Dimension of matrix A, n ≥ 0.

Input

a

  • A single-precision floating-point array for sorgtr
  • A double-precision floating-point array for dorgtr
  • A single-precision complex array for cungtr
  • A double-precision complex array for zungtr

Array with a size of lda*n.

  • On entry: reflector.
  • On exit: n*n orthogonal matrix Q.

Input/Output

lda

Integer

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

Input

tau

  • A single-precision floating-point array for sorgtr
  • A double-precision floating-point array for dorgtr
  • A single-precision complex array for cungtr
  • A double-precision complex array for zungtr

Array with a size of n-1.

This array represents the scalar factors of H.

Input

work

  • A single-precision floating-point array for sorgtr
  • A double-precision floating-point array for dorgtr
  • A single-precision complex array for cungtr
  • A double-precision complex array for zungtr

Work array, with a size of max(1, lwork).

If info=0, work(0) returns the optimal lwork size.

Output

lwork

Integer

Size of work.

  • If lwork≥n - 1, lwork≥(n–1)*nb is recommended to obtain optimal performance, where nb is an optimal block size.
  • If lwork=-1, work returns the optimal size.

Input

Info

Integer

  • 0: The execution is successful.
  • Smaller than 0: If info = -i, the i-th parameter has an illegal value.

Output

Dependency

#include "klapack.h"

Examples

C interface:

char uplo = 'L';
int n = 4;
int lda = n;
int info = 0;
double tau[4] = {1.003949, 1.125229, 1.978923, 0.000000};
double *work = NULL;
double qwork;
int lwork = -1;
double *d = (double*)malloc(n * sizeof(double));
double *e = (double*)malloc((n - 1) * sizeof(double));
/*
 * tau:
 *   1.003949  1.125229  1.978923  0.000000
 * A (4x4, stored in column-major):
 *   7.027  8.710  1.015  6.929
 *   8.710  0.839  2.469  3.850
 *   1.015  2.469  1.930  6.761
 *   6.929  3.850  6.761  4.344
 *
 */
double a[] = {7.027, 8.710, 1.015, 6.929,
             8.710, 0.839, 2.469, 3.850,
             1.015, 2.469, 1.930, 6.761,
             6.929, 3.850, 6.761, 4.344};

/* Query optimal work size */
dsytrd_(&uplo, &n, a, &lda, d, e, tau, &qwork, &lwork, &info);
if (info != 0) {
    printf("ERROR, info = %d\n", info);
    return 1;
}
lwork = (int)qwork;
work = (double *)malloc(sizeof(double) * lwork);
/* Calculate Q */
dsytrd_(&uplo, &n, a, &lda, d, e, tau, work, &lwork, &info);

dorgtr_(&uplo, &n, a, &lda, tau, work, &lwork, &info);
/* output */
* a
* 1.000000        0.000000        0.000000        0.000000
* 0.000000        -0.779341       0.346782        -0.521890
* 0.000000        -0.090819       -0.886612       -0.453510
* 0.000000        -0.619983       -0.306042       0.722467

Fortran interface:

CHARACTER :: uplo = "L"
PARAMETER (n = 4)
PARAMETER (lda = 4)  

INTEGER :: info = 0 
REAL(8) :: a(lda, n) 
REAL(8) :: d(n) 
REAL(8) :: e(n-1) 
REAL(8) :: tau(n)
REAL(8), ALLOCATABLE :: work(:)
REAL(8) :: qwork(1)
INTEGER :: lwork = -1
  
DATA a / 7.027, 8.710, 1.015, 6.929,
&        8.710, 0.839, 2.469, 3.850,
&        1.015, 2.469, 1.930, 6.761,
&        6.929, 3.850, 6.761, 4.344 / 

DATA tau / 1.003949, 1.125229, 1.978923, 0.000000 /
EXTERNAL DSYTRD,DORGTR
CALL DSYTRD(uplo, n, a, lda, d, e, tau, qwork, lwork, info)
IF (info.NE.0) THEN 
    CALL EXIT(1) 
END IF
lwork = INT(qwork(1))  
ALLOCATE(work(lwork))
CALL DSYTRD(uplo, n, a, lda, d, e, tau, qwork, lwork, info)
IF (info.NE.0) THEN 
    CALL EXIT(1) 
END IF
CALL DORGTR(uplo, n, a, lda, tau, work, lwork, info)
DEALLOCATE(work);
* 
* Output: 
* a
* 
1.000000        0.000000        0.000000        0.000000
* 0.000000        -0.779341       0.346782        -0.521890
* 0.000000        -0.090819       -0.886612       -0.453510
* 0.000000        -0.619983       -0.306042       0.722467