我要评分
获取效率
正确性
完整性
易理解

?potrf

Compute the Cholesky decomposition of a symmetric positive definite matrix or Hermitian positive definite matrix.

That is, or . is an upper triangular matrix, and is a lower triangular matrix.

Interface Definition

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);

Parameters

Parameter

Type

Description

Input/Output

uplo

String

'U': saves the upper triangular matrix of A.

'L': saves the lower triangular matrix of A.

Input

n

Integer

Number of rows or columns in the symmetric matrix A.

Input

a

  • A single-precision floating-point array for spotrf
  • A double-precision floating-point array for dpotrf
  • A single-precision complex array for cpotrf
  • A double-precision complex array for zpotrf
  • Stores matrix A to be factorized before this function is called.
  • When uplo = 'U', the upper triangular matrix U is saved for the diagonal and the part above the diagonal after the function is called.
  • When uplo = 'L', the lower triangular matrix L is saved for the diagonal and the part below the diagonal save after the function is called.

Input/Output

lda

Integer

Leading dimension of matrix A. lda ≥ max(1, n).

Input

info

Integer

Execution result:

  • 0: The exit is successful.
  • Smaller than 0: The value of the -info-th parameter is invalid.
  • Greater than 0: The principal minor of order info in matrix A is not positive definite, and the factorization cannot be completed.

Output

Dependency

#include "klapack.h"

Examples

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