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

?ptsv

Solve a system of linear equations, where A is a real symmetric or complex Hermitian positive-definite tridiagonal matrix.

Interface Definition

C interface:

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

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

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

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

Fortran interface:

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

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

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

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

Parameters

Parameter

Type

Description

Input/Output

N

Integer

Number of dimensions in matrix A, N ≥ 0.

Input

NRHS

Integer

Number of columns in matrix B, NRHS ≥ 0.

Input

D

  • A single-precision floating-point array for sptsv/cptsv
  • A double-precision floating-point array for dptsv/zptsv

As an input value, it represents a diagonal element of tridiagonal matrix A, with a dimension of N.

As an output value, it represents a diagonal element D after factorization.

Input, output

E

  • A single-precision floating-point array for sptsv
  • A double-precision floating-point array for dptsv
  • A single-precision complex array for cptsv
  • A double-precision complex array for zptsv

As an input value, it represents a sub-diagonal element of tridiagonal matrix A, with a dimension of N-1.

As an output value, it represents a sub-diagonal element of matrix A after factorization.

Input, output

B

  • A single-precision floating-point array for sptsv
  • A double-precision floating-point array for dptsv
  • A single-precision complex array for cptsv
  • A double-precision complex array for zptsv

As an input value, it represents the right-hand side matrix, with a dimension of (LDB, NRHS).

As an output value, it represents the solution X, with a dimension of (LDB, NRHS).

Input, output

LDB

Integer

Leading dimension of matrix B.

Input

INFO

Integer

  • 0: The exit is successful.
  • Smaller than 0: The value of the -info-th parameter is invalid.
  • Greater than 0: The INFO-th order principal minor is not positive definite.

Output

Dependency

#include "klapack.h"

Examples

C interface:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
    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;
    
    dptsv_(&n, &nrhs, d, e, b, &ldb, &info);
/* 
* Output: 
*   d: 7.608696        7.722759        7.347826        4.559874
*   e: 0.046387        0.000000        0.112078
*   b: 0.038912        0.011147        0.092279        0.026655
*/

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 DPTSV 
 CALL DPTSV(n, nrhs, d, e, b, ldb, info);
* 
* Output: 
*   d: 7.608696        7.722759        7.347826        4.559874
*   e: 0.046387        0.000000        0.112078
*   b: 0.038912        0.011147        0.092279        0.026655