Rate This Document
Findability
Accuracy
Completeness
Readability

?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

  • 'U': saves the upper triangular matrix of A.
  • 'L': saves the lower triangular matrix of A.

Input

TRANS

Character

  • If the value is 'N', A * X = B.
  • If the value is 'T', AT * X = B.
  • If the value is 'C', AH * X = B (conjugate transposition).

Input

DIAG

Character

  • If the value is 'N', A is a non-unit triangular matrix.
  • If the value is 'U', A is a unit triangular matrix.

Input

N

Integer

Order of matrix A, N ≥ 0.

Input

NRHS

Integer

Number of columns in matrix B, NRHS ≥ 0.

Input

A

  • A single-precision floating-point array for strtrs
  • A double-precision floating-point array for dtrtrs
  • A single-precision complex array for ctrtrs
  • A double-precision complex array for ztrtrs

Triangular matrix A with a size of (LDA, N).

Input

LDA

Integer

Leading dimension of matrix A. LDA ≥ max(1, N).

Input

B

  • A single-precision floating-point array for strtrs
  • A double-precision floating-point array for dtrtrs
  • A single-precision complex array for ctrtrs
  • A double-precision complex array for ztrtrs

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

  • 0: The execution is successful.
  • Smaller than 0: The value of the -INFO-th parameter is invalid.
  • Greater than 0: If the INFO-th diagonal element in matrix A is 0, A is a singular matrix.

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);