# ?sysv

Computes the solution to the system of linear equations with a real or complex symmetric matrix A and multiple right-hand sides.

## Syntax

FORTRAN 77:

call ssysv( uplo, n, nrhs, a, lda, ipiv, b, ldb, work, lwork, info )

call dsysv( uplo, n, nrhs, a, lda, ipiv, b, ldb, work, lwork, info )

call csysv( uplo, n, nrhs, a, lda, ipiv, b, ldb, work, lwork, info )

call zsysv( uplo, n, nrhs, a, lda, ipiv, b, ldb, work, lwork, info )

Fortran 95:

call sysv( a, b [,uplo] [,ipiv] [,info] )

## Description

This routine solves for X the real or complex system of linear equations `A*X = B`, where A is an n-by-n symmetric matrix, the columns of matrix B are individual right-hand sides, and the columns of X are the corresponding solutions.

The diagonal pivoting method is used to factor A as `A = U*D*UT` or `A = L*D*LT` , where U (or L) is a product of permutation and unit upper (lower) triangular matrices, and D is symmetric and block diagonal with 1-by-1 and 2-by-2 diagonal blocks.

The factored form of A is then used to solve the system of equations `A*X = B`.

## Input Parameters

uplo

  CHARACTER*1. Must be 'U' or 'L'.

  Indicates whether the upper or lower triangular part of A is stored:

  If `uplo = 'U'`, the upper triangle of A is stored.

  If `uplo = 'L'`, the lower triangle of A is stored.

n

  INTEGER. The order of matrix A; n ≥ 0.

nrhs

  INTEGER. The number of right-hand sides; the number of columns in `B; nrhs ≥ 0`.

a, b, work

  REAL for ssysv

  DOUBLE PRECISION for dsysv

  COMPLEX for csysv

  DOUBLE COMPLEX for zsysv.

  Arrays: `a(lda,*)`, `b(ldb,*)`, `work(*)`.

  The array a contains the upper or the lower triangular part of the symmetric matrix A (see uplo). The second dimension of a must be at least `max(1, n)`.

  The array b contains the matrix B whose columns are the right-hand sides for the systems of equations. The second dimension of b must be at least `max(1,nrhs)`.

  work is a workspace array, dimension at least `max(1,lwork)`.

lda

  INTEGER. The first dimension of a; `lda ≥ max(1, n)`.

ldb

  INTEGER. The first dimension of b; `ldb ≥ max(1, n)`.

lwork

  INTEGER. The size of the work array; lwork ≥ 1.

  If `lwork = -1`, then a workspace query is assumed; the routine only calculates the optimal size of the work array, returns this value as the first entry of the work array, and no error message related to lwork is issued by xerbla. See Application Notes below for details and for the suggested value of lwork.

## Output Parameters

a

  If `info = 0`, a is overwritten by the block-diagonal matrix D and the multipliers used to obtain the factor U (or L) from the factorization of A as computed by ?sytrf.

b

  If `info = 0`, b is overwritten by the solution matrix X.

ipiv

  INTEGER.

  Array, DIMENSION at least `max(1, n)`. Contains details of the interchanges and the block structure of D, as determined by ?sytrf.

  If `ipiv(i) = k >0`, then `dii` is a 1-by-1 diagonal block, and the i-th row and column of A was interchanged with the k-th row and column.

  If `uplo = 'U'` and ipiv(i) = ipiv(i-1) = -m < 0, then D has a 2-by-2 block in rows/columns i and `i-1`, and (`i-1`)-th row and column of A was interchanged with the m-th row and column.

  If `uplo = 'L'` and ipiv(i) = ipiv(i+1) = -m < 0, then D has a 2-by-2 block in rows/columns i and `i+1`, and (`i+1`)-th row and column of A was interchanged with the m-th row and column.

`work(1)`

  If info = 0, on exit `work(1)` contains the minimum value of lwork required for optimum performance. Use this lwork for subsequent runs.

info

  INTEGER. If `info = 0`, the execution is successful.

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

  If `info = i`, `dii` is 0. The factorization has been completed, but D is exactly singular, so the solution could not be computed.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their Fortran 77 counterparts. For general conventions applied to skip redundant or reconstructible arguments, see Fortran 95 Interface Conventions.

Specific details for the routine sysv interface are as follows:

a

  Holds the matrix A of size (`n,n`).

b

  Holds the matrix B of size (`n,nrhs`).

ipiv

  Holds the vector of length (n).

uplo

  Must be 'U' or 'L'. The default value is 'U'.

## Application Notes

For better performance, try using `lwork = n*blocksize`, where blocksize is a machine-dependent value (typically, 16 to 64) required for optimum performance of the blocked algorithm.

If you are in doubt how much workspace to supply, use a generous value of lwork for the first run or set `lwork = -1`.

If you choose the first option and set any of admissible lwork sizes, which is no less than the minimal value described, the routine completes the task, though probably not so fast as with a recommended workspace, and provides the recommended workspace in the first element of the corresponding array work on exit. Use this value (`work(1)`) for subsequent runs.

If you set `lwork = -1`, the routine returns immediately and provides the recommended workspace in the first element of the corresponding array (work). This operation is called a workspace query.

Note that if you set lwork to less than the minimal required value and not -1, the routine returns immediately with an error exit and does not provide any information on the recommended workspace.

Parent topic: Driver Routines