Rate This Document
Findability
Accuracy
Completeness
Readability

?hptrf

Compute the LDL* or U*DU factorization of a packed Hermitian matrix.

Interface Definition

C interface:

void chptrf_(const char *uplo, const int *n, float _Complex *ap, int *ipiv, int *info);

void zhptrf_(const char *uplo, const int *n, double _Complex *ap, int *ipiv, int *info);

Fortran interface:

CHPTRF(UPLO, N, AP, IPIV, INFO);

ZHPTRF(UPLO, N, AP, IPIV, INFO);

Parameters

Parameter

Type

Description

Input/Output

UPLO

Character

  • 'U': saves the upper triangular matrix of A.
  • 'L': saves the lower triangular matrix of A.

Input

N

Integer

Number of dimensions in matrix A, N ≥ 0.

Input

AP

  • A single-precision complex array for chptrf
  • A double-precision complex array for zhptrf
  • When input, it is a packed symmetric matrix A, and its size is N*(N+1)/2.
  • When output, it is a block diagonal matrix D and a multiplier used to obtain the factor U or L. It is stored as an upper or lower triangular matrix overwriting A.

Input/Output

IPIV

Integer

Permutation array of size N, defining the block structure of diagonal matrix D and the associated pivoting details.

  • If IPIV(k) > 0, then row and column k are interchanged with row and column IPIV(k), and D(k,k) is a 1*1 diagonal block.
  • If UPLO='U' and IPIV(k)=IPIV(k-1) < 0, then rows and columns of (k-1) and -IPIV (k) are interchanged, and D(k-1:k, k-1:k) is a 2*2 diagonal block.
  • If UPLO='L' and IPIV(k)=IPIV(k+1) < 0, then rows and columns of (k+1) and -IPIV(k) are interchanged, and D(k:k+1;k:k+1) is a 2*2 diagonal block.

Output

INFO

Integer

  • 0: The exit is successful.
  • Smaller than 0: The value of the -info-th parameter is invalid.
  • Greater than 0: U(INFO, INFO) is 0 and the factorization fails.

Output

Dependencies

#include "klapack.h"

Examples

C interface:

const char uplo = 'U';
const int n = 4;
double ap[] = {0.521739, 0.043478, 0.304348, 0.130435, 0.304348, 0.043478, 0.652174, 0.086957, 0.521739, 0.086957};
double ipiv[4];
int info = 0;
zhptrf_(&uplo, &n, ap, ipiv, &info);
if (info != 0) {
    printf("ERROR, info = %d\n", info);
}

/* 
* Output: 
*   ap: -0.129534   1.024339   0.302185   -0.492537   -0.044777   -0.728261   1.250000   0.083333  0.250000  0.521739
*   ipiv: 1       2       1       1
*/

Fortran interface:

CHARACTER::uplo = "U"
PARAMETER (n = 4)  
INTEGER :: info = 0 
REAL(8) :: ap(n*(n+1)/2) 
INTEGER :: ipiv(n)
  
DATA ap / 0.521739, 0.043478, 0.304348, 0.130435, 0.304348, 0.043478, 0.652174, 0.086957, 0.521739, 0.086957 / 

 EXTERNAL ZHPTRF 
 CALL ZHPTRF(uplo, n, ap, ipiv, info);
* 
* Output: 
*   ap: -0.129534   1.024339   0.302185   -0.492537   -0.044777   -0.728261   1.250000   0.083333  0.250000  0.521739
*   ipiv: 1       2       1       1