Rate This Document
Findability
Accuracy
Completeness
Readability

?posv

Solve the system of linear equations , where A is an positive definite matrix of real symmetry or conjugate symmetry, and X and B are matrices. Compute the Cholesky factorization of matrix A, and solve the system of linear equations based on the factorization result.

Interface Definition

C interface:

void dposv_(const char *uplo, const int *n, const int *nrhs, double *a, const int *lda, double *b, const int *ldb, int *info);

void sposv_(const char *uplo, const int *n, const int *nrhs, float *a, const int *lda, float *b, const int *ldb, int *info);

void cposv_(const char *uplo, const int *n, const int *nrhs, float _Complex *a, const int *lda, float _Complex *b, const int *ldb, int *info);

void zposv_(const char *uplo, const int *n, const int *nrhs, double _Complex *a, const int *lda, double _Complex *b, const int *ldb, int *info);

Fortran interface:

DPOSV(uplo, n, nrhs, a, lda, b, ldb, info);

SPOSV(uplo, n, nrhs, a, lda, b, ldb, info);

CPOSV(uplo, n, nrhs, a, lda, b, ldb, info);

ZPOSV(uplo, n, nrhs, a, lda, b, ldb, 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 rows or columns in the symmetric matrix A.

Input

nrhs

Integer

Number of items on the right, that is, the number of columns in matrix B. nrhs ≥ 0.

Input

a

  • A single-precision floating-point array for sposv
  • A double-precision floating-point array for dposv
  • A single-precision complex array for cposv
  • A double-precision complex array for zposv
  • Before the function is called, if uplo='U', matrix A contains the upper triangular part and the lower triangular part will not be used. If uplo='L', matrix A contains the lower triangular part and the upper triangular part will not be used.
  • After the function is called, the Cholesky factorization result (U or L) of matrix A is stored.

Input/Output

lda

Integer

Leading dimension of matrix A. lda ≥ max(1, n).

Input

b

  • A single-precision floating-point array for sposv
  • A double-precision floating-point array for dposv
  • A single-precision complex array for cposv
  • A double-precision complex array for zposv
  • Matrix B on the right before the function is called.
  • Solved matrix X after the function is called.

Input/Output

ldb

Integer

Leading dimension of matrix B. ldb ≥ max(1, n).

Input

info

Integer

Execution result:

  • 0: The execution is successful.
  • Smaller than 0: The value of the -info-th parameter is invalid.
  • Greater than 0: The sequence principal minor of the info size in matrix A is not positive definite, and the factorization cannot be completed.

Output

Dependency

#include "klapack.h"

Examples

C interface:
char uplo = 'L'; 
int n = 4; 
int nrhs = 1; 
int lda = 4;
int ldb = 4; 
int info = 0; 
/* 
* A (stored in column-major): 
*  231.8009    33.9545    9.4153    11.1156    
*   33.9454    162.2902   6.6684    53.2023     
*   9.4153     6.6684     100.3220  71.5384   
*   11.1156    53.2023    71.5384   106.5638  
*/ 
 
double a[] = {231.8009,   33.9545,   9.4143,   11.1156, 
              33.9495,  162.2902,   6.6684,   53.2033, 
              9.4143,    6.6684,  100.322,   71.5384, 
              11.1156,   53.2033,  71.5384,  106.5638}; 
double b[] = {1.0, 2.0, 3.0, 4.0};
 
dposv_(&uplo, &n, &nrhs, a, &lda, b, &ldb, &info); 
/* 
 * Output X:  0.002361        0.000904        0.006432        0.032521
 */

Fortran interface:

CHARACTER :: uplo = "L" 
PARAMETER (n = 4) 
PARAMETER (nrhs = 1)
PARAMETER (lda = 4) 
PARAMETER (ldb = 4) 
INTEGER :: info = 0 
 
*       
*  A (stored in column-major): 
*  231.8009    33.9545    9.4153    11.1156    
*   33.9454    162.2902   6.6684    53.2023     
*   9.4153     6.6684     100.3220  71.5384   
*   11.1156    53.2023    71.5384   106.5638
 
 
REAL(8) :: a(lda, n) 
DATA a / 231.8009,   33.9545,   9.4143,   11.1156, 
 $        33.9495,  162.2902,   6.6684,   53.2033, 
 $        9.4143,    6.6684,  100.322,   71.5384, 
 $        11.1156,   53.2033,  71.5384,  106.5638  / 
REAL(8) :: b(ldb, nrhs) 
DATA b / 1.0, 2.0, 3.0, 4.0 / 
 
EXTERNAL DPOSV 
CALL DPOSV(uplo, n, nrhs, a, lda, b, ldb, info); 
* Output X: 0.002361        0.000904        0.006432        0.032521