1 SUBROUTINE ZTRSV
( UPLO
, TRANS
, DIAG
, N
, A
, LDA
, X
, INCX
)
2 * .. Scalar Arguments
..
4 CHARACTER*1 DIAG
, TRANS
, UPLO
5 * .. Array Arguments
..
6 COMPLEX*16 A
( LDA
, * ), X
( * )
12 * ZTRSV solves one of the systems of equations
14 * A*x
= b
, or A
'*x = b, or conjg( A' )*x
= b
,
16 * where b and x are n element vectors and A is an n by n unit
, or
17 * non
-unit
, upper or lower triangular matrix
.
19 * No test
for singularity or near
-singularity is included in this
20 * routine
. Such tests must be performed before calling this routine
.
26 * On entry
, UPLO specifies whether the matrix is an upper or
27 * lower triangular matrix as follows
:
29 * UPLO
= 'U' or
'u' A is an upper triangular matrix
.
31 * UPLO
= 'L' or
'l' A is a lower triangular matrix
.
35 * TRANS
- CHARACTER*1
.
36 * On entry
, TRANS specifies the equations
to be solved as
39 * TRANS
= 'N' or
'n' A*x
= b
.
41 * TRANS
= 'T' or
't' A
'*x = b.
43 * TRANS = 'C
' or 'c
' conjg( A' )*x
= b
.
48 * On entry
, DIAG specifies whether or not A is unit
49 * triangular as follows
:
51 * DIAG
= 'U' or
'u' A is assumed
to be unit triangular
.
53 * DIAG
= 'N' or
'n' A is not assumed
to be unit
59 * On entry
, N specifies the order of the matrix A
.
60 * N must be at least zero
.
63 * A
- COMPLEX*16 array of
DIMENSION ( LDA
, n
).
64 * Before entry with UPLO
= 'U' or
'u', the leading n by n
65 * upper triangular part of the array A must contain the upper
66 * triangular matrix and the strictly lower triangular part of
67 * A is not referenced
.
68 * Before entry with UPLO
= 'L' or
'l', the leading n by n
69 * lower triangular part of the array A must contain the lower
70 * triangular matrix and the strictly upper triangular part of
71 * A is not referenced
.
72 * Note that when DIAG
= 'U' or
'u', the diagonal elements of
73 * A are not referenced either
, but are assumed
to be unity
.
77 * On entry
, LDA specifies the first
dimension of A as declared
78 * in the calling
(sub
) program. LDA must be at least
82 * X
- COMPLEX*16 array of
dimension at least
83 * ( 1 + ( n
- 1 )*abs
( INCX
) ).
84 * Before entry
, the incremented array X must contain the n
85 * element right
-hand side vector b
. On exit
, X is overwritten
86 * with the solution vector x
.
89 * On entry
, INCX specifies the increment
for the elements of
90 * X
. INCX must not be zero
.
94 * Level
2 Blas routine
.
96 * -- Written on
22-October
-1986.
97 * Jack Dongarra
, Argonne National Lab
.
98 * Jeremy Du Croz
, Nag Central Office
.
99 * Sven Hammarling
, Nag Central Office
.
100 * Richard Hanson
, Sandia National Labs
.
105 PARAMETER ( ZERO
= ( 0.0D
+0, 0.0D
+0 ) )
106 * .. Local Scalars
..
108 INTEGER I
, INFO
, IX
, J
, JX
, KX
109 LOGICAL NOCONJ
, NOUNIT
110 * .. External Functions
..
113 * .. External Subroutines
..
115 * .. Intrinsic Functions
..
116 INTRINSIC DCONJG
, MAX
118 * .. Executable Statements
..
120 * Test the input parameters
.
123 IF ( .NOT
.LSAME
( UPLO
, 'U' ).AND
.
124 $
.NOT
.LSAME
( UPLO
, 'L' ) )THEN
126 ELSE IF( .NOT
.LSAME
( TRANS
, 'N' ).AND
.
127 $
.NOT
.LSAME
( TRANS
, 'T' ).AND
.
128 $
.NOT
.LSAME
( TRANS
, 'C' ) )THEN
130 ELSE IF( .NOT
.LSAME
( DIAG
, 'U' ).AND
.
131 $
.NOT
.LSAME
( DIAG
, 'N' ) )THEN
133 ELSE IF( N
.LT
.0 )THEN
135 ELSE IF( LDA
.LT
.MAX
( 1, N
) )THEN
137 ELSE IF( INCX
.EQ
.0 )THEN
141 CALL XERBLA
( 'ZTRSV ', INFO
)
145 * Quick
return if possible
.
150 NOCONJ
= LSAME
( TRANS
, 'T' )
151 NOUNIT
= LSAME
( DIAG
, 'N' )
153 * Set up the start point in X
if the increment is not unity
. This
154 * will be
( N
- 1 )*INCX too small
for descending loops
.
157 KX
= 1 - ( N
- 1 )*INCX
158 ELSE IF( INCX
.NE
.1 )THEN
162 * Start the operations
. In this version the elements of A are
163 * accessed sequentially with one pass through A
.
165 IF( LSAME
( TRANS
, 'N' ) )THEN
167 * Form x
:= inv
( A
)*x
.
169 IF( LSAME
( UPLO
, 'U' ) )THEN
172 IF( X
( J
).NE
.ZERO
)THEN
174 $ X
( J
) = X
( J
)/A
( J
, J
)
176 DO 10, I
= J
- 1, 1, -1
177 X
( I
) = X
( I
) - TEMP*A
( I
, J
)
182 JX
= KX
+ ( N
- 1 )*INCX
184 IF( X
( JX
).NE
.ZERO
)THEN
186 $ X
( JX
) = X
( JX
)/A
( J
, J
)
189 DO 30, I
= J
- 1, 1, -1
191 X
( IX
) = X
( IX
) - TEMP*A
( I
, J
)
200 IF( X
( J
).NE
.ZERO
)THEN
202 $ X
( J
) = X
( J
)/A
( J
, J
)
205 X
( I
) = X
( I
) - TEMP*A
( I
, J
)
212 IF( X
( JX
).NE
.ZERO
)THEN
214 $ X
( JX
) = X
( JX
)/A
( J
, J
)
219 X
( IX
) = X
( IX
) - TEMP*A
( I
, J
)
228 * Form x
:= inv
( A
' )*x or x := inv( conjg( A' ) )*x
.
230 IF( LSAME
( UPLO
, 'U' ) )THEN
236 TEMP
= TEMP
- A
( I
, J
)*X
( I
)
239 $ TEMP
= TEMP
/A
( J
, J
)
242 TEMP
= TEMP
- DCONJG
( A
( I
, J
) )*X
( I
)
245 $ TEMP
= TEMP
/DCONJG
( A
( J
, J
) )
256 TEMP
= TEMP
- A
( I
, J
)*X
( IX
)
260 $ TEMP
= TEMP
/A
( J
, J
)
263 TEMP
= TEMP
- DCONJG
( A
( I
, J
) )*X
( IX
)
267 $ TEMP
= TEMP
/DCONJG
( A
( J
, J
) )
278 DO 150, I
= N
, J
+ 1, -1
279 TEMP
= TEMP
- A
( I
, J
)*X
( I
)
282 $ TEMP
= TEMP
/A
( J
, J
)
284 DO 160, I
= N
, J
+ 1, -1
285 TEMP
= TEMP
- DCONJG
( A
( I
, J
) )*X
( I
)
288 $ TEMP
= TEMP
/DCONJG
( A
( J
, J
) )
293 KX
= KX
+ ( N
- 1 )*INCX
299 DO 180, I
= N
, J
+ 1, -1
300 TEMP
= TEMP
- A
( I
, J
)*X
( IX
)
304 $ TEMP
= TEMP
/A
( J
, J
)
306 DO 190, I
= N
, J
+ 1, -1
307 TEMP
= TEMP
- DCONJG
( A
( I
, J
) )*X
( IX
)
311 $ TEMP
= TEMP
/DCONJG
( A
( J
, J
) )