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

?pptrs

Solve the tridiagonal equation A * X = B, AT * X = B, or AH * X = B. The coefficient matrix A is obtained by calling ?gttrf.

Interface Definition

C interface:

void spptrs_(const char *UPLO, const int *N, const int *NRHS, float *AP, float *B, const int *LDB, int *INFO);

void dpptrs_(const char *UPLO, const int *N, const int *NRHS, double *AP, double *B, const int *LDB, int *INFO);

void cpptrs_(const char *UPLO, const int *N, const int *NRHS, float _Complex *AP, int *IPIV, float _Complex *B, const int *LDB, int *INFO);

void zpptrs_(const char *UPLO, const int *N, const int *NRHS, double _Complex *AP, int *IPIV, double _Complex *B, const int *LDB, int *INFO);

Fortran interface:

SPPTRS(UPLO, N, NRHS, AP, B, LDB, INFO);

DPPTRS(UPLO, N, NRHS, AP, B, LDB, INFO);

CPPTRS(UPLO, N, NRHS, AP, B, LDB, INFO);

ZPPTRS(UPLO, N, NRHS, AP, B, LDB, INFO);

Parameters

Parameter

Type

Description

Input/Output

UPLO

Character

  • 'U': Stores the upper triangular part of matrix A.
  • 'T': Stores the lower triangular part of matrix A.

Input

N

Integer

Order of matrix A, N ≥ 0.

Input

NRHS

Integer

Number of columns in matrix B, NRHS ≥ 0.

Input

AP

  • A single-precision floating-point array for spptrs
  • A double-precision floating-point array for dpptrs
  • A single-precision complex array for cpptrs
  • A double-precision complex array for zpptrs

L and U obtained by Cholesky factorization of packed matrix A. The size is N*(N+1)/2.

Input

B

  • A single-precision floating-point array for spptrs
  • A double-precision floating-point array for dpptrs
  • A single-precision complex array for cpptrs
  • A double-precision complex array for zpptrs

Right-hand side matrix, with a size of LDB*NRHS.

  • Before calling: right-hand side matrix B.
  • After calling: solved matrix X.

Input, output

LDB

Integer

Leading dimension of matrix B. LDB ≥ max(1, N).

Input

INFO

Integer

0: The exit is successful.

Smaller than 0: The value of the -info-th parameter is invalid.

Output

Dependency

include "klapack.h"

Examples

C interface:

const char uplo = 'U';
const int n = 4;
const int nrhs = 1;
const int ldb = n;
double ap[] = {231.8009,33.9545,162.2902,9.4143,6.6684,100.322,11.1156,53.2033,71.5384,106.5638};
int info = 0;
double b[]={1.0, 2.0, 3.0, 4.0};
dpptrf_(&uplo, &n, ap, &info);
dpptrs_(&uplo, &n, &nrhs, ap, b, &ldb, &info);
if (info != 0) {
    printf("ERROR, info = %d\n", info);
}

/* 
* Output: 
*   ap: 0.002361    0.000904    0.006432    0.032521
*/
Fortran interface:
CHARACTER::uplo = "U"
PARAMETER (n = 4)  
PARAMETER (nrhs = 4) 
PARAMETER (ldb = n) 
INTEGER :: info = 0 
REAL(8) :: ap(n*(n+1)/2) 
  
DATA ap / 231.8009,33.9545,162.2902,9.4143,6.6684,100.322,11.1156,53.2033,71.5384,106.5638 / 
DATA b / 1.0, 2.0, 3.0, 4.0 /
 EXTERNAL DPPTRF,DPPTRS
 CALL DPPTRF(uplo, n, ap, info);
 CALL DPPTRS(uplo, n, nrhs, ap, b, ldb, info);
* 
* Output: 
*   ap: 0.002361    0.000904    0.006432    0.032521