Rate This Document
Findability
Accuracy
Completeness
Readability

?sptrf

Interface Definition

C interface:

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

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

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

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

Fortran interface:

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

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

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

ZSPTRF(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 floating-point array for ssptrf
  • A double-precision floating-point array for dsptrf
  • A complex single-precision array for csptrf
  • A complex double-precision array for zsptrf
  • 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

A transposed array with a size of N, containing details of the interchanges and the block structure of diagonal matrix D.

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

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

Dependency

#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;
dsptrf_(&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 DSPTRF 
 CALL DSPTRF(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