?potrf
计算对称正定矩阵或者Hermite正定矩阵的Cholesky分解。
即或者,上三角矩阵,下三角矩阵。
接口定义
C Interface:
void spotrf_(const char *uplo, const int *n, float *a, const int *lda, int *info);
void dpotrf_(const char *uplo, const int *n, double *a, const int *lda, int *info);
void cpotrf_(const char *uplo, const int *n, float _Complex *a, const int *lda, int *info);
void zpotrf_(const char *uplo, const int *n, double _Complex *a, const int *lda, int *info);
Fortran Interface:
SPOTRF( uplo, n, a, lda, info);
DPOTRF( uplo, n, a, lda, info);
CPOTRF( uplo, n, a, lda, info);
ZPOTRF( uplo, n, a, lda, info);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
uplo |
字符型 |
'U':保存A的上三角矩阵。 'L':保存A的下三角矩阵。 |
输入 |
n |
整数型 |
对称矩阵A的行数或列数。 |
输入 |
a |
|
|
输入/输出 |
lda |
整数型 |
A的leading dimension大小,要求lda≥max(1, n)。 |
输入 |
info |
整数型 |
执行结果:
|
输出 |
依赖
#include "klapack.h"
示例
C Interface:
char uplo = 'L' int n = 4; int lda = 4; int info = 0; /* * A (stored in column-major): * 231.8009 33.9545 9.4153 11.1156 * 33.9454 162.2902 6.6684 53.2023 * 9.4153 6.6684 100.3220 71.5384 * 11.1156 53.2023 71.5384 123.4425 */ double a[] = {231.8009, 33.9545, 9.4143, 11.1156, 33.9495, 162.2902, 6.6684, 53.2033, 9.4143, 6.6684, 100.322, 71.5384, 11.1156, 53.2033, 71.5384, 106.5638 }; dpotrf_(&uplo, &n, a, &lda, &info); /* * Output: * 15.2250 33.9495 9.4143 11.1156 * 2.2302 12.5426 6.6684 53.2033 * 0.6183 0.4217 9.9881 71.5384 * 0.7301 4.112 6.9436 6.396 */
Fortran Interface:
CHARACTER :: uplo = "L" PARAMETER (n = 4) PARAMETER (lda = 4) INTEGER :: info = 0 REAL(8) :: a(n,n) * A (stored in column-major): * 231.8009 33.9545 9.4153 11.1156 * 33.9454 162.2902 6.6684 53.2023 * 9.4153 6.6684 100.3220 71.5384 * 11.1156 53.2023 71.5384 123.4425 DATA a / 231.8009, 33.9545, 9.4143, 11.1156, $ 33.9495, 162.2902, 6.6684, 53.2033, $ 9.4143, 6.6684, 100.322, 71.5384, $ 11.1156, 53.2033, 71.5384, 106.5638 / EXTERNAL DPOTRF CALL DPOTRF (uplo, n, a, lda, info); * Output: * 15.2250 33.9495 9.4143 11.1156 * 2.2302 12.5426 6.6684 53.2033 * 0.6183 0.4217 9.9881 71.5384 * 0.7301 4.112 6.9436 6.396
父主题: 矩阵分解函数