LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
strsv.f
Go to the documentation of this file.
1 *> \brief \b STRSV
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE STRSV(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
12 *
13 * .. Scalar Arguments ..
14 * INTEGER INCX,LDA,N
15 * CHARACTER DIAG,TRANS,UPLO
16 * ..
17 * .. Array Arguments ..
18 * REAL A(LDA,*),X(*)
19 * ..
20 *
21 *
22 *> \par Purpose:
23 * =============
24 *>
25 *> \verbatim
26 *>
27 *> STRSV solves one of the systems of equations
28 *>
29 *> A*x = b, or A**T*x = b,
30 *>
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.
33 *>
34 *> No test for singularity or near-singularity is included in this
35 *> routine. Such tests must be performed before calling this routine.
36 *> \endverbatim
37 *
38 * Arguments:
39 * ==========
40 *
41 *> \param[in] UPLO
42 *> \verbatim
43 *> UPLO is CHARACTER*1
44 *> On entry, UPLO specifies whether the matrix is an upper or
45 *> lower triangular matrix as follows:
46 *>
47 *> UPLO = 'U' or 'u' A is an upper triangular matrix.
48 *>
49 *> UPLO = 'L' or 'l' A is a lower triangular matrix.
50 *> \endverbatim
51 *>
52 *> \param[in] TRANS
53 *> \verbatim
54 *> TRANS is CHARACTER*1
55 *> On entry, TRANS specifies the equations to be solved as
56 *> follows:
57 *>
58 *> TRANS = 'N' or 'n' A*x = b.
59 *>
60 *> TRANS = 'T' or 't' A**T*x = b.
61 *>
62 *> TRANS = 'C' or 'c' A**T*x = b.
63 *> \endverbatim
64 *>
65 *> \param[in] DIAG
66 *> \verbatim
67 *> DIAG is CHARACTER*1
68 *> On entry, DIAG specifies whether or not A is unit
69 *> triangular as follows:
70 *>
71 *> DIAG = 'U' or 'u' A is assumed to be unit triangular.
72 *>
73 *> DIAG = 'N' or 'n' A is not assumed to be unit
74 *> triangular.
75 *> \endverbatim
76 *>
77 *> \param[in] N
78 *> \verbatim
79 *> N is INTEGER
80 *> On entry, N specifies the order of the matrix A.
81 *> N must be at least zero.
82 *> \endverbatim
83 *>
84 *> \param[in] A
85 *> \verbatim
86 *> A is REAL array of DIMENSION ( LDA, n ).
87 *> Before entry with UPLO = 'U' or 'u', the leading n by n
88 *> upper triangular part of the array A must contain the upper
89 *> triangular matrix and the strictly lower triangular part of
90 *> A is not referenced.
91 *> Before entry with UPLO = 'L' or 'l', the leading n by n
92 *> lower triangular part of the array A must contain the lower
93 *> triangular matrix and the strictly upper triangular part of
94 *> A is not referenced.
95 *> Note that when DIAG = 'U' or 'u', the diagonal elements of
96 *> A are not referenced either, but are assumed to be unity.
97 *> \endverbatim
98 *>
99 *> \param[in] LDA
100 *> \verbatim
101 *> LDA is INTEGER
102 *> On entry, LDA specifies the first dimension of A as declared
103 *> in the calling (sub) program. LDA must be at least
104 *> max( 1, n ).
105 *> \endverbatim
106 *>
107 *> \param[in,out] X
108 *> \verbatim
109 *> X is REAL array of dimension at least
110 *> ( 1 + ( n - 1 )*abs( INCX ) ).
111 *> Before entry, the incremented array X must contain the n
112 *> element right-hand side vector b. On exit, X is overwritten
113 *> with the solution vector x.
114 *> \endverbatim
115 *>
116 *> \param[in] INCX
117 *> \verbatim
118 *> INCX is INTEGER
119 *> On entry, INCX specifies the increment for the elements of
120 *> X. INCX must not be zero.
121 *> \endverbatim
122 *
123 * Authors:
124 * ========
125 *
126 *> \author Univ. of Tennessee
127 *> \author Univ. of California Berkeley
128 *> \author Univ. of Colorado Denver
129 *> \author NAG Ltd.
130 *
131 *> \date November 2011
132 *
133 *> \ingroup single_blas_level2
134 *
135 *> \par Further Details:
136 * =====================
137 *>
138 *> \verbatim
139 *>
140 *> Level 2 Blas routine.
141 *>
142 *> -- Written on 22-October-1986.
143 *> Jack Dongarra, Argonne National Lab.
144 *> Jeremy Du Croz, Nag Central Office.
145 *> Sven Hammarling, Nag Central Office.
146 *> Richard Hanson, Sandia National Labs.
147 *> \endverbatim
148 *>
149 * =====================================================================
150  SUBROUTINE strsv(UPLO,TRANS,DIAG,N,A,LDA,X,INCX)
151 *
152 * -- Reference BLAS level2 routine (version 3.4.0) --
153 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
154 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
155 * November 2011
156 *
157 * .. Scalar Arguments ..
158  INTEGER incx,lda,n
159  CHARACTER diag,trans,uplo
160 * ..
161 * .. Array Arguments ..
162  REAL a(lda,*),x(*)
163 * ..
164 *
165 * =====================================================================
166 *
167 * .. Parameters ..
168  REAL zero
169  parameter(zero=0.0e+0)
170 * ..
171 * .. Local Scalars ..
172  REAL temp
173  INTEGER i,info,ix,j,jx,kx
174  LOGICAL nounit
175 * ..
176 * .. External Functions ..
177  LOGICAL lsame
178  EXTERNAL lsame
179 * ..
180 * .. External Subroutines ..
181  EXTERNAL xerbla
182 * ..
183 * .. Intrinsic Functions ..
184  INTRINSIC max
185 * ..
186 *
187 * Test the input parameters.
188 *
189  info = 0
190  IF (.NOT.lsame(uplo,'U') .AND. .NOT.lsame(uplo,'L')) THEN
191  info = 1
192  ELSE IF (.NOT.lsame(trans,'N') .AND. .NOT.lsame(trans,'T') .AND.
193  + .NOT.lsame(trans,'C')) THEN
194  info = 2
195  ELSE IF (.NOT.lsame(diag,'U') .AND. .NOT.lsame(diag,'N')) THEN
196  info = 3
197  ELSE IF (n.LT.0) THEN
198  info = 4
199  ELSE IF (lda.LT.max(1,n)) THEN
200  info = 6
201  ELSE IF (incx.EQ.0) THEN
202  info = 8
203  END IF
204  IF (info.NE.0) THEN
205  CALL xerbla('STRSV ',info)
206  return
207  END IF
208 *
209 * Quick return if possible.
210 *
211  IF (n.EQ.0) return
212 *
213  nounit = lsame(diag,'N')
214 *
215 * Set up the start point in X if the increment is not unity. This
216 * will be ( N - 1 )*INCX too small for descending loops.
217 *
218  IF (incx.LE.0) THEN
219  kx = 1 - (n-1)*incx
220  ELSE IF (incx.NE.1) THEN
221  kx = 1
222  END IF
223 *
224 * Start the operations. In this version the elements of A are
225 * accessed sequentially with one pass through A.
226 *
227  IF (lsame(trans,'N')) THEN
228 *
229 * Form x := inv( A )*x.
230 *
231  IF (lsame(uplo,'U')) THEN
232  IF (incx.EQ.1) THEN
233  DO 20 j = n,1,-1
234  IF (x(j).NE.zero) THEN
235  IF (nounit) x(j) = x(j)/a(j,j)
236  temp = x(j)
237  DO 10 i = j - 1,1,-1
238  x(i) = x(i) - temp*a(i,j)
239  10 continue
240  END IF
241  20 continue
242  ELSE
243  jx = kx + (n-1)*incx
244  DO 40 j = n,1,-1
245  IF (x(jx).NE.zero) THEN
246  IF (nounit) x(jx) = x(jx)/a(j,j)
247  temp = x(jx)
248  ix = jx
249  DO 30 i = j - 1,1,-1
250  ix = ix - incx
251  x(ix) = x(ix) - temp*a(i,j)
252  30 continue
253  END IF
254  jx = jx - incx
255  40 continue
256  END IF
257  ELSE
258  IF (incx.EQ.1) THEN
259  DO 60 j = 1,n
260  IF (x(j).NE.zero) THEN
261  IF (nounit) x(j) = x(j)/a(j,j)
262  temp = x(j)
263  DO 50 i = j + 1,n
264  x(i) = x(i) - temp*a(i,j)
265  50 continue
266  END IF
267  60 continue
268  ELSE
269  jx = kx
270  DO 80 j = 1,n
271  IF (x(jx).NE.zero) THEN
272  IF (nounit) x(jx) = x(jx)/a(j,j)
273  temp = x(jx)
274  ix = jx
275  DO 70 i = j + 1,n
276  ix = ix + incx
277  x(ix) = x(ix) - temp*a(i,j)
278  70 continue
279  END IF
280  jx = jx + incx
281  80 continue
282  END IF
283  END IF
284  ELSE
285 *
286 * Form x := inv( A**T )*x.
287 *
288  IF (lsame(uplo,'U')) THEN
289  IF (incx.EQ.1) THEN
290  DO 100 j = 1,n
291  temp = x(j)
292  DO 90 i = 1,j - 1
293  temp = temp - a(i,j)*x(i)
294  90 continue
295  IF (nounit) temp = temp/a(j,j)
296  x(j) = temp
297  100 continue
298  ELSE
299  jx = kx
300  DO 120 j = 1,n
301  temp = x(jx)
302  ix = kx
303  DO 110 i = 1,j - 1
304  temp = temp - a(i,j)*x(ix)
305  ix = ix + incx
306  110 continue
307  IF (nounit) temp = temp/a(j,j)
308  x(jx) = temp
309  jx = jx + incx
310  120 continue
311  END IF
312  ELSE
313  IF (incx.EQ.1) THEN
314  DO 140 j = n,1,-1
315  temp = x(j)
316  DO 130 i = n,j + 1,-1
317  temp = temp - a(i,j)*x(i)
318  130 continue
319  IF (nounit) temp = temp/a(j,j)
320  x(j) = temp
321  140 continue
322  ELSE
323  kx = kx + (n-1)*incx
324  jx = kx
325  DO 160 j = n,1,-1
326  temp = x(jx)
327  ix = kx
328  DO 150 i = n,j + 1,-1
329  temp = temp - a(i,j)*x(ix)
330  ix = ix - incx
331  150 continue
332  IF (nounit) temp = temp/a(j,j)
333  x(jx) = temp
334  jx = jx - incx
335  160 continue
336  END IF
337  END IF
338  END IF
339 *
340  return
341 *
342 * End of STRSV .
343 *
344  END