?trtrs
Interface Definition
C interface:
void dtrtrs_(const char *uplo, const char *trans, const char *diag, const int *n, const int *nrhs, const double *a, const int *lda, double *b, const int *ldb, int *info);
void strtrs_(const char *uplo, const char *trans, const char *diag, const int *n, const int *nrhs, const float *a, const int *lda, float *b, const int *ldb, int *info);
void ctrtrs_(const char *uplo, const char *trans, const char *diag, const int *n, const int *nrhs, const float _Complex *a, const int *lda, float _Complex *b, const int *ldb, int *info);
void ztrtrs_(const char *uplo, const char *trans, const char *diag, const int *n, const int *nrhs, const double _Complex *a, const int *lda, double _Complex *b, const int *ldb, int *info);
Fortran interface:
DTRTRS(UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB, INFO);
STRTRS(UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB, INFO);
CTRTRS(UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB, INFO);
ZTRTRS(UPLO, TRANS, DIAG, N, NRHS, A, LDA, B, LDB, INFO);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
UPLO |
Character |
|
Input |
TRANS |
Character |
|
Input |
DIAG |
Character |
|
Input |
N |
Integer |
Order of matrix A, N ≥ 0. |
Input |
NRHS |
Integer |
Number of columns in matrix B, NRHS ≥ 0. |
Input |
A |
|
Triangular matrix A with a size of (LDA, N). |
Input |
LDA |
Integer |
Leading dimension of matrix A. LDA ≥ max(1, N). |
Input |
B |
|
When as an input value, it is an RHS matrix B with a size of (LDB, NRHS). When as an output value, if INFO = 0, it is the solved matrix X of the equation. |
Input, output |
LDB |
Integer |
Leading dimension of RHS matrix B. LDB ≥ max(1, N). |
Input |
INFO |
Integer |
|
Output |
Dependency
include "klapack.h"
Examples
C interface:
const char uplo = 'L';
const char trans = 'N';
const char diag = 'N';
const int n = 4;
const int lda = n;
const int ldb = n;
const int nrhs = 1;
double *a = (double*)malloc(lda * n * sizeof(double));
double *b = (double*)malloc(ldb * nrhs * sizeof(double));
int info = 0;
// Generate Matrix A.
for (int i = 0; i < n; i++) {
for (int j = i; j < lda; j++) {
a[i * lda + j] = (rand() % 53 + 1) / 53.0;
}
}
// Generate right hand side matrix B.
for (int i = 0; i < ldb * nrhs; i++) {
b[i] = (rand() % 23 + 1) / 23.0;
}
// Call dtrtrs.
dtrtrs_(&uplo, &trans, &diag, &n, &nrhs, a, &lda, b, &ldb, &info);
if (info != 0) {
printf("ERROR, info = %d\n", info);
}
Fortran interface:
CHARACTER :: uplo = "L" CHARACTER :: trans = "N" CHARACTER :: diag = "N" PARAMETER (n = 4) PARAMETER (lda = 4) PARAMETER (ldb = 4) PARAMETER (nrhs = 1) INTEGER :: info = 0 REAL(8) :: d(lda, n) REAL(8) :: b(ldb, nrhs) EXTERNAL DTRTRS CALL DTRTRS(uplo, trans, diag n, nrhs, a, lda, b, ldb, info);