?ppsv
求解线性方程组。其中A为实对称或共轭对称的正定矩阵,以压缩方式存储;X和B为矩阵。计算矩阵A的Cholesky分解,并通过分解结果求解线性方程组。
接口定义
C Interface:
void dppsv_(const char *uplo, const int *n, const int *nrhs, double *ap, double *b, const int *ldb, int *info);
void sppsv_(const char *uplo, const int *n, const int *nrhs, float *ap, float *b, const int *ldb, int *info);
void cppsv_(const char *uplo, const int *n, const int *nrhs, float _Complex *ap, float _Complex *b, const int *ldb, int *info);
void zppsv_(const char *uplo, const int *n, const int *nrhs, double _Complex *ap, double _Complex *b, const int *ldb, int *info);
Fortran Interface:
DPPSV(uplo, n, nrhs, ap, b, ldb, info);
SPPSV(uplo, n, nrhs, ap, b, ldb, info);
CPPSV(uplo, n, nrhs, ap, b, ldb, info);
ZPPSV(uplo, n, nrhs, ap, b, ldb, info);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
uplo |
字符型 |
|
输入 |
n |
整数型 |
对称矩阵A的行数或列数。 |
输入 |
nrhs |
整数型 |
右侧项的数量,即矩阵B的列数,要求nrhs≥0。 |
输入 |
ap |
|
|
输入/输出 |
b |
|
|
输入/输出 |
ldb |
整数型 |
B的leading dimension大小,要求ldb≥max(1, n)。 |
输入 |
info |
整数型 |
执行结果:
|
输出 |
依赖
#include "klapack.h"
示例
C Interface:
char uplo = 'L'; int n = 5; int nrhs = 2; int ldb = 5; int info = 0; /* * A (stored in column-major): * 178.535 33.2929 9.2538 11.1156 21.5482 * 33.2929 156.5955 5.1031 55.771 41.3063 * 9.2538 5.1031 100.5198 73.8396 23.04 * 11.1156 55.771 73.8396 106.5638 56.19 * 21.5482 41.3063 23.04 56.19 114.5161 */ double ap[] = {178.535, 33.2929, 9.2538, 11.1156, 21.5482, 156.5955, 5.1031, 55.771, 41.3063, 100.5198, 73.8396, 23.04, 106.5638, 56.19, 114.5161}; double b[] = {0.374, 6.242, 5.593, 2.456, 5.222, 6.906, 2.31 , 3.948, 6.403, 5.664}; dppsv_(&uplo, &n, &nrhs, ap, b, &ldb, &info); /* * Output X: * -0.0186 0.0373 * 0.0770 -0.0235 * 0.1536 -0.0208 * -0.1574 0.0726 * 0.0677 0.0195 */
Fortran Interface:
CHARACTER :: uplo = "L" PARAMETER (n = 5) PARAMETER (nrhs = 2) PARAMETER (ldb = 5) INTEGER :: info = 0 * A (stored in column-major): * 178.535 33.2929 9.2538 11.1156 21.5482 * 33.2929 156.5955 5.1031 55.771 41.3063 * 9.2538 5.1031 100.5198 73.8396 23.04 * 11.1156 55.771 73.8396 106.5638 56.19 * 21.5482 41.3063 23.04 56.19 114.5161 REAL(8) :: ap(15) DATA ap / 178.535, 33.2929, 9.2538, 11.1156, 21.5482, $ 156.5955, 5.1031, 55.771, 41.3063, $ 100.5198, 73.8396, 23.04, $ 106.5638, 56.19, $ 114.5161 / REAL(8) :: b(n, nrhs) DATA b / 0.374, 6.242, 5.593, 2.456, 5.222, $ 6.906, 2.31 , 3.948, 6.403, 5.664 / EXTERNAL DPPSV CALL DPPSV(uplo, n, nrhs, ap, b, ldb, info); * Output X: * -0.0186 0.0373 * 0.0770 -0.0235 * 0.1536 -0.0208 * -0.1574 0.0726 * 0.0677 0.0195