?stedc
对称三对角矩阵的特征值求解,使用Divide-and-Conquer算法。
接口定义
C Interface:
sstedc_(const char *compz, const int *n, float *d, float *e, float *z, const int *ldz, float *work, const int lwork, float *rwork, const int *lrwork,
int *iwork, const int *liwork, int *info);
dstedc_(const char *compz, const int *n, double *d, double *e, double *z, const int *ldz, double *work, const int lwork, double *rwork, const int *lrwork,
int *iwork, const int *liwork, int *info);
cstedc_(const char *compz, const int *n, float *d, float *e, float _Complex *z, const int *ldz, float _Complex *work, const int lwork, float *rwork, const int *lrwork,
int *iwork, const int *liwork, int *info);
zstedc_(const char *compz, const int *n, double *d, double *e, double _Complex *z, const int *ldz, double _Complex *work, const int lwork, double *rwork, const int *lrwork,
int *iwork, const int *liwork, int *info);
Fortran Interface:
SSTEDC(COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO);
DSTEDC(COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO);
CSTEDC(COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO);
ZSTEDC(COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK, LRWORK, IWORK, LIWORK, INFO);
参数
参数 |
类型 |
说明 |
输入/输出 |
---|---|---|---|
compz |
字符型 |
|
输入 |
n |
整数型 |
矩阵的维度,n≥0 |
输入 |
d |
|
长度为n
|
输入,输出 |
e |
|
长度为n-1
|
输入,输出 |
z |
|
大小为ldz*n
|
输入,输出 |
ldz |
整数型 |
矩阵z的主维,ldz >=1; 若需要求特征向量,则ldz ≥ max(1, n)。 |
输入 |
work |
|
|
输出 |
lwork |
整数型 |
work数组的大小
|
输入 |
rwork |
|
|
输出 |
lrwork |
整数型 |
rwork数组的大小
|
输入 |
iwork |
整数型 |
|
输出 |
liwork |
整数型 |
iwork数组的大小
|
输入 |
info |
整数型 |
|
输出 |
依赖
#include "klapack.h"
示例
C Interface:
const char compz = 'N'; const int n = 4; const int ldz = 4; double d[] = {72.1673, 66.1857, 64.7644, 28.0199, 91.4151}; double e[] = {6.8955, 7.2465, 3.5019, 8.2268, 3.5287}; double z[] = {0.924528, 0.056604, 0.415094, 0.924528, 0.622642, 0.905660, 0.150943, 0.471698, 0.132075, 0.566038, 0.811321, 0.924528, 0.339623, 0.283019, 0.679245, 0.283019}; int lwork = 1; int liwork = 1; double *work = (double*)malloc(lwork * sizeof(double)); double *iwork = (double*)malloc(liwork * sizeof(double)); int info = 0; dstedc_(&compz, &n, d, e, z, &ldz, work, &lwork, iwork, &liwork, &info); if (info != 0) { printf("ERROR, info = %d\n", info); } /* output */ * d * 27.676252 56.816901 68.501999 78.142148 * e * 0.000000 0.000000 0.000000 * z * 0.924528 0.056604 0.415094 0.924528 0.622642 0.905660 0.150943 0.471698 0.132075 0.566038 * 0.811321 0.924528 0.339623 0.283019 0.679245 0.283019
Fortran Interface:
CHARACTER :: compz = "N" PARAMETER (n = 4) PARAMETER (ldz = 4) PARAMETER (lwork = 1) PARAMETER (liwork = -1) INTEGER :: info = 0 REAL(8) :: d(n) REAL(8) :: e(n-1) REAL(8) :: z(ldz, n) REAL(8) :: work(lwork) REAL(8) :: iwork(liwork) DATA d / 72.1673, 66.1857, 64.7644, 28.0199 / DATA e / 6.8955, 7.2465, 3.5019 / DATA z / 0.924528, 0.056604, 0.415094, 0.924528, 0.622642, 0.905660, 0.150943, 0.471698, 0.132075, 0.566038, 0.811321, 0.924528, 0.339623, 0.283019, 0.679245, 0.283019/ EXTERNAL DSTEDC CALL DSTEDC(compz, n, d, e, z, ldz, work, liwork, iwork, liwork, info); * * Output: * d: * 27.676252 56.816901 68.501999 78.142148 * e: * 0.000000 0.000000 0.000000 * z: * 0.924528 0.056604 0.415094 0.924528 0.622642 0.905660 0.150943 0.471698 0.132075 0.566038 * 0.811321 0.924528 0.339623 0.283019 0.679245 0.283019