OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches

Functions

subroutine sgtcon (norm, n, dl, d, du, du2, ipiv, anorm, rcond, work, iwork, info)
 SGTCON
subroutine sgtrfs (trans, n, nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, ldb, x, ldx, ferr, berr, work, iwork, info)
 SGTRFS
subroutine sgttrf (n, dl, d, du, du2, ipiv, info)
 SGTTRF
subroutine sgttrs (trans, n, nrhs, dl, d, du, du2, ipiv, b, ldb, info)
 SGTTRS
subroutine sgtts2 (itrans, n, nrhs, dl, d, du, du2, ipiv, b, ldb)
 SGTTS2 solves a system of linear equations with a tridiagonal matrix using the LU factorization computed by sgttrf.

Detailed Description

This is the group of real computational functions for GT matrices

Function Documentation

◆ sgtcon()

subroutine sgtcon ( character norm,
integer n,
real, dimension( * ) dl,
real, dimension( * ) d,
real, dimension( * ) du,
real, dimension( * ) du2,
integer, dimension( * ) ipiv,
real anorm,
real rcond,
real, dimension( * ) work,
integer, dimension( * ) iwork,
integer info )

SGTCON

Download SGTCON + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGTCON estimates the reciprocal of the condition number of a real
!> tridiagonal matrix A using the LU factorization as computed by
!> SGTTRF.
!>
!> An estimate is obtained for norm(inv(A)), and the reciprocal of the
!> condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
!> 
Parameters
[in]NORM
!>          NORM is CHARACTER*1
!>          Specifies whether the 1-norm condition number or the
!>          infinity-norm condition number is required:
!>          = '1' or 'O':  1-norm;
!>          = 'I':         Infinity-norm.
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in]DL
!>          DL is REAL array, dimension (N-1)
!>          The (n-1) multipliers that define the matrix L from the
!>          LU factorization of A as computed by SGTTRF.
!> 
[in]D
!>          D is REAL array, dimension (N)
!>          The n diagonal elements of the upper triangular matrix U from
!>          the LU factorization of A.
!> 
[in]DU
!>          DU is REAL array, dimension (N-1)
!>          The (n-1) elements of the first superdiagonal of U.
!> 
[in]DU2
!>          DU2 is REAL array, dimension (N-2)
!>          The (n-2) elements of the second superdiagonal of U.
!> 
[in]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          The pivot indices; for 1 <= i <= n, row i of the matrix was
!>          interchanged with row IPIV(i).  IPIV(i) will always be either
!>          i or i+1; IPIV(i) = i indicates a row interchange was not
!>          required.
!> 
[in]ANORM
!>          ANORM is REAL
!>          If NORM = '1' or 'O', the 1-norm of the original matrix A.
!>          If NORM = 'I', the infinity-norm of the original matrix A.
!> 
[out]RCOND
!>          RCOND is REAL
!>          The reciprocal of the condition number of the matrix A,
!>          computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
!>          estimate of the 1-norm of inv(A) computed in this routine.
!> 
[out]WORK
!>          WORK is REAL array, dimension (2*N)
!> 
[out]IWORK
!>          IWORK is INTEGER array, dimension (N)
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 144 of file sgtcon.f.

146*
147* -- LAPACK computational routine --
148* -- LAPACK is a software package provided by Univ. of Tennessee, --
149* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
150*
151* .. Scalar Arguments ..
152 CHARACTER NORM
153 INTEGER INFO, N
154 REAL ANORM, RCOND
155* ..
156* .. Array Arguments ..
157 INTEGER IPIV( * ), IWORK( * )
158 REAL D( * ), DL( * ), DU( * ), DU2( * ), WORK( * )
159* ..
160*
161* =====================================================================
162*
163* .. Parameters ..
164 REAL ONE, ZERO
165 parameter( one = 1.0e+0, zero = 0.0e+0 )
166* ..
167* .. Local Scalars ..
168 LOGICAL ONENRM
169 INTEGER I, KASE, KASE1
170 REAL AINVNM
171* ..
172* .. Local Arrays ..
173 INTEGER ISAVE( 3 )
174* ..
175* .. External Functions ..
176 LOGICAL LSAME
177 EXTERNAL lsame
178* ..
179* .. External Subroutines ..
180 EXTERNAL sgttrs, slacn2, xerbla
181* ..
182* .. Executable Statements ..
183*
184* Test the input arguments.
185*
186 info = 0
187 onenrm = norm.EQ.'1' .OR. lsame( norm, 'O' )
188 IF( .NOT.onenrm .AND. .NOT.lsame( norm, 'I' ) ) THEN
189 info = -1
190 ELSE IF( n.LT.0 ) THEN
191 info = -2
192 ELSE IF( anorm.LT.zero ) THEN
193 info = -8
194 END IF
195 IF( info.NE.0 ) THEN
196 CALL xerbla( 'SGTCON', -info )
197 RETURN
198 END IF
199*
200* Quick return if possible
201*
202 rcond = zero
203 IF( n.EQ.0 ) THEN
204 rcond = one
205 RETURN
206 ELSE IF( anorm.EQ.zero ) THEN
207 RETURN
208 END IF
209*
210* Check that D(1:N) is non-zero.
211*
212 DO 10 i = 1, n
213 IF( d( i ).EQ.zero )
214 $ RETURN
215 10 CONTINUE
216*
217 ainvnm = zero
218 IF( onenrm ) THEN
219 kase1 = 1
220 ELSE
221 kase1 = 2
222 END IF
223 kase = 0
224 20 CONTINUE
225 CALL slacn2( n, work( n+1 ), work, iwork, ainvnm, kase, isave )
226 IF( kase.NE.0 ) THEN
227 IF( kase.EQ.kase1 ) THEN
228*
229* Multiply by inv(U)*inv(L).
230*
231 CALL sgttrs( 'No transpose', n, 1, dl, d, du, du2, ipiv,
232 $ work, n, info )
233 ELSE
234*
235* Multiply by inv(L**T)*inv(U**T).
236*
237 CALL sgttrs( 'Transpose', n, 1, dl, d, du, du2, ipiv, work,
238 $ n, info )
239 END IF
240 GO TO 20
241 END IF
242*
243* Compute the estimate of the reciprocal condition number.
244*
245 IF( ainvnm.NE.zero )
246 $ rcond = ( one / ainvnm ) / anorm
247*
248 RETURN
249*
250* End of SGTCON
251*
norm(diag(diag(diag(inv(mat))) -id.SOL), 2) % destroy mumps instance id.JOB
subroutine xerbla(srname, info)
XERBLA
Definition xerbla.f:60
logical function lsame(ca, cb)
LSAME
Definition lsame.f:53
subroutine sgttrs(trans, n, nrhs, dl, d, du, du2, ipiv, b, ldb, info)
SGTTRS
Definition sgttrs.f:138
subroutine slacn2(n, v, x, isgn, est, kase, isave)
SLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition slacn2.f:136

◆ sgtrfs()

subroutine sgtrfs ( character trans,
integer n,
integer nrhs,
real, dimension( * ) dl,
real, dimension( * ) d,
real, dimension( * ) du,
real, dimension( * ) dlf,
real, dimension( * ) df,
real, dimension( * ) duf,
real, dimension( * ) du2,
integer, dimension( * ) ipiv,
real, dimension( ldb, * ) b,
integer ldb,
real, dimension( ldx, * ) x,
integer ldx,
real, dimension( * ) ferr,
real, dimension( * ) berr,
real, dimension( * ) work,
integer, dimension( * ) iwork,
integer info )

SGTRFS

Download SGTRFS + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGTRFS improves the computed solution to a system of linear
!> equations when the coefficient matrix is tridiagonal, and provides
!> error bounds and backward error estimates for the solution.
!> 
Parameters
[in]TRANS
!>          TRANS is CHARACTER*1
!>          Specifies the form of the system of equations:
!>          = 'N':  A * X = B     (No transpose)
!>          = 'T':  A**T * X = B  (Transpose)
!>          = 'C':  A**H * X = B  (Conjugate transpose = Transpose)
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in]NRHS
!>          NRHS is INTEGER
!>          The number of right hand sides, i.e., the number of columns
!>          of the matrix B.  NRHS >= 0.
!> 
[in]DL
!>          DL is REAL array, dimension (N-1)
!>          The (n-1) subdiagonal elements of A.
!> 
[in]D
!>          D is REAL array, dimension (N)
!>          The diagonal elements of A.
!> 
[in]DU
!>          DU is REAL array, dimension (N-1)
!>          The (n-1) superdiagonal elements of A.
!> 
[in]DLF
!>          DLF is REAL array, dimension (N-1)
!>          The (n-1) multipliers that define the matrix L from the
!>          LU factorization of A as computed by SGTTRF.
!> 
[in]DF
!>          DF is REAL array, dimension (N)
!>          The n diagonal elements of the upper triangular matrix U from
!>          the LU factorization of A.
!> 
[in]DUF
!>          DUF is REAL array, dimension (N-1)
!>          The (n-1) elements of the first superdiagonal of U.
!> 
[in]DU2
!>          DU2 is REAL array, dimension (N-2)
!>          The (n-2) elements of the second superdiagonal of U.
!> 
[in]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          The pivot indices; for 1 <= i <= n, row i of the matrix was
!>          interchanged with row IPIV(i).  IPIV(i) will always be either
!>          i or i+1; IPIV(i) = i indicates a row interchange was not
!>          required.
!> 
[in]B
!>          B is REAL array, dimension (LDB,NRHS)
!>          The right hand side matrix B.
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B.  LDB >= max(1,N).
!> 
[in,out]X
!>          X is REAL array, dimension (LDX,NRHS)
!>          On entry, the solution matrix X, as computed by SGTTRS.
!>          On exit, the improved solution matrix X.
!> 
[in]LDX
!>          LDX is INTEGER
!>          The leading dimension of the array X.  LDX >= max(1,N).
!> 
[out]FERR
!>          FERR is REAL array, dimension (NRHS)
!>          The estimated forward error bound for each solution vector
!>          X(j) (the j-th column of the solution matrix X).
!>          If XTRUE is the true solution corresponding to X(j), FERR(j)
!>          is an estimated upper bound for the magnitude of the largest
!>          element in (X(j) - XTRUE) divided by the magnitude of the
!>          largest element in X(j).  The estimate is as reliable as
!>          the estimate for RCOND, and is almost always a slight
!>          overestimate of the true error.
!> 
[out]BERR
!>          BERR is REAL array, dimension (NRHS)
!>          The componentwise relative backward error of each solution
!>          vector X(j) (i.e., the smallest relative change in
!>          any element of A or B that makes X(j) an exact solution).
!> 
[out]WORK
!>          WORK is REAL array, dimension (3*N)
!> 
[out]IWORK
!>          IWORK is INTEGER array, dimension (N)
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Internal Parameters:
!>  ITMAX is the maximum number of steps of iterative refinement.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 206 of file sgtrfs.f.

209*
210* -- LAPACK computational routine --
211* -- LAPACK is a software package provided by Univ. of Tennessee, --
212* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
213*
214* .. Scalar Arguments ..
215 CHARACTER TRANS
216 INTEGER INFO, LDB, LDX, N, NRHS
217* ..
218* .. Array Arguments ..
219 INTEGER IPIV( * ), IWORK( * )
220 REAL B( LDB, * ), BERR( * ), D( * ), DF( * ),
221 $ DL( * ), DLF( * ), DU( * ), DU2( * ), DUF( * ),
222 $ FERR( * ), WORK( * ), X( LDX, * )
223* ..
224*
225* =====================================================================
226*
227* .. Parameters ..
228 INTEGER ITMAX
229 parameter( itmax = 5 )
230 REAL ZERO, ONE
231 parameter( zero = 0.0e+0, one = 1.0e+0 )
232 REAL TWO
233 parameter( two = 2.0e+0 )
234 REAL THREE
235 parameter( three = 3.0e+0 )
236* ..
237* .. Local Scalars ..
238 LOGICAL NOTRAN
239 CHARACTER TRANSN, TRANST
240 INTEGER COUNT, I, J, KASE, NZ
241 REAL EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN
242* ..
243* .. Local Arrays ..
244 INTEGER ISAVE( 3 )
245* ..
246* .. External Subroutines ..
247 EXTERNAL saxpy, scopy, sgttrs, slacn2, slagtm, xerbla
248* ..
249* .. Intrinsic Functions ..
250 INTRINSIC abs, max
251* ..
252* .. External Functions ..
253 LOGICAL LSAME
254 REAL SLAMCH
255 EXTERNAL lsame, slamch
256* ..
257* .. Executable Statements ..
258*
259* Test the input parameters.
260*
261 info = 0
262 notran = lsame( trans, 'N' )
263 IF( .NOT.notran .AND. .NOT.lsame( trans, 'T' ) .AND. .NOT.
264 $ lsame( trans, 'C' ) ) THEN
265 info = -1
266 ELSE IF( n.LT.0 ) THEN
267 info = -2
268 ELSE IF( nrhs.LT.0 ) THEN
269 info = -3
270 ELSE IF( ldb.LT.max( 1, n ) ) THEN
271 info = -13
272 ELSE IF( ldx.LT.max( 1, n ) ) THEN
273 info = -15
274 END IF
275 IF( info.NE.0 ) THEN
276 CALL xerbla( 'SGTRFS', -info )
277 RETURN
278 END IF
279*
280* Quick return if possible
281*
282 IF( n.EQ.0 .OR. nrhs.EQ.0 ) THEN
283 DO 10 j = 1, nrhs
284 ferr( j ) = zero
285 berr( j ) = zero
286 10 CONTINUE
287 RETURN
288 END IF
289*
290 IF( notran ) THEN
291 transn = 'N'
292 transt = 'T'
293 ELSE
294 transn = 'T'
295 transt = 'N'
296 END IF
297*
298* NZ = maximum number of nonzero elements in each row of A, plus 1
299*
300 nz = 4
301 eps = slamch( 'Epsilon' )
302 safmin = slamch( 'Safe minimum' )
303 safe1 = nz*safmin
304 safe2 = safe1 / eps
305*
306* Do for each right hand side
307*
308 DO 110 j = 1, nrhs
309*
310 count = 1
311 lstres = three
312 20 CONTINUE
313*
314* Loop until stopping criterion is satisfied.
315*
316* Compute residual R = B - op(A) * X,
317* where op(A) = A, A**T, or A**H, depending on TRANS.
318*
319 CALL scopy( n, b( 1, j ), 1, work( n+1 ), 1 )
320 CALL slagtm( trans, n, 1, -one, dl, d, du, x( 1, j ), ldx, one,
321 $ work( n+1 ), n )
322*
323* Compute abs(op(A))*abs(x) + abs(b) for use in the backward
324* error bound.
325*
326 IF( notran ) THEN
327 IF( n.EQ.1 ) THEN
328 work( 1 ) = abs( b( 1, j ) ) + abs( d( 1 )*x( 1, j ) )
329 ELSE
330 work( 1 ) = abs( b( 1, j ) ) + abs( d( 1 )*x( 1, j ) ) +
331 $ abs( du( 1 )*x( 2, j ) )
332 DO 30 i = 2, n - 1
333 work( i ) = abs( b( i, j ) ) +
334 $ abs( dl( i-1 )*x( i-1, j ) ) +
335 $ abs( d( i )*x( i, j ) ) +
336 $ abs( du( i )*x( i+1, j ) )
337 30 CONTINUE
338 work( n ) = abs( b( n, j ) ) +
339 $ abs( dl( n-1 )*x( n-1, j ) ) +
340 $ abs( d( n )*x( n, j ) )
341 END IF
342 ELSE
343 IF( n.EQ.1 ) THEN
344 work( 1 ) = abs( b( 1, j ) ) + abs( d( 1 )*x( 1, j ) )
345 ELSE
346 work( 1 ) = abs( b( 1, j ) ) + abs( d( 1 )*x( 1, j ) ) +
347 $ abs( dl( 1 )*x( 2, j ) )
348 DO 40 i = 2, n - 1
349 work( i ) = abs( b( i, j ) ) +
350 $ abs( du( i-1 )*x( i-1, j ) ) +
351 $ abs( d( i )*x( i, j ) ) +
352 $ abs( dl( i )*x( i+1, j ) )
353 40 CONTINUE
354 work( n ) = abs( b( n, j ) ) +
355 $ abs( du( n-1 )*x( n-1, j ) ) +
356 $ abs( d( n )*x( n, j ) )
357 END IF
358 END IF
359*
360* Compute componentwise relative backward error from formula
361*
362* max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) )
363*
364* where abs(Z) is the componentwise absolute value of the matrix
365* or vector Z. If the i-th component of the denominator is less
366* than SAFE2, then SAFE1 is added to the i-th components of the
367* numerator and denominator before dividing.
368*
369 s = zero
370 DO 50 i = 1, n
371 IF( work( i ).GT.safe2 ) THEN
372 s = max( s, abs( work( n+i ) ) / work( i ) )
373 ELSE
374 s = max( s, ( abs( work( n+i ) )+safe1 ) /
375 $ ( work( i )+safe1 ) )
376 END IF
377 50 CONTINUE
378 berr( j ) = s
379*
380* Test stopping criterion. Continue iterating if
381* 1) The residual BERR(J) is larger than machine epsilon, and
382* 2) BERR(J) decreased by at least a factor of 2 during the
383* last iteration, and
384* 3) At most ITMAX iterations tried.
385*
386 IF( berr( j ).GT.eps .AND. two*berr( j ).LE.lstres .AND.
387 $ count.LE.itmax ) THEN
388*
389* Update solution and try again.
390*
391 CALL sgttrs( trans, n, 1, dlf, df, duf, du2, ipiv,
392 $ work( n+1 ), n, info )
393 CALL saxpy( n, one, work( n+1 ), 1, x( 1, j ), 1 )
394 lstres = berr( j )
395 count = count + 1
396 GO TO 20
397 END IF
398*
399* Bound error from formula
400*
401* norm(X - XTRUE) / norm(X) .le. FERR =
402* norm( abs(inv(op(A)))*
403* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X)
404*
405* where
406* norm(Z) is the magnitude of the largest component of Z
407* inv(op(A)) is the inverse of op(A)
408* abs(Z) is the componentwise absolute value of the matrix or
409* vector Z
410* NZ is the maximum number of nonzeros in any row of A, plus 1
411* EPS is machine epsilon
412*
413* The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B))
414* is incremented by SAFE1 if the i-th component of
415* abs(op(A))*abs(X) + abs(B) is less than SAFE2.
416*
417* Use SLACN2 to estimate the infinity-norm of the matrix
418* inv(op(A)) * diag(W),
419* where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) )))
420*
421 DO 60 i = 1, n
422 IF( work( i ).GT.safe2 ) THEN
423 work( i ) = abs( work( n+i ) ) + nz*eps*work( i )
424 ELSE
425 work( i ) = abs( work( n+i ) ) + nz*eps*work( i ) + safe1
426 END IF
427 60 CONTINUE
428*
429 kase = 0
430 70 CONTINUE
431 CALL slacn2( n, work( 2*n+1 ), work( n+1 ), iwork, ferr( j ),
432 $ kase, isave )
433 IF( kase.NE.0 ) THEN
434 IF( kase.EQ.1 ) THEN
435*
436* Multiply by diag(W)*inv(op(A)**T).
437*
438 CALL sgttrs( transt, n, 1, dlf, df, duf, du2, ipiv,
439 $ work( n+1 ), n, info )
440 DO 80 i = 1, n
441 work( n+i ) = work( i )*work( n+i )
442 80 CONTINUE
443 ELSE
444*
445* Multiply by inv(op(A))*diag(W).
446*
447 DO 90 i = 1, n
448 work( n+i ) = work( i )*work( n+i )
449 90 CONTINUE
450 CALL sgttrs( transn, n, 1, dlf, df, duf, du2, ipiv,
451 $ work( n+1 ), n, info )
452 END IF
453 GO TO 70
454 END IF
455*
456* Normalize error.
457*
458 lstres = zero
459 DO 100 i = 1, n
460 lstres = max( lstres, abs( x( i, j ) ) )
461 100 CONTINUE
462 IF( lstres.NE.zero )
463 $ ferr( j ) = ferr( j ) / lstres
464*
465 110 CONTINUE
466*
467 RETURN
468*
469* End of SGTRFS
470*
subroutine slagtm(trans, n, nrhs, alpha, dl, d, du, x, ldx, beta, b, ldb)
SLAGTM performs a matrix-matrix product of the form C = αAB+βC, where A is a tridiagonal matrix,...
Definition slagtm.f:145
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
Definition scopy.f:82
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
Definition saxpy.f:89
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
#define max(a, b)
Definition macros.h:21

◆ sgttrf()

subroutine sgttrf ( integer n,
real, dimension( * ) dl,
real, dimension( * ) d,
real, dimension( * ) du,
real, dimension( * ) du2,
integer, dimension( * ) ipiv,
integer info )

SGTTRF

Download SGTTRF + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGTTRF computes an LU factorization of a real tridiagonal matrix A
!> using elimination with partial pivoting and row interchanges.
!>
!> The factorization has the form
!>    A = L * U
!> where L is a product of permutation and unit lower bidiagonal
!> matrices and U is upper triangular with nonzeros in only the main
!> diagonal and first two superdiagonals.
!> 
Parameters
[in]N
!>          N is INTEGER
!>          The order of the matrix A.
!> 
[in,out]DL
!>          DL is REAL array, dimension (N-1)
!>          On entry, DL must contain the (n-1) sub-diagonal elements of
!>          A.
!>
!>          On exit, DL is overwritten by the (n-1) multipliers that
!>          define the matrix L from the LU factorization of A.
!> 
[in,out]D
!>          D is REAL array, dimension (N)
!>          On entry, D must contain the diagonal elements of A.
!>
!>          On exit, D is overwritten by the n diagonal elements of the
!>          upper triangular matrix U from the LU factorization of A.
!> 
[in,out]DU
!>          DU is REAL array, dimension (N-1)
!>          On entry, DU must contain the (n-1) super-diagonal elements
!>          of A.
!>
!>          On exit, DU is overwritten by the (n-1) elements of the first
!>          super-diagonal of U.
!> 
[out]DU2
!>          DU2 is REAL array, dimension (N-2)
!>          On exit, DU2 is overwritten by the (n-2) elements of the
!>          second super-diagonal of U.
!> 
[out]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          The pivot indices; for 1 <= i <= n, row i of the matrix was
!>          interchanged with row IPIV(i).  IPIV(i) will always be either
!>          i or i+1; IPIV(i) = i indicates a row interchange was not
!>          required.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -k, the k-th argument had an illegal value
!>          > 0:  if INFO = k, U(k,k) is exactly zero. The factorization
!>                has been completed, but the factor U is exactly
!>                singular, and division by zero will occur if it is used
!>                to solve a system of equations.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 123 of file sgttrf.f.

124*
125* -- LAPACK computational routine --
126* -- LAPACK is a software package provided by Univ. of Tennessee, --
127* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
128*
129* .. Scalar Arguments ..
130 INTEGER INFO, N
131* ..
132* .. Array Arguments ..
133 INTEGER IPIV( * )
134 REAL D( * ), DL( * ), DU( * ), DU2( * )
135* ..
136*
137* =====================================================================
138*
139* .. Parameters ..
140 REAL ZERO
141 parameter( zero = 0.0e+0 )
142* ..
143* .. Local Scalars ..
144 INTEGER I
145 REAL FACT, TEMP
146* ..
147* .. Intrinsic Functions ..
148 INTRINSIC abs
149* ..
150* .. External Subroutines ..
151 EXTERNAL xerbla
152* ..
153* .. Executable Statements ..
154*
155 info = 0
156 IF( n.LT.0 ) THEN
157 info = -1
158 CALL xerbla( 'SGTTRF', -info )
159 RETURN
160 END IF
161*
162* Quick return if possible
163*
164 IF( n.EQ.0 )
165 $ RETURN
166*
167* Initialize IPIV(i) = i and DU2(I) = 0
168*
169 DO 10 i = 1, n
170 ipiv( i ) = i
171 10 CONTINUE
172 DO 20 i = 1, n - 2
173 du2( i ) = zero
174 20 CONTINUE
175*
176 DO 30 i = 1, n - 2
177 IF( abs( d( i ) ).GE.abs( dl( i ) ) ) THEN
178*
179* No row interchange required, eliminate DL(I)
180*
181 IF( d( i ).NE.zero ) THEN
182 fact = dl( i ) / d( i )
183 dl( i ) = fact
184 d( i+1 ) = d( i+1 ) - fact*du( i )
185 END IF
186 ELSE
187*
188* Interchange rows I and I+1, eliminate DL(I)
189*
190 fact = d( i ) / dl( i )
191 d( i ) = dl( i )
192 dl( i ) = fact
193 temp = du( i )
194 du( i ) = d( i+1 )
195 d( i+1 ) = temp - fact*d( i+1 )
196 du2( i ) = du( i+1 )
197 du( i+1 ) = -fact*du( i+1 )
198 ipiv( i ) = i + 1
199 END IF
200 30 CONTINUE
201 IF( n.GT.1 ) THEN
202 i = n - 1
203 IF( abs( d( i ) ).GE.abs( dl( i ) ) ) THEN
204 IF( d( i ).NE.zero ) THEN
205 fact = dl( i ) / d( i )
206 dl( i ) = fact
207 d( i+1 ) = d( i+1 ) - fact*du( i )
208 END IF
209 ELSE
210 fact = d( i ) / dl( i )
211 d( i ) = dl( i )
212 dl( i ) = fact
213 temp = du( i )
214 du( i ) = d( i+1 )
215 d( i+1 ) = temp - fact*d( i+1 )
216 ipiv( i ) = i + 1
217 END IF
218 END IF
219*
220* Check for a zero on the diagonal of U.
221*
222 DO 40 i = 1, n
223 IF( d( i ).EQ.zero ) THEN
224 info = i
225 GO TO 50
226 END IF
227 40 CONTINUE
228 50 CONTINUE
229*
230 RETURN
231*
232* End of SGTTRF
233*

◆ sgttrs()

subroutine sgttrs ( character trans,
integer n,
integer nrhs,
real, dimension( * ) dl,
real, dimension( * ) d,
real, dimension( * ) du,
real, dimension( * ) du2,
integer, dimension( * ) ipiv,
real, dimension( ldb, * ) b,
integer ldb,
integer info )

SGTTRS

Download SGTTRS + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGTTRS solves one of the systems of equations
!>    A*X = B  or  A**T*X = B,
!> with a tridiagonal matrix A using the LU factorization computed
!> by SGTTRF.
!> 
Parameters
[in]TRANS
!>          TRANS is CHARACTER*1
!>          Specifies the form of the system of equations.
!>          = 'N':  A * X = B  (No transpose)
!>          = 'T':  A**T* X = B  (Transpose)
!>          = 'C':  A**T* X = B  (Conjugate transpose = Transpose)
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.
!> 
[in]NRHS
!>          NRHS is INTEGER
!>          The number of right hand sides, i.e., the number of columns
!>          of the matrix B.  NRHS >= 0.
!> 
[in]DL
!>          DL is REAL array, dimension (N-1)
!>          The (n-1) multipliers that define the matrix L from the
!>          LU factorization of A.
!> 
[in]D
!>          D is REAL array, dimension (N)
!>          The n diagonal elements of the upper triangular matrix U from
!>          the LU factorization of A.
!> 
[in]DU
!>          DU is REAL array, dimension (N-1)
!>          The (n-1) elements of the first super-diagonal of U.
!> 
[in]DU2
!>          DU2 is REAL array, dimension (N-2)
!>          The (n-2) elements of the second super-diagonal of U.
!> 
[in]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          The pivot indices; for 1 <= i <= n, row i of the matrix was
!>          interchanged with row IPIV(i).  IPIV(i) will always be either
!>          i or i+1; IPIV(i) = i indicates a row interchange was not
!>          required.
!> 
[in,out]B
!>          B is REAL array, dimension (LDB,NRHS)
!>          On entry, the matrix of right hand side vectors B.
!>          On exit, B is overwritten by the solution vectors X.
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B.  LDB >= max(1,N).
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 136 of file sgttrs.f.

138*
139* -- LAPACK computational routine --
140* -- LAPACK is a software package provided by Univ. of Tennessee, --
141* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
142*
143* .. Scalar Arguments ..
144 CHARACTER TRANS
145 INTEGER INFO, LDB, N, NRHS
146* ..
147* .. Array Arguments ..
148 INTEGER IPIV( * )
149 REAL B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
150* ..
151*
152* =====================================================================
153*
154* .. Local Scalars ..
155 LOGICAL NOTRAN
156 INTEGER ITRANS, J, JB, NB
157* ..
158* .. External Functions ..
159 INTEGER ILAENV
160 EXTERNAL ilaenv
161* ..
162* .. External Subroutines ..
163 EXTERNAL sgtts2, xerbla
164* ..
165* .. Intrinsic Functions ..
166 INTRINSIC max, min
167* ..
168* .. Executable Statements ..
169*
170 info = 0
171 notran = ( trans.EQ.'N' .OR. trans.EQ.'n' )
172 IF( .NOT.notran .AND. .NOT.( trans.EQ.'T' .OR. trans.EQ.
173 $ 't' ) .AND. .NOT.( trans.EQ.'C' .OR. trans.EQ.'c' ) ) THEN
174 info = -1
175 ELSE IF( n.LT.0 ) THEN
176 info = -2
177 ELSE IF( nrhs.LT.0 ) THEN
178 info = -3
179 ELSE IF( ldb.LT.max( n, 1 ) ) THEN
180 info = -10
181 END IF
182 IF( info.NE.0 ) THEN
183 CALL xerbla( 'SGTTRS', -info )
184 RETURN
185 END IF
186*
187* Quick return if possible
188*
189 IF( n.EQ.0 .OR. nrhs.EQ.0 )
190 $ RETURN
191*
192* Decode TRANS
193*
194 IF( notran ) THEN
195 itrans = 0
196 ELSE
197 itrans = 1
198 END IF
199*
200* Determine the number of right-hand sides to solve at a time.
201*
202 IF( nrhs.EQ.1 ) THEN
203 nb = 1
204 ELSE
205 nb = max( 1, ilaenv( 1, 'SGTTRS', trans, n, nrhs, -1, -1 ) )
206 END IF
207*
208 IF( nb.GE.nrhs ) THEN
209 CALL sgtts2( itrans, n, nrhs, dl, d, du, du2, ipiv, b, ldb )
210 ELSE
211 DO 10 j = 1, nrhs, nb
212 jb = min( nrhs-j+1, nb )
213 CALL sgtts2( itrans, n, jb, dl, d, du, du2, ipiv, b( 1, j ),
214 $ ldb )
215 10 CONTINUE
216 END IF
217*
218* End of SGTTRS
219*
integer function ilaenv(ispec, name, opts, n1, n2, n3, n4)
ILAENV
Definition ilaenv.f:162
subroutine sgtts2(itrans, n, nrhs, dl, d, du, du2, ipiv, b, ldb)
SGTTS2 solves a system of linear equations with a tridiagonal matrix using the LU factorization compu...
Definition sgtts2.f:128
#define min(a, b)
Definition macros.h:20

◆ sgtts2()

subroutine sgtts2 ( integer itrans,
integer n,
integer nrhs,
real, dimension( * ) dl,
real, dimension( * ) d,
real, dimension( * ) du,
real, dimension( * ) du2,
integer, dimension( * ) ipiv,
real, dimension( ldb, * ) b,
integer ldb )

SGTTS2 solves a system of linear equations with a tridiagonal matrix using the LU factorization computed by sgttrf.

Download SGTTS2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> SGTTS2 solves one of the systems of equations
!>    A*X = B  or  A**T*X = B,
!> with a tridiagonal matrix A using the LU factorization computed
!> by SGTTRF.
!> 
Parameters
[in]ITRANS
!>          ITRANS is INTEGER
!>          Specifies the form of the system of equations.
!>          = 0:  A * X = B  (No transpose)
!>          = 1:  A**T* X = B  (Transpose)
!>          = 2:  A**T* X = B  (Conjugate transpose = Transpose)
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.
!> 
[in]NRHS
!>          NRHS is INTEGER
!>          The number of right hand sides, i.e., the number of columns
!>          of the matrix B.  NRHS >= 0.
!> 
[in]DL
!>          DL is REAL array, dimension (N-1)
!>          The (n-1) multipliers that define the matrix L from the
!>          LU factorization of A.
!> 
[in]D
!>          D is REAL array, dimension (N)
!>          The n diagonal elements of the upper triangular matrix U from
!>          the LU factorization of A.
!> 
[in]DU
!>          DU is REAL array, dimension (N-1)
!>          The (n-1) elements of the first super-diagonal of U.
!> 
[in]DU2
!>          DU2 is REAL array, dimension (N-2)
!>          The (n-2) elements of the second super-diagonal of U.
!> 
[in]IPIV
!>          IPIV is INTEGER array, dimension (N)
!>          The pivot indices; for 1 <= i <= n, row i of the matrix was
!>          interchanged with row IPIV(i).  IPIV(i) will always be either
!>          i or i+1; IPIV(i) = i indicates a row interchange was not
!>          required.
!> 
[in,out]B
!>          B is REAL array, dimension (LDB,NRHS)
!>          On entry, the matrix of right hand side vectors B.
!>          On exit, B is overwritten by the solution vectors X.
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B.  LDB >= max(1,N).
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 127 of file sgtts2.f.

128*
129* -- LAPACK computational routine --
130* -- LAPACK is a software package provided by Univ. of Tennessee, --
131* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
132*
133* .. Scalar Arguments ..
134 INTEGER ITRANS, LDB, N, NRHS
135* ..
136* .. Array Arguments ..
137 INTEGER IPIV( * )
138 REAL B( LDB, * ), D( * ), DL( * ), DU( * ), DU2( * )
139* ..
140*
141* =====================================================================
142*
143* .. Local Scalars ..
144 INTEGER I, IP, J
145 REAL TEMP
146* ..
147* .. Executable Statements ..
148*
149* Quick return if possible
150*
151 IF( n.EQ.0 .OR. nrhs.EQ.0 )
152 $ RETURN
153*
154 IF( itrans.EQ.0 ) THEN
155*
156* Solve A*X = B using the LU factorization of A,
157* overwriting each right hand side vector with its solution.
158*
159 IF( nrhs.LE.1 ) THEN
160 j = 1
161 10 CONTINUE
162*
163* Solve L*x = b.
164*
165 DO 20 i = 1, n - 1
166 ip = ipiv( i )
167 temp = b( i+1-ip+i, j ) - dl( i )*b( ip, j )
168 b( i, j ) = b( ip, j )
169 b( i+1, j ) = temp
170 20 CONTINUE
171*
172* Solve U*x = b.
173*
174 b( n, j ) = b( n, j ) / d( n )
175 IF( n.GT.1 )
176 $ b( n-1, j ) = ( b( n-1, j )-du( n-1 )*b( n, j ) ) /
177 $ d( n-1 )
178 DO 30 i = n - 2, 1, -1
179 b( i, j ) = ( b( i, j )-du( i )*b( i+1, j )-du2( i )*
180 $ b( i+2, j ) ) / d( i )
181 30 CONTINUE
182 IF( j.LT.nrhs ) THEN
183 j = j + 1
184 GO TO 10
185 END IF
186 ELSE
187 DO 60 j = 1, nrhs
188*
189* Solve L*x = b.
190*
191 DO 40 i = 1, n - 1
192 IF( ipiv( i ).EQ.i ) THEN
193 b( i+1, j ) = b( i+1, j ) - dl( i )*b( i, j )
194 ELSE
195 temp = b( i, j )
196 b( i, j ) = b( i+1, j )
197 b( i+1, j ) = temp - dl( i )*b( i, j )
198 END IF
199 40 CONTINUE
200*
201* Solve U*x = b.
202*
203 b( n, j ) = b( n, j ) / d( n )
204 IF( n.GT.1 )
205 $ b( n-1, j ) = ( b( n-1, j )-du( n-1 )*b( n, j ) ) /
206 $ d( n-1 )
207 DO 50 i = n - 2, 1, -1
208 b( i, j ) = ( b( i, j )-du( i )*b( i+1, j )-du2( i )*
209 $ b( i+2, j ) ) / d( i )
210 50 CONTINUE
211 60 CONTINUE
212 END IF
213 ELSE
214*
215* Solve A**T * X = B.
216*
217 IF( nrhs.LE.1 ) THEN
218*
219* Solve U**T*x = b.
220*
221 j = 1
222 70 CONTINUE
223 b( 1, j ) = b( 1, j ) / d( 1 )
224 IF( n.GT.1 )
225 $ b( 2, j ) = ( b( 2, j )-du( 1 )*b( 1, j ) ) / d( 2 )
226 DO 80 i = 3, n
227 b( i, j ) = ( b( i, j )-du( i-1 )*b( i-1, j )-du2( i-2 )*
228 $ b( i-2, j ) ) / d( i )
229 80 CONTINUE
230*
231* Solve L**T*x = b.
232*
233 DO 90 i = n - 1, 1, -1
234 ip = ipiv( i )
235 temp = b( i, j ) - dl( i )*b( i+1, j )
236 b( i, j ) = b( ip, j )
237 b( ip, j ) = temp
238 90 CONTINUE
239 IF( j.LT.nrhs ) THEN
240 j = j + 1
241 GO TO 70
242 END IF
243*
244 ELSE
245 DO 120 j = 1, nrhs
246*
247* Solve U**T*x = b.
248*
249 b( 1, j ) = b( 1, j ) / d( 1 )
250 IF( n.GT.1 )
251 $ b( 2, j ) = ( b( 2, j )-du( 1 )*b( 1, j ) ) / d( 2 )
252 DO 100 i = 3, n
253 b( i, j ) = ( b( i, j )-du( i-1 )*b( i-1, j )-
254 $ du2( i-2 )*b( i-2, j ) ) / d( i )
255 100 CONTINUE
256 DO 110 i = n - 1, 1, -1
257 IF( ipiv( i ).EQ.i ) THEN
258 b( i, j ) = b( i, j ) - dl( i )*b( i+1, j )
259 ELSE
260 temp = b( i+1, j )
261 b( i+1, j ) = b( i, j ) - dl( i )*temp
262 b( i, j ) = temp
263 END IF
264 110 CONTINUE
265 120 CONTINUE
266 END IF
267 END IF
268*
269* End of SGTTS2
270*