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

?pttrs

Solve the tridiagonal equation AX=B, where the coefficient matrix A is the ?pttrf factorization result.

Interface Definition

C interface:

void spttrs_(const int *N, const int *NRHS, float *D, float *E, float *B, const int *LDB, int *INFO);

void dpttrs_(const int *N, const int *NRHS, double *D, double *E, double *B, const int *LDB, int *INFO);

void cpttrs_(const char *UPLO, const int *N, const int *NRHS, float *D, float _Complex *E, float _Complex *B, const int *LDB, int *INFO);

void zpttrs_(const char *UPLO, const int *N, const int *NRHS, double *D, double _Complex *E, double _Complex *B, const int *LDB, int *INFO);

Fortran interface:

SPTTRS(N, NRHS, D, E, B, LDB, INFO);

DPTTRS(N, NRHS, D, E, B, LDB, INFO);

CPTTRS(UPLO, N, NRHS, D, E, B, LDB, INFO);

ZPTTRS(UPLO, N, NRHS, D, E, B, LDB, INFO);

Parameters

Parameter

Type

Description

Input/Output

UPLO (specific to complex numbers)

Character

  • 'U': A=U**H*D*U
  • 'L': A=L*D*L**H

Input

N

Integer

Number of dimensions of matrix A, N ≥ 0

Input

NRHS

Integer

Number of columns in matrix B, NRHS ≥ 0

Input

D

  • For spttrs/cpttrs, D is a single-precision floating-point array.
  • For dpttrs/zpttrs, D is a double-precision floating-point array.

Diagonal element of tridiagonal matrix A, with a dimension of N.

Input

E

  • For spttrs, E is a single-precision floating-point array.
  • For dpttrs, E is a double-precision floating-point array.
  • For cpttrs, E is a single-precision complex number array.
  • For zpttrs, E is a double-precision complex number array.

Sub-diagonal element of tridiagonal matrix A, with a dimension of N-1.

Input

B

  • For spttrs, B is a single-precision floating-point array.
  • For dpttrs, B is a double-precision floating-point array.
  • For cpttrs, B is a single-precision complex number array.
  • For zpttrs, B is a double-precision complex number array.

When as an input value, it is a right-hand side matrix, and the dimension is (LDB, NRHS).

When as an output value, it is the result X, and the dimension is (LDB, NRHS).

Input/output

LDB

Integer

Main dimension of matrix B.

Input

INFO

Integer

  • 0: The exit is successful.
  • Smaller than 0: The -INFO-th parameter is invalid.

Output

Dependencies

#include "klapack.h"

Examples

C interface:

    const int n = 4;
    const int ldb = n;
    const int nrhs = 1;
    double d[] = {7.608696,7.739130, 7.347826,4.652174};
    double e[] = {0.352941,0.000000,0.823529};
    double b[] = {0.300000,0.100000,0.700000,0.200000};
    int info = 0;
    
    dpttrs_(&n, &nrhs, d, e, b, &ldb, &info);
/* 
* Output: 
*   b: 0.039697        -0.000760       0.161909        -0.080924
*/

Fortran interface:

PARAMETER (n = 4) 
PARAMETER (ldb = 4)
PARAMETER (nrhs = 1) 
INTEGER :: info = 0 
REAL(8) :: d(n) 
REAL(8) :: e(n-1)
REAL(8) :: b(ldb, nrhs)  
  
DATA d / 7.608696,7.739130, 7.347826,4.652174 / 
DATA e / 0.352941,0.000000,0.823529 /
DATA b / 0.300000,0.100000,0.700000,0.200000 /
 EXTERNAL DPTTRS 
 CALL DPTTRS(n, nrhs, d, e, b, ldb, info);
* 
* Output: 
*  b: 0.039697        -0.000760       0.161909        -0.080924