1 SUBROUTINE DSYSV
( UPLO
, N
, NRHS
, A
, LDA
, IPIV
, B
, LDB
, WORK
,
4 * -- LAPACK driver routine
(version
3.1) --
5 * Univ
. of Tennessee
, Univ
. of California Berkeley and NAG Ltd
..
8 * .. Scalar Arguments
..
10 INTEGER INFO
, LDA
, LDB
, LWORK
, N
, NRHS
12 * .. Array Arguments
..
14 DOUBLE PRECISION A
( LDA
, * ), B
( LDB
, * ), WORK
( * )
20 * DSYSV computes the solution
to a
real system of linear equations
22 * where A is an N
-by
-N symmetric matrix and X and B are N
-by
-NRHS
25 * The diagonal pivoting method is used
to factor A as
26 * A
= U
* D
* U**T
, if UPLO
= 'U', or
27 * A
= L
* D
* L**T
, if UPLO
= 'L',
28 * where U
(or L
) is a product of permutation and unit upper
(lower
)
29 * triangular matrices
, and D is symmetric and block diagonal with
30 * 1-by
-1 and
2-by
-2 diagonal blocks
. The factored form of A is
then
31 * used
to solve the system of equations A
* X
= B
.
36 * UPLO
(input
) CHARACTER*1
37 * = 'U': Upper triangle of A is stored
;
38 * = 'L': Lower triangle of A is stored
.
41 * The number of linear equations
, i
.e
., the order of the
44 * NRHS
(input
) INTEGER
45 * The number of right hand sides
, i
.e
., the number of columns
46 * of the matrix B
. NRHS
>= 0.
48 * A
(input
/output
) DOUBLE PRECISION array
, dimension (LDA
,N
)
49 * On entry
, the symmetric matrix A
. If UPLO
= 'U', the leading
50 * N
-by
-N upper triangular part of A contains the upper
51 * triangular part of the matrix A
, and the strictly lower
52 * triangular part of A is not referenced
. If UPLO
= 'L', the
53 * leading N
-by
-N lower triangular part of A contains the lower
54 * triangular part of the matrix A
, and the strictly upper
55 * triangular part of A is not referenced
.
57 * On exit
, if INFO
= 0, the block diagonal matrix D and the
58 * multipliers used
to obtain the factor U or L from the
59 * factorization A
= U*D*U**T or A
= L*D*L**T as computed by
63 * The leading
dimension of the array A
. LDA
>= max
(1,N
).
65 * IPIV
(output
) INTEGER array
, dimension (N
)
66 * Details of the interchanges and the block structure of D
, as
67 * determined by DSYTRF
. If IPIV
(k
) > 0, then rows and columns
68 * k and IPIV
(k
) were interchanged
, and D
(k
,k
) is a
1-by
-1
69 * diagonal block
. If UPLO
= 'U' and IPIV
(k
) = IPIV
(k
-1) < 0,
70 * then rows and columns k
-1 and
-IPIV
(k
) were interchanged and
71 * D
(k
-1:k
,k
-1:k
) is a
2-by
-2 diagonal block
. If UPLO
= 'L' and
72 * IPIV
(k
) = IPIV
(k
+1) < 0, then rows and columns k
+1 and
73 * -IPIV
(k
) were interchanged and D
(k
:k
+1,k
:k
+1) is a
2-by
-2
76 * B
(input
/output
) DOUBLE PRECISION array
, dimension (LDB
,NRHS
)
77 * On entry
, the N
-by
-NRHS right hand side matrix B
.
78 * On exit
, if INFO
= 0, the N
-by
-NRHS solution matrix X
.
81 * The leading
dimension of the array B
. LDB
>= max
(1,N
).
83 * WORK
(workspace
/output
) DOUBLE PRECISION array
, dimension (MAX
(1,LWORK
))
84 * On exit
, if INFO
= 0, WORK
(1) returns the optimal LWORK
.
86 * LWORK
(input
) INTEGER
87 * The length of WORK
. LWORK
>= 1, and
for best performance
88 * LWORK
>= max
(1,N*NB
), where NB is the optimal blocksize
for
91 * If LWORK
= -1, then a workspace query is assumed
; the routine
92 * only calculates the optimal size of the WORK array
, returns
93 * this value as the first entry of the WORK array
, and no error
94 * message related
to LWORK is issued by XERBLA
.
96 * INFO
(output
) INTEGER
97 * = 0: successful exit
98 * < 0: if INFO
= -i
, the i
-th argument had an illegal value
99 * > 0: if INFO
= i
, D
(i
,i
) is exactly zero
. The factorization
100 * has been completed
, but the block diagonal matrix D is
101 * exactly singular
, so the solution could not be computed
.
103 * =====================================================================
105 * .. Local Scalars
..
109 * .. External Functions
..
112 EXTERNAL LSAME
, ILAENV
114 * .. External Subroutines
..
115 EXTERNAL DSYTRF
, DSYTRS
, XERBLA
117 * .. Intrinsic Functions
..
120 * .. Executable Statements
..
122 * Test the input parameters
.
125 LQUERY
= ( LWORK
.EQ
.-1 )
126 IF( .NOT
.LSAME
( UPLO
, 'U' ) .AND
. .NOT
.LSAME
( UPLO
, 'L' ) ) THEN
128 ELSE IF( N
.LT
.0 ) THEN
130 ELSE IF( NRHS
.LT
.0 ) THEN
132 ELSE IF( LDA
.LT
.MAX
( 1, N
) ) THEN
134 ELSE IF( LDB
.LT
.MAX
( 1, N
) ) THEN
136 ELSE IF( LWORK
.LT
.1 .AND
. .NOT
.LQUERY
) THEN
144 NB
= ILAENV
( 1, 'DSYTRF', UPLO
, N
, -1, -1, -1 )
151 CALL XERBLA
( 'DSYSV ', -INFO
)
153 ELSE IF( LQUERY
) THEN
157 * Compute the factorization A
= U*D*U
' or A = L*D*L'.
159 CALL DSYTRF
( UPLO
, N
, A
, LDA
, IPIV
, WORK
, LWORK
, INFO
)
162 * Solve the system A*X
= B
, overwriting B with X
.
164 CALL DSYTRS
( UPLO
, N
, NRHS
, A
, LDA
, IPIV
, B
, LDB
, INFO
)