?sy(he)trd_2stage
将对称矩阵或Hermite矩阵A转为对称或Hermite三对角矩阵T,即A**H*A*Q=T,其中Q为正交矩阵。
接口定义
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);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
VECT |
字符型 |
|
输入 |
UPLO |
字符型 |
|
输入 |
N |
|
矩阵A的列数,N ≥ 0。 |
输入 |
A |
|
矩阵A,维度为(LDA, N)。 |
输入、输出 |
LDA |
整数型 |
矩阵A的主维, LDA ≥ max(1, N)。 |
输入 |
D |
|
对称三对角矩阵T的对角元素,大小为N。 |
输出 |
E |
|
对称三对角矩阵T的非对角元素,大小为N-1。 |
输出 |
TAU |
|
基本反射器的标量因子。 |
输出 |
HOUS2 |
|
存放第二阶段中Householder表达形式。 |
输出 |
LHOUS2 |
整数型 |
HOUS2的长度。
|
输入 |
WORK |
|
工作数组,大小为LWORK。 |
输出 |
LWORK |
整数型 |
工作数组的长度,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,当LWORK=-1时,返回最优LWORK值。 |
输入 |
INFO |
整数型 |
|
输出 |
依赖
include "klapack.h"
示例
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