Computes the BunchKaufman factorization of a symmetric matrix.
Syntax
FORTRAN 77:

call ssytrf( uplo, n, a, lda, ipiv, work, lwork, info )
call dsytrf( uplo, n, a, lda, ipiv, work, lwork, info )
call csytrf( uplo, n, a, lda, ipiv, work, lwork, info )
call zsytrf( uplo, n, a, lda, ipiv, work, lwork, info )
Fortran 95:

call sytrf( a [, uplo] [,ipiv] [, info] )
C:

lapack_int LAPACKE_<?>sytrf( int matrix_layout, char uplo, lapack_int n, <datatype>* a, lapack_int lda, lapack_int* ipiv );
Description
The routine computes the factorization of a real/complex symmetric matrix A using the BunchKaufman diagonal pivoting method. The form of the factorization is:

if uplo='U', A = P*U*D*U^{T}*P^{T}

if uplo='L', A = P*L*D*L^{T}*P^{T},
where A is the input matrix, P is a permutation matrix, U and L are upper and lower triangular matrices with unit diagonal, and D is a symmetric blockdiagonal matrix with 1by1 and 2by2 diagonal blocks. U and L have 2by2 unit diagonal blocks corresponding to the 2by2 blocks of D.
Note
This routine supports the Progress Routine feature. See Progress Routine for details.
Input Parameters
The data types are given for the Fortran interface. A <datatype> placeholder, if present, is used for the C interface data types in the C interface section above. See C Interface Conventions for the C interface principal conventions and type definitions.
uplo 
CHARACTER*1. Must be 'U' or 'L'. Indicates whether the upper or lower triangular part of A is stored and how A is factored: If If 
n 
INTEGER. The order of matrix A; n ≥ 0. 
a 
REAL for ssytrf DOUBLE PRECISION for dsytrf COMPLEX for csytrf DOUBLE COMPLEX for zsytrf. Array, DIMENSION 
lda 
INTEGER. The leading dimension of a; at least 
work 
Same type as a. A workspace array, dimension at least 
lwork 
INTEGER. The size of the work array If See Application Notes for the suggested value of lwork. 
Output Parameters
a 
The upper or lower triangular part of a is overwritten by details of the blockdiagonal matrix D and the multipliers used to obtain the factor U (or L). 

If 
ipiv 
INTEGER. Array, DIMENSION at least If uplo = 'U' and ipiv(i) =ipiv(i1) = m < 0, then D has a 2by2 block in rows/columns i and If uplo = 'L' and ipiv(i) =ipiv(i+1) = m < 0, then D has a 2by2 block in rows/columns i and 
info 
INTEGER. If If If 
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 sytrf interface are as follows:
a 
holds the matrix A of size (n, n) 
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 machinedependent 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.
The 2by2 unit diagonal blocks and the unit diagonal elements of U and L are not stored. The remaining elements of U and L are stored in the corresponding columns of the array a, but additional row interchanges are required to recover U or L explicitly (which is seldom necessary).
If ipiv(i) = i for all i =1...n
, then all offdiagonal elements of U (L) are stored explicitly in the corresponding elements of the array a.
If uplo = 'U'
, the computed factors U and D are the exact factors of a perturbed matrix A + E
, where
E ≤ c(n)ε PUDU^{T}P^{T}
c(n)
is a modest linear function of n, and ε is the machine precision. A similar estimate holds for the computed L and D when uplo = 'L'
.
The total number of floatingpoint operations is approximately (1/3)n^{3}
for real flavors or (4/3)n^{3}
for complex flavors.
After calling this routine, you can call the following routines:
to solve 

to estimate the condition number of A 

to compute the inverse of A. 
If uplo = 'U'
, then A = U*D*U'
, where
U = P(n)*U(n)* ... *P(k)*U(k)*...,
that is, U is a product of terms P(k)*U(k), where

k decreases from n to 1 in steps of 1 and 2.

D is a block diagonal matrix with 1by1 and 2by2 diagonal blocks D(k).

P(k) is a permutation matrix as defined by ipiv(k).

U(k) is a unit upper triangular matrix, such that if the diagonal block D(k) is of order s (s = 1 or 2), then
If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k1,k).
If s = 2, the upper triangle of D(k) overwrites A(k1,k1), A(k1,k) and A(k,k), and v overwrites A(1:k2,k 1:k).
If uplo = 'L'
, then A = L*D*L'
, where
L = P(1)*L(1)* ... *P(k)*L(k)*...,
that is, L is a product of terms P(k)*L(k), where

k increases from 1 to n in steps of 1 and 2.

D is a block diagonal matrix with 1by1 and 2by2 diagonal blocks D(k).

P(k) is a permutation matrix as defined by ipiv(k).

L(k) is a unit lower triangular matrix, such that if the diagonal block D(k) is of order s (s = 1 or 2), then
If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k), and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).