Solves a system of linear equations with a UDUT- or LDLT-factored Hermitian coefficient matrix.


lapack_int LAPACKE_chetrs (int matrix_layout , char uplo , lapack_int n , lapack_int nrhs , const lapack_complex_float * a , lapack_int lda , const lapack_int * ipiv , lapack_complex_float * b , lapack_int ldb );

lapack_int LAPACKE_zhetrs (int matrix_layout , char uplo , lapack_int n , lapack_int nrhs , const lapack_complex_double * a , lapack_int lda , const lapack_int * ipiv , lapack_complex_double * b , lapack_int ldb );

Include Files

  • mkl.h


The routine solves for X the system of linear equations A*X = B with a Hermitian matrix A, given the Bunch-Kaufman factorization of A:

if uplo='U',

A = U*D*UH

if uplo='L',

A = L*D*LH,

where U and L are upper and lower triangular matrices with unit diagonal and D is a symmetric block-diagonal matrix. The system is solved with multiple right-hand sides stored in the columns of the matrix B. You must supply to this routine the factor U (or L) and the array ipiv returned by the factorization routine ?hetrf.

Input Parameters


Specifies whether matrix storage layout is row major (LAPACK_ROW_MAJOR) or column major (LAPACK_COL_MAJOR).


Must be 'U' or 'L'.

Indicates how the input matrix A has been factored:

If uplo = 'U', the array a stores the upper triangular factor U of the factorization A = U*D*UH.

If uplo = 'L', the array a stores the lower triangular factor L of the factorization A = L*D*LH.


The order of matrix A; n 0.


The number of right-hand sides; nrhs 0.


Array, size at least max(1, n).

The ipiv array, as returned by ?hetrf.


The array aof size max(1, lda*n) contains the factor U or L (see uplo).


The array b contains the matrix B whose columns are the right-hand sides for the system of equations.

The size of b is at least max(1, ldb*nrhs) for column major layout and max(1, ldb*n) for row major layout.


The leading dimension of a; lda max(1, n).


The leading dimension of b; ldb max(1, n) for column major layout and ldbnrhs for row major layout.

Output Parameters


Overwritten by the solution matrix X.

Return Values

This function returns a value info.

If info=0, the execution is successful.

If info = -i, parameter i had an illegal value.

Application Notes

For each right-hand side b, the computed solution is the exact solution of a perturbed system of equations (A + E)x = b, where

|E|  c(n)ε P|U||D||UH|PT or |E|  c(n)ε P|L||D||LH|PT

c(n) is a modest linear function of n, and ε is the machine precision.

If x0 is the true solution, the computed solution x satisfies this error bound:


where cond(A,x)= || |A-1||A| |x| || / ||x|| ||A-1|| ||A|| = κ(A).

Note that cond(A,x) can be much smaller than κ(A).

The total number of floating-point operations for one right-hand side vector is approximately 8n2.

To estimate the condition number κ(A), call ?hecon.

To refine the solution and estimate the error, call ?herfs.

Orange (only for download buttons)