3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE CTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
13 * .. Scalar Arguments ..
15 * CHARACTER DIAG,TRANS,UPLO
17 * .. Array Arguments ..
27 *> CTPSV solves one of the systems of equations
29 *> A*x = b, or A**T*x = b, or A**H*x = b,
31 *> where b and x are n element vectors and A is an n by n unit, or
32 *> non-unit, upper or lower triangular matrix, supplied in packed form.
34 *> No test for singularity or near-singularity is included in this
35 *> routine. Such tests must be performed before calling this routine.
43 *> UPLO is CHARACTER*1
44 *> On entry, UPLO specifies whether the matrix is an upper or
45 *> lower triangular matrix as follows:
47 *> UPLO = 'U' or 'u' A is an upper triangular matrix.
49 *> UPLO = 'L' or 'l' A is a lower triangular matrix.
54 *> TRANS is CHARACTER*1
55 *> On entry, TRANS specifies the equations to be solved as
58 *> TRANS = 'N' or 'n' A*x = b.
60 *> TRANS = 'T' or 't' A**T*x = b.
62 *> TRANS = 'C' or 'c' A**H*x = b.
67 *> DIAG is CHARACTER*1
68 *> On entry, DIAG specifies whether or not A is unit
69 *> triangular as follows:
71 *> DIAG = 'U' or 'u' A is assumed to be unit triangular.
73 *> DIAG = 'N' or 'n' A is not assumed to be unit
80 *> On entry, N specifies the order of the matrix A.
81 *> N must be at least zero.
86 *> AP is COMPLEX array of DIMENSION at least
87 *> ( ( n*( n + 1 ) )/2 ).
88 *> Before entry with UPLO = 'U' or 'u', the array AP must
89 *> contain the upper triangular matrix packed sequentially,
90 *> column by column, so that AP( 1 ) contains a( 1, 1 ),
91 *> AP( 2 ) and AP( 3 ) contain a( 1, 2 ) and a( 2, 2 )
92 *> respectively, and so on.
93 *> Before entry with UPLO = 'L' or 'l', the array AP must
94 *> contain the lower triangular matrix packed sequentially,
95 *> column by column, so that AP( 1 ) contains a( 1, 1 ),
96 *> AP( 2 ) and AP( 3 ) contain a( 2, 1 ) and a( 3, 1 )
97 *> respectively, and so on.
98 *> Note that when DIAG = 'U' or 'u', the diagonal elements of
99 *> A are not referenced, but are assumed to be unity.
104 *> X is COMPLEX array of dimension at least
105 *> ( 1 + ( n - 1 )*abs( INCX ) ).
106 *> Before entry, the incremented array X must contain the n
107 *> element right-hand side vector b. On exit, X is overwritten
108 *> with the solution vector x.
114 *> On entry, INCX specifies the increment for the elements of
115 *> X. INCX must not be zero.
121 *> \author Univ. of Tennessee
122 *> \author Univ. of California Berkeley
123 *> \author Univ. of Colorado Denver
126 *> \date November 2011
128 *> \ingroup complex_blas_level2
130 *> \par Further Details:
131 * =====================
135 *> Level 2 Blas routine.
137 *> -- Written on 22-October-1986.
138 *> Jack Dongarra, Argonne National Lab.
139 *> Jeremy Du Croz, Nag Central Office.
140 *> Sven Hammarling, Nag Central Office.
141 *> Richard Hanson, Sandia National Labs.
144 * =====================================================================
145 SUBROUTINE CTPSV(UPLO,TRANS,DIAG,N,AP,X,INCX)
147 * -- Reference BLAS level2 routine (version 3.4.0) --
148 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
149 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
152 * .. Scalar Arguments ..
154 CHARACTER DIAG,TRANS,UPLO
156 * .. Array Arguments ..
160 * =====================================================================
164 PARAMETER (ZERO= (0.0E+0,0.0E+0))
166 * .. Local Scalars ..
168 INTEGER I,INFO,IX,J,JX,K,KK,KX
169 LOGICAL NOCONJ,NOUNIT
171 * .. External Functions ..
175 * .. External Subroutines ..
178 * .. Intrinsic Functions ..
182 * Test the input parameters.
185 IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
187 ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
188 + .NOT.LSAME(TRANS,'C')) THEN
190 ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
192 ELSE IF (N.LT.0) THEN
194 ELSE IF (INCX.EQ.0) THEN
198 CALL XERBLA('CTPSV ',INFO)
202 * Quick return if possible.
206 NOCONJ = LSAME(TRANS,'T')
207 NOUNIT = LSAME(DIAG,'N')
209 * Set up the start point in X if the increment is not unity. This
210 * will be ( N - 1 )*INCX too small for descending loops.
214 ELSE IF (INCX.NE.1) THEN
218 * Start the operations. In this version the elements of AP are
219 * accessed sequentially with one pass through AP.
221 IF (LSAME(TRANS,'N')) THEN
223 * Form x := inv( A )*x.
225 IF (LSAME(UPLO,'U')) THEN
229 IF (X(J).NE.ZERO) THEN
230 IF (NOUNIT) X(J) = X(J)/AP(KK)
234 X(I) = X(I) - TEMP*AP(K)
243 IF (X(JX).NE.ZERO) THEN
244 IF (NOUNIT) X(JX) = X(JX)/AP(KK)
247 DO 30 K = KK - 1,KK - J + 1,-1
249 X(IX) = X(IX) - TEMP*AP(K)
260 IF (X(J).NE.ZERO) THEN
261 IF (NOUNIT) X(J) = X(J)/AP(KK)
265 X(I) = X(I) - TEMP*AP(K)
274 IF (X(JX).NE.ZERO) THEN
275 IF (NOUNIT) X(JX) = X(JX)/AP(KK)
278 DO 70 K = KK + 1,KK + N - J
280 X(IX) = X(IX) - TEMP*AP(K)
290 * Form x := inv( A**T )*x or x := inv( A**H )*x.
292 IF (LSAME(UPLO,'U')) THEN
300 TEMP = TEMP - AP(K)*X(I)
303 IF (NOUNIT) TEMP = TEMP/AP(KK+J-1)
306 TEMP = TEMP - CONJG(AP(K))*X(I)
309 IF (NOUNIT) TEMP = TEMP/CONJG(AP(KK+J-1))
320 DO 120 K = KK,KK + J - 2
321 TEMP = TEMP - AP(K)*X(IX)
324 IF (NOUNIT) TEMP = TEMP/AP(KK+J-1)
326 DO 130 K = KK,KK + J - 2
327 TEMP = TEMP - CONJG(AP(K))*X(IX)
330 IF (NOUNIT) TEMP = TEMP/CONJG(AP(KK+J-1))
344 DO 150 I = N,J + 1,-1
345 TEMP = TEMP - AP(K)*X(I)
348 IF (NOUNIT) TEMP = TEMP/AP(KK-N+J)
350 DO 160 I = N,J + 1,-1
351 TEMP = TEMP - CONJG(AP(K))*X(I)
354 IF (NOUNIT) TEMP = TEMP/CONJG(AP(KK-N+J))
366 DO 180 K = KK,KK - (N- (J+1)),-1
367 TEMP = TEMP - AP(K)*X(IX)
370 IF (NOUNIT) TEMP = TEMP/AP(KK-N+J)
372 DO 190 K = KK,KK - (N- (J+1)),-1
373 TEMP = TEMP - CONJG(AP(K))*X(IX)
376 IF (NOUNIT) TEMP = TEMP/CONJG(AP(KK-N+J))