?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 |
|
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 |
|
|
Input/Output |
lda |
Integer |
Leading dimension of matrix A. lda ≥ max(1, n). |
Input |
b |
|
|
Input/Output |
ldb |
Integer |
Leading dimension of matrix B. ldb ≥ max(1, n). |
Input |
info |
Integer |
Execution result:
|
Output |
Dependency
#include "klapack.h"
Examples
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