Rate This Document
Findability
Accuracy
Completeness
Readability

?sy(he)trd

Transform a symmetric or Hermitian matrix to symmetric tridiagonal form T by means of similarity transformation. That is, QH * A * Q = T.

Interface Definition

C interface:

void ssytrd_(const char *uplo, const int *n, float *a, const int *lda, float *d, float *e, float *tau, float *work, const int *lwork, int *info);

void dsytrd_(const char *uplo, const int *n, double *a, const int *lda, double *d, double *e, double *tau, double *work, const int *lwork, int *info);

void chetrd_(const char *uplo, const int *n, float _Complex *a, const int *lda, float *d, float *e, float _Complex *tau, float _Complex *work, const int *lwork, int *info);

void zhetrd_(const char *uplo, const int *n, double _Complex *a, const int *lda, double *d, double *e, double _Complex *tau, double _Complex *work, const int *lwork, int *info);

Fortran interface:

SSYTRD(UPLO,N,A,LDA,D,E,TAU,WORK,LWORK,INFO);

DSYTRD(UPLO,N,A,LDA,D,E,TAU,WORK,LWORK,INFO);

CHETRD(UPLO,N,A,LDA,D,E,TAU,WORK,LWORK,INFO);

ZHETRD(UPLO,N,A,LDA,D,E,TAU,WORK,LWORK,INFO);

Parameters

Parameter

Type

Description

Input/Output

uplo

Character

  • 'U': saves the upper triangular matrix of A.
  • 'L': saves the lower triangular matrix of A.

Input

N

Integer

Number of dimensions of matrix A, N ≥ 0

Input

A

  • A single-precision floating-point array in ssytrd
  • A double-precision floating-point array in dsytrd
  • A single-precision complex array in chetrd
  • A double-precision complex array in zhetrd
  • Saves the symmetric matrix to be factorized before calling.
  • Saves the eigenvectors after calling.

Input/Output

lda

Integer

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

Input

D

  • A single-precision floating-point array in ssytrd or chetrd
  • A double-precision floating-point array in dsytrd or zhetrd

A diagonal element of tridiagonal matrix T, that is, D(i) = A(i, i)

Output

E

  • A single-precision floating-point array in ssytrd or chetrd
  • A double-precision floating-point array in dsytrd or zhetrd

Non-diagonal elements of symmetric tridiagonal matrix T

  • If UPLO = "U", E(i) = A(i, i+1).
  • If UPLO = "L", E(i) = A(i+1, i).

Output

tau

  • A single-precision floating-point array in ssytrd
  • A double-precision floating-point array in dsytrd
  • A single-precision complex array in chetrd
  • A double-precision complex array in zhetrd

tau(i) must contain the constant factors of elementary reflectors, and the dimension is N-1.

Output

work

  • A single-precision floating-point array in ssytrd
  • A double-precision floating-point array in dsytrd
  • A single-precision complex array in chetrd
  • A double-precision complex array in zhetrd

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:

    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) { 
        return ERROR; 
    } 
    lwork = (int)qwork; 
    work = (double *)malloc(sizeof(double) * lwork); 
    /* Calculate Q */ 
    dsytrd_(&uplo, &n, a, &lda, d, e, tau, work, &lwork, &info); 
    free(work); 
    /* 
     * Output: 
     * A output (stored in column-major) 
     *   7.027000        -11.176107      0.051041        0.348434 
     *   8.710000        7.026600        6.375997        0.224161 
     *   1.015000        2.469000        3.358516        -1.395021 
     *   6.929000        3.850000        6.761000        -3.272116
     *
     * D output (stored in column-major)
     *   7.027000        7.026600        3.358516        -3.272116
     *
     * E output (stored in column-major)
     *   -11.176107      6.375997        -1.395021
     */

Fortran interface:

        CHARACTER :: uplo = "L"        
        PARAMETER (n = 4) 
        PARAMETER (lda = 4) 
        INTEGER :: info = 0 
        REAL(8) :: tau(4) 
        REAL(8) :: qwork(1) 
        INTEGER :: lwork = -1 
        REAL(8), ALLOCATABLE :: work(:) 
        REAL(8), ALLOCATABLE :: d(:)
        REAL(8), ALLOCATABLE :: e(:)
* 
*       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
* 
        DATA tau /1.003949, 1.125229, 1.978923, 0.000000/ 
        REAL(8) :: a(m, n) 
        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 / 
 
        EXTERNAL DORGLQ 
*       Query optimal work size 
        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)) 
*       Calculate Q 
        CALL DSYTRD(uplo, n, a, lda, d, e, tau, work, lwork, info) 
        DEALLOCATE(work) 
 
*       Output: 
*       A output (stored in column-major) 
*        7.027000        -11.176107      0.051041        0.348434 
*        8.710000        7.026600        6.375997        0.224161 
*        1.015000        2.469000        3.358516        -1.395021 
*        6.929000        3.850000        6.761000        -3.272116
*
*       D output (stored in column-major)
*        7.027000        7.026600        3.358516        -3.272116
*
*       E output (stored in column-major)
*        -11.176107      6.375997        -1.395021