Rate This Document
Findability
Accuracy
Completeness
Readability

?sy(he)trd_2stage

Transform a symmetric or Hermitian matrix to symmetric or Hermitian tridiagonal. That is, AH * A * Q = T, where Q is an orthogonal matrix.

Interface Definition

C interface:

void ssytrd_2stage(const char *VECT, const char *UPLO, const int *N, float *A, const int *LDA, float *D, float *E, float *TAU, float *HOUS2, int *LHOUS2, float *WORK, const int *LWORK, int *INFO);

void dsytrd_2stage(const char *VECT, const char *UPLO, const int *N, double *A, const int *LDA, double *D, double *E, double *TAU, double *HOUS2, int *LHOUS2, double *WORK, const int *LWORK, int *INFO);

void chetrd_2stage(const char *VECT, const char *UPLO, const int *N, float _Complex *A, const int *LDA, float *D, float *E, float _Complex *TAU, float _Complex *HOUS2, int *LHOUS2, float _Complex *WORK, const int *LWORK, int *INFO);

void zhetrd_2stage(const char *VECT, const char *UPLO, const int *N, double _Complex *A, const int *LDA, double *D, double *E, double _Complex *TAU, double _Complex *HOUS2, int *LHOUS2, double _Complex *WORK, const int *LWORK, int *INFO);

Fortran interface:

SSYTRD_2STAGE(VECT, UPLO, N, A, LDA, D, E, TAU, HOUS2, LHOUS2, WORK, LWORK, INFO);

DSYTRD_2STAGE(VECT, UPLO, N, A, LDA, D, E, TAU, HOUS2, LHOUS2, WORK, LWORK, INFO);

CHETRD_2STAGE(VECT, UPLO, N, A, LDA, D, E, TAU, HOUS2, LHOUS2, WORK, LWORK, INFO);

ZHETRD_2STAGE(VECT, UPLO, N, A, LDA, D, E, TAU, HOUS2, LHOUS2, WORK, LWORK, INFO);

Parameters

Parameter

Type

Description

Input/Output

VECT

Character

  • 'N': A Householder expression is not required.
  • 'V': A Householder expression is required.

Input

UPLO

Character

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

Input

N

  • For ssytrd_2stage, N is a single-precision floating-point array.
  • For dsytrd_2stage, N is a double-precision floating-point array.
  • For chetrd_2stage, N is a single-precision complex number array.
  • For zhetrd_2stage, N is a double-precision complex number array.

Number of columns of matrix A, N ≥ 0

Input

A

  • For ssytrd_2stage, A is a single-precision floating-point array.
  • For dsytrd_2stage, A is a double-precision floating-point array.
  • For chetrd_2stage, A is a single-precision complex number array.
  • For zhetrd_2stage, A is a double-precision complex number array.

Matrix A, with a dimension of (LDA, N)

Input/Output

LDA

Integer

Leading dimension of matrix A. LDA ≥ max(1, N)

Input

D

  • For ssytrd_2stage or chetrd_2stage, D is a single-precision floating-point array.
  • For dsytrd_2stage or zhetrd_2stage, D is a double-precision floating-point array.

Diagonal element of symmetric tridiagonal matrix T, with a dimension of N

Output

E

  • For ssytrd_2stage or chetrd_2stage, E is a single-precision floating-point array.
  • For dsytrd_2stage or zhetrd_2stage, E is a double-precision floating-point array.

Non-diagonal element of symmetric tridiagonal matrix T, with a dimension of N-1

Output

TAU

  • For ssytrd_2stage, TAU is a single-precision floating-point array.
  • For dsytrd_2stage, TAU is a double-precision floating-point array.
  • For chetrd_2stage, TAU is a single-precision complex number array.
  • For zhetrd_2stage, TAU is a double-precision complex number array.

Scalar factor for the elementary reflector

Output

HOUS2

  • For ssytrd_2stage, HOUS2 is a single-precision floating-point array.
  • For dsytrd_2stage, HOUS2 is a double-precision floating-point array.
  • For chetrd_2stage, HOUS2 is a single-precision complex number array.
  • For zhetrd_2stage, HOUS2 is a double-precision complex number array.

Householder expression in the second phase

Output

LHOUS2

Integer

Length of HOUS2

  • If VECT = 'N', LHOUS2 = max(1, 4*n).
  • If VECT = 'V', this parameter is unavailable.

Input

WORK

  • For ssytrd_2stage, WORK is a single-precision floating-point array.
  • For dsytrd_2stage, WORK is a double-precision floating-point array.
  • For chetrd_2stage, WORK is a single-precision complex number array.
  • For zhetrd_2stage, WORK is a double-precision complex number array.

Work array, with a size of LWORK

Output

LWORK

Integer

Length of the work array, LWORK ≥ max(1, dimension). dimension = max(stage1, stage2) + (KD+1)*N = N*KD + N*max(KD+1, FACTOPTNB) + max(2*KD*KD, KD*NTHREADS) + (KD+1)*N. When LWORK = -1, the optimal LWORK value is returned.

Input

INFO

Integer

  • 0: The exit is successful.
  • Smaller than 0: The -INFO-th parameter is invalid.

Output

Dependencies

include "klapack.h"

Examples

C interface:

char vect = 'N';
char uplo = 'L';
int n = 4; 
int lda = n; 
int info = 0; 
double tau = (double*)malloc(n * sizeof(double)); 
double *work = NULL; 
double *hous2 = NULL;
double qwork; 
double qhous2;
int lwork = -1;
int lhous2 = -1; 
double *d = (double*)malloc(n * sizeof(double));
double *e = (double*)malloc((n - 1) * sizeof(double));

double a[] = {0.521739, 0.043478, 0.304348, 0.130435,
              0.043478, 0.304348, 0.043478, 0.652174,
              0.304348, 0.043478, 0.086957, 0.521739,
              0.130435, 0.652174, 0.521739, 0.086957}; 

/* Query optimal work size and hous2 size */ 
dsytrd_2stage_(&vect, &uplo, &n, a, &lda, d, e, tau, &qhous2, &lhous2, &qwork, &lwork, &info) 
if (info != 0) { 
    return ERROR; 
} 
lwork = (int)qwork; 
work = (double *)malloc(sizeof(double) * lwork); 
lhous2 = (int)qhous2;
hous2 = (double*)malloc(lhous2 * sizeof(double));

/* Calculate */ 
dsytrd_2stage_(&vect, &uplo, &n, a, &lda, d, e, tau, hous2, &lhous2, work, &lwork, &info);
if (info != 0) { 
    return ERROR; 
}

free(work); 
free(hous2);
free(tau);

/* 
* Output: 
* A output (stored in column-major) 
*   0.521739        0.043478        0.304348        0.130435
*   0.043478        0.304348        0.043478        0.652174
*   0.304348        0.043478        0.086957        0.521739
*   0.130435        0.652174        0.521739        0.086957
*
* D output (stored in column-major)
*   0.521739        0.538688        0.325765        -0.386192
*
* E output (stored in column-major)
*   -0.333963       -0.507861       -0.471868
*/

Fortran interface:

CHARACTER :: vect = "N"
CHARACTER :: uplo = "L"        
PARAMETER (n = 4) 
PARAMETER (lda = 4) 
INTEGER :: info = 0 
REAL(8) :: tau(4) 
REAL(8) :: qwork(1) 
REAL(8) :: qhous2(1)
INTEGER :: lwork = -1 
INTEGER :: lhous2 = -1
REAL(8), ALLOCATABLE :: work(:) 
REAL(8), ALLOCATABLE :: hous2(:)
REAL(8), ALLOCATABLE :: d(:)
REAL(8), ALLOCATABLE :: e(:)
* 
*       tau: 
*         1.003949  1.125229  1.978923  0.000000 
*       A (4x4, stored in column-major): 
*         0.521739, 0.043478, 0.304348, 0.130435,
*         0.043478, 0.304348, 0.043478, 0.652174,
*         0.304348, 0.043478, 0.086957, 0.521739,
*         0.130435, 0.652174, 0.521739, 0.086957

*  
        REAL(8) :: a(m, n) 
        DATA a / 0.521739, 0.043478, 0.304348, 0.130435, 
     $           0.043478, 0.304348, 0.043478, 0.652174,
     $           0.304348, 0.043478, 0.086957, 0.521739, 
     $           0.130435, 0.652174, 0.521739, 0.086957 / 
 
        EXTERNAL DORGLQ 
*       Query optimal work size and hous2 size.
        CALL DSYTRD_2STAGE(vect, uplo, n, a, lda, d, e, tau, qhous2, lhous2, qwork, lwork, info) 
        IF (info.NE.0) THEN 
            CALL EXIT(1) 
        END IF 
        lwork = INT(qwork(1)) 
        ALLOCATE(work(lwork)) 
        lhous2 = INT(qhous2(1)) 
        ALLOCATE(hous2(lhous2))
*       Calculate 
        CALL DSYTRD_2STAGE(vect, uplo, n, a, lda, d, e, tau, hous2, lhous2, work, lwork, info) 
        DEALLOCATE(work) 
        DEALLOCATE(hous2) 
 
* Output: 
* A output (stored in column-major) 
*   0.521739        0.043478        0.304348        0.130435
*   0.043478        0.304348        0.043478        0.652174
*   0.304348        0.043478        0.086957        0.521739
*   0.130435        0.652174        0.521739        0.086957
*
* D output (stored in column-major)
*   0.521739        0.538688        0.325765        -0.386192
*
* E output (stored in column-major)
*   -0.333963       -0.507861       -0.471868