1 *> \brief <b> ZHESV computes the solution to system of linear equations A * X = B for HE matrices</b>
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZHESV + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhesv.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhesv.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhesv.f">
21 * SUBROUTINE ZHESV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
24 * .. Scalar Arguments ..
26 * INTEGER INFO, LDA, LDB, LWORK, N, NRHS
28 * .. Array Arguments ..
30 * COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
39 *> ZHESV computes the solution to a complex system of linear equations
41 *> where A is an N-by-N Hermitian matrix and X and B are N-by-NRHS
44 *> The diagonal pivoting method is used to factor A as
45 *> A = U * D * U**H, if UPLO = 'U', or
46 *> A = L * D * L**H, if UPLO = 'L',
47 *> where U (or L) is a product of permutation and unit upper (lower)
48 *> triangular matrices, and D is Hermitian and block diagonal with
49 *> 1-by-1 and 2-by-2 diagonal blocks. The factored form of A is then
50 *> used to solve the system of equations A * X = B.
58 *> UPLO is CHARACTER*1
59 *> = 'U': Upper triangle of A is stored;
60 *> = 'L': Lower triangle of A is stored.
66 *> The number of linear equations, i.e., the order of the
73 *> The number of right hand sides, i.e., the number of columns
74 *> of the matrix B. NRHS >= 0.
79 *> A is COMPLEX*16 array, dimension (LDA,N)
80 *> On entry, the Hermitian matrix A. If UPLO = 'U', the leading
81 *> N-by-N upper triangular part of A contains the upper
82 *> triangular part of the matrix A, and the strictly lower
83 *> triangular part of A is not referenced. If UPLO = 'L', the
84 *> leading N-by-N lower triangular part of A contains the lower
85 *> triangular part of the matrix A, and the strictly upper
86 *> triangular part of A is not referenced.
88 *> On exit, if INFO = 0, the block diagonal matrix D and the
89 *> multipliers used to obtain the factor U or L from the
90 *> factorization A = U*D*U**H or A = L*D*L**H as computed by
97 *> The leading dimension of the array A. LDA >= max(1,N).
102 *> IPIV is INTEGER array, dimension (N)
103 *> Details of the interchanges and the block structure of D, as
104 *> determined by ZHETRF. If IPIV(k) > 0, then rows and columns
105 *> k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
106 *> diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
107 *> then rows and columns k-1 and -IPIV(k) were interchanged and
108 *> D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and
109 *> IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
110 *> -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
116 *> B is COMPLEX*16 array, dimension (LDB,NRHS)
117 *> On entry, the N-by-NRHS right hand side matrix B.
118 *> On exit, if INFO = 0, the N-by-NRHS solution matrix X.
124 *> The leading dimension of the array B. LDB >= max(1,N).
129 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
130 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
136 *> The length of WORK. LWORK >= 1, and for best performance
137 *> LWORK >= max(1,N*NB), where NB is the optimal blocksize for
139 *> for LWORK < N, TRS will be done with Level BLAS 2
140 *> for LWORK >= N, TRS will be done with Level BLAS 3
142 *> If LWORK = -1, then a workspace query is assumed; the routine
143 *> only calculates the optimal size of the WORK array, returns
144 *> this value as the first entry of the WORK array, and no error
145 *> message related to LWORK is issued by XERBLA.
151 *> = 0: successful exit
152 *> < 0: if INFO = -i, the i-th argument had an illegal value
153 *> > 0: if INFO = i, D(i,i) is exactly zero. The factorization
154 *> has been completed, but the block diagonal matrix D is
155 *> exactly singular, so the solution could not be computed.
161 *> \author Univ. of Tennessee
162 *> \author Univ. of California Berkeley
163 *> \author Univ. of Colorado Denver
166 *> \date November 2011
168 *> \ingroup complex16HEsolve
170 * =====================================================================
171 SUBROUTINE ZHESV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
174 * -- LAPACK driver routine (version 3.4.0) --
175 * -- LAPACK is a software package provided by Univ. of Tennessee, --
176 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
179 * .. Scalar Arguments ..
181 INTEGER INFO, LDA, LDB, LWORK, N, NRHS
183 * .. Array Arguments ..
185 COMPLEX*16 A( LDA, * ), B( LDB, * ), WORK( * )
188 * =====================================================================
190 * .. Local Scalars ..
194 * .. External Functions ..
197 EXTERNAL LSAME, ILAENV
199 * .. External Subroutines ..
200 EXTERNAL XERBLA, ZHETRF, ZHETRS, ZHETRS2
202 * .. Intrinsic Functions ..
205 * .. Executable Statements ..
207 * Test the input parameters.
210 LQUERY = ( LWORK.EQ.-1 )
211 IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
213 ELSE IF( N.LT.0 ) THEN
215 ELSE IF( NRHS.LT.0 ) THEN
217 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
219 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
221 ELSE IF( LWORK.LT.1 .AND. .NOT.LQUERY ) THEN
229 NB = ILAENV( 1, 'ZHETRF', UPLO, N, -1, -1, -1 )
236 CALL XERBLA( 'ZHESV ', -INFO )
238 ELSE IF( LQUERY ) THEN
242 * Compute the factorization A = U*D*U**H or A = L*D*L**H.
244 CALL ZHETRF( UPLO, N, A, LDA, IPIV, WORK, LWORK, INFO )
247 * Solve the system A*X = B, overwriting B with X.
249 IF ( LWORK.LT.N ) THEN
251 * Solve with TRS ( Use Level BLAS 2)
253 CALL ZHETRS( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
257 * Solve with TRS2 ( Use Level BLAS 3)
259 CALL ZHETRS2( UPLO,N,NRHS,A,LDA,IPIV,B,LDB,WORK,INFO )