LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
chesv.f
Go to the documentation of this file.
1*> \brief <b> CHESV computes the solution to system of linear equations A * X = B for HE matrices</b>
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CHESV + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/chesv.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/chesv.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/chesv.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CHESV( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
20* LWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER UPLO
24* INTEGER INFO, LDA, LDB, LWORK, N, NRHS
25* ..
26* .. Array Arguments ..
27* INTEGER IPIV( * )
28* COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> CHESV computes the solution to a complex system of linear equations
38*> A * X = B,
39*> where A is an N-by-N Hermitian matrix and X and B are N-by-NRHS
40*> matrices.
41*>
42*> The diagonal pivoting method is used to factor A as
43*> A = U * D * U**H, if UPLO = 'U', or
44*> A = L * D * L**H, if UPLO = 'L',
45*> where U (or L) is a product of permutation and unit upper (lower)
46*> triangular matrices, and D is Hermitian and block diagonal with
47*> 1-by-1 and 2-by-2 diagonal blocks. The factored form of A is then
48*> used to solve the system of equations A * X = B.
49*> \endverbatim
50*
51* Arguments:
52* ==========
53*
54*> \param[in] UPLO
55*> \verbatim
56*> UPLO is CHARACTER*1
57*> = 'U': Upper triangle of A is stored;
58*> = 'L': Lower triangle of A is stored.
59*> \endverbatim
60*>
61*> \param[in] N
62*> \verbatim
63*> N is INTEGER
64*> The number of linear equations, i.e., the order of the
65*> matrix A. N >= 0.
66*> \endverbatim
67*>
68*> \param[in] NRHS
69*> \verbatim
70*> NRHS is INTEGER
71*> The number of right hand sides, i.e., the number of columns
72*> of the matrix B. NRHS >= 0.
73*> \endverbatim
74*>
75*> \param[in,out] A
76*> \verbatim
77*> A is COMPLEX array, dimension (LDA,N)
78*> On entry, the Hermitian matrix A. If UPLO = 'U', the leading
79*> N-by-N upper triangular part of A contains the upper
80*> triangular part of the matrix A, and the strictly lower
81*> triangular part of A is not referenced. If UPLO = 'L', the
82*> leading N-by-N lower triangular part of A contains the lower
83*> triangular part of the matrix A, and the strictly upper
84*> triangular part of A is not referenced.
85*>
86*> On exit, if INFO = 0, the block diagonal matrix D and the
87*> multipliers used to obtain the factor U or L from the
88*> factorization A = U*D*U**H or A = L*D*L**H as computed by
89*> CHETRF.
90*> \endverbatim
91*>
92*> \param[in] LDA
93*> \verbatim
94*> LDA is INTEGER
95*> The leading dimension of the array A. LDA >= max(1,N).
96*> \endverbatim
97*>
98*> \param[out] IPIV
99*> \verbatim
100*> IPIV is INTEGER array, dimension (N)
101*> Details of the interchanges and the block structure of D, as
102*> determined by CHETRF. If IPIV(k) > 0, then rows and columns
103*> k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
104*> diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
105*> then rows and columns k-1 and -IPIV(k) were interchanged and
106*> D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and
107*> IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
108*> -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
109*> diagonal block.
110*> \endverbatim
111*>
112*> \param[in,out] B
113*> \verbatim
114*> B is COMPLEX array, dimension (LDB,NRHS)
115*> On entry, the N-by-NRHS right hand side matrix B.
116*> On exit, if INFO = 0, the N-by-NRHS solution matrix X.
117*> \endverbatim
118*>
119*> \param[in] LDB
120*> \verbatim
121*> LDB is INTEGER
122*> The leading dimension of the array B. LDB >= max(1,N).
123*> \endverbatim
124*>
125*> \param[out] WORK
126*> \verbatim
127*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
128*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
129*> \endverbatim
130*>
131*> \param[in] LWORK
132*> \verbatim
133*> LWORK is INTEGER
134*> The length of WORK. LWORK >= 1, and for best performance
135*> LWORK >= max(1,N*NB), where NB is the optimal blocksize for
136*> CHETRF.
137*> for LWORK < N, TRS will be done with Level BLAS 2
138*> for LWORK >= N, TRS will be done with Level BLAS 3
139*>
140*> If LWORK = -1, then a workspace query is assumed; the routine
141*> only calculates the optimal size of the WORK array, returns
142*> this value as the first entry of the WORK array, and no error
143*> message related to LWORK is issued by XERBLA.
144*> \endverbatim
145*>
146*> \param[out] INFO
147*> \verbatim
148*> INFO is INTEGER
149*> = 0: successful exit
150*> < 0: if INFO = -i, the i-th argument had an illegal value
151*> > 0: if INFO = i, D(i,i) is exactly zero. The factorization
152*> has been completed, but the block diagonal matrix D is
153*> exactly singular, so the solution could not be computed.
154*> \endverbatim
155*
156* Authors:
157* ========
158*
159*> \author Univ. of Tennessee
160*> \author Univ. of California Berkeley
161*> \author Univ. of Colorado Denver
162*> \author NAG Ltd.
163*
164*> \ingroup hesv
165*
166* =====================================================================
167 SUBROUTINE chesv( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, WORK,
168 $ LWORK, INFO )
169*
170* -- LAPACK driver routine --
171* -- LAPACK is a software package provided by Univ. of Tennessee, --
172* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
173*
174* .. Scalar Arguments ..
175 CHARACTER UPLO
176 INTEGER INFO, LDA, LDB, LWORK, N, NRHS
177* ..
178* .. Array Arguments ..
179 INTEGER IPIV( * )
180 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * )
181* ..
182*
183* =====================================================================
184*
185* .. Local Scalars ..
186 LOGICAL LQUERY
187 INTEGER LWKOPT, NB
188* ..
189* .. External Functions ..
190 LOGICAL LSAME
191 INTEGER ILAENV
192 REAL SROUNDUP_LWORK
193 EXTERNAL lsame, ilaenv, sroundup_lwork
194* ..
195* .. External Subroutines ..
196 EXTERNAL xerbla, chetrf, chetrs, chetrs2
197* ..
198* .. Intrinsic Functions ..
199 INTRINSIC max
200* ..
201* .. Executable Statements ..
202*
203* Test the input parameters.
204*
205 info = 0
206 lquery = ( lwork.EQ.-1 )
207 IF( .NOT.lsame( uplo, 'U' ) .AND.
208 $ .NOT.lsame( uplo, 'L' ) ) THEN
209 info = -1
210 ELSE IF( n.LT.0 ) THEN
211 info = -2
212 ELSE IF( nrhs.LT.0 ) THEN
213 info = -3
214 ELSE IF( lda.LT.max( 1, n ) ) THEN
215 info = -5
216 ELSE IF( ldb.LT.max( 1, n ) ) THEN
217 info = -8
218 ELSE IF( lwork.LT.1 .AND. .NOT.lquery ) THEN
219 info = -10
220 END IF
221*
222 IF( info.EQ.0 ) THEN
223 IF( n.EQ.0 ) THEN
224 lwkopt = 1
225 ELSE
226 nb = ilaenv( 1, 'CHETRF', uplo, n, -1, -1, -1 )
227 lwkopt = n*nb
228 END IF
229 work( 1 ) = sroundup_lwork(lwkopt)
230 END IF
231*
232 IF( info.NE.0 ) THEN
233 CALL xerbla( 'CHESV ', -info )
234 RETURN
235 ELSE IF( lquery ) THEN
236 RETURN
237 END IF
238*
239* Compute the factorization A = U*D*U**H or A = L*D*L**H.
240*
241 CALL chetrf( uplo, n, a, lda, ipiv, work, lwork, info )
242 IF( info.EQ.0 ) THEN
243*
244* Solve the system A*X = B, overwriting B with X.
245*
246 IF ( lwork.LT.n ) THEN
247*
248* Solve with TRS ( Use Level BLAS 2)
249*
250 CALL chetrs( uplo, n, nrhs, a, lda, ipiv, b, ldb, info )
251*
252 ELSE
253*
254* Solve with TRS2 ( Use Level BLAS 3)
255*
256 CALL chetrs2( uplo,n,nrhs,a,lda,ipiv,b,ldb,work,info )
257*
258 END IF
259*
260 END IF
261*
262 work( 1 ) = sroundup_lwork(lwkopt)
263*
264 RETURN
265*
266* End of CHESV
267*
268 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine chesv(uplo, n, nrhs, a, lda, ipiv, b, ldb, work, lwork, info)
CHESV computes the solution to system of linear equations A * X = B for HE matrices
Definition chesv.f:169
subroutine chetrf(uplo, n, a, lda, ipiv, work, lwork, info)
CHETRF
Definition chetrf.f:175
subroutine chetrs2(uplo, n, nrhs, a, lda, ipiv, b, ldb, work, info)
CHETRS2
Definition chetrs2.f:125
subroutine chetrs(uplo, n, nrhs, a, lda, ipiv, b, ldb, info)
CHETRS
Definition chetrs.f:118