LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ dsposv()

subroutine dsposv ( character  UPLO,
integer  N,
integer  NRHS,
double precision, dimension( lda, * )  A,
integer  LDA,
double precision, dimension( ldb, * )  B,
integer  LDB,
double precision, dimension( ldx, * )  X,
integer  LDX,
double precision, dimension( n, * )  WORK,
real, dimension( * )  SWORK,
integer  ITER,
integer  INFO 
)

DSPOSV computes the solution to system of linear equations A * X = B for PO matrices

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

Purpose:
 DSPOSV computes the solution to a real system of linear equations
    A * X = B,
 where A is an N-by-N symmetric positive definite matrix and X and B
 are N-by-NRHS matrices.

 DSPOSV first attempts to factorize the matrix in SINGLE PRECISION
 and use this factorization within an iterative refinement procedure
 to produce a solution with DOUBLE PRECISION normwise backward error
 quality (see below). If the approach fails the method switches to a
 DOUBLE PRECISION factorization and solve.

 The iterative refinement is not going to be a winning strategy if
 the ratio SINGLE PRECISION performance over DOUBLE PRECISION
 performance is too small. A reasonable strategy should take the
 number of right-hand sides and the size of the matrix into account.
 This might be done with a call to ILAENV in the future. Up to now, we
 always try iterative refinement.

 The iterative refinement process is stopped if
     ITER > ITERMAX
 or for all the RHS we have:
     RNRM < SQRT(N)*XNRM*ANRM*EPS*BWDMAX
 where
     o ITER is the number of the current iteration in the iterative
       refinement process
     o RNRM is the infinity-norm of the residual
     o XNRM is the infinity-norm of the solution
     o ANRM is the infinity-operator-norm of the matrix A
     o EPS is the machine epsilon returned by DLAMCH('Epsilon')
 The value ITERMAX and BWDMAX are fixed to 30 and 1.0D+00
 respectively.
Parameters
[in]UPLO
          UPLO is CHARACTER*1
          = 'U':  Upper triangle of A is stored;
          = 'L':  Lower triangle of A is stored.
[in]N
          N is INTEGER
          The number of linear equations, i.e., 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,out]A
          A is DOUBLE PRECISION array,
          dimension (LDA,N)
          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
          N-by-N upper triangular part of A contains the upper
          triangular part of the matrix A, and the strictly lower
          triangular part of A is not referenced.  If UPLO = 'L', the
          leading N-by-N lower triangular part of A contains the lower
          triangular part of the matrix A, and the strictly upper
          triangular part of A is not referenced.
          On exit, if iterative refinement has been successfully used
          (INFO.EQ.0 and ITER.GE.0, see description below), then A is
          unchanged, if double precision factorization has been used
          (INFO.EQ.0 and ITER.LT.0, see description below), then the
          array A contains the factor U or L from the Cholesky
          factorization A = U**T*U or A = L*L**T.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[in]B
          B is DOUBLE PRECISION array, dimension (LDB,NRHS)
          The N-by-NRHS right hand side matrix B.
[in]LDB
          LDB is INTEGER
          The leading dimension of the array B.  LDB >= max(1,N).
[out]X
          X is DOUBLE PRECISION array, dimension (LDX,NRHS)
          If INFO = 0, the N-by-NRHS solution matrix X.
[in]LDX
          LDX is INTEGER
          The leading dimension of the array X.  LDX >= max(1,N).
[out]WORK
          WORK is DOUBLE PRECISION array, dimension (N,NRHS)
          This array is used to hold the residual vectors.
[out]SWORK
          SWORK is REAL array, dimension (N*(N+NRHS))
          This array is used to use the single precision matrix and the
          right-hand sides or solutions in single precision.
[out]ITER
          ITER is INTEGER
          < 0: iterative refinement has failed, double precision
               factorization has been performed
               -1 : the routine fell back to full precision for
                    implementation- or machine-specific reasons
               -2 : narrowing the precision induced an overflow,
                    the routine fell back to full precision
               -3 : failure of SPOTRF
               -31: stop the iterative refinement after the 30th
                    iterations
          > 0: iterative refinement has been successfully used.
               Returns the number of iterations
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
          > 0:  if INFO = i, the leading minor of order i of (DOUBLE
                PRECISION) A is not positive definite, so the
                factorization could not be completed, and the solution
                has not been computed.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
June 2016

Definition at line 201 of file dsposv.f.

201 *
202 * -- LAPACK driver routine (version 3.8.0) --
203 * -- LAPACK is a software package provided by Univ. of Tennessee, --
204 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
205 * June 2016
206 *
207 * .. Scalar Arguments ..
208  CHARACTER uplo
209  INTEGER info, iter, lda, ldb, ldx, n, nrhs
210 * ..
211 * .. Array Arguments ..
212  REAL swork( * )
213  DOUBLE PRECISION a( lda, * ), b( ldb, * ), work( n, * ),
214  $ x( ldx, * )
215 * ..
216 *
217 * =====================================================================
218 *
219 * .. Parameters ..
220  LOGICAL doitref
221  parameter( doitref = .true. )
222 *
223  INTEGER itermax
224  parameter( itermax = 30 )
225 *
226  DOUBLE PRECISION bwdmax
227  parameter( bwdmax = 1.0e+00 )
228 *
229  DOUBLE PRECISION negone, one
230  parameter( negone = -1.0d+0, one = 1.0d+0 )
231 *
232 * .. Local Scalars ..
233  INTEGER i, iiter, ptsa, ptsx
234  DOUBLE PRECISION anrm, cte, eps, rnrm, xnrm
235 *
236 * .. External Subroutines ..
237  EXTERNAL daxpy, dsymm, dlacpy, dlat2s, dlag2s, slag2d,
239 * ..
240 * .. External Functions ..
241  INTEGER idamax
242  DOUBLE PRECISION dlamch, dlansy
243  LOGICAL lsame
244  EXTERNAL idamax, dlamch, dlansy, lsame
245 * ..
246 * .. Intrinsic Functions ..
247  INTRINSIC abs, dble, max, sqrt
248 * ..
249 * .. Executable Statements ..
250 *
251  info = 0
252  iter = 0
253 *
254 * Test the input parameters.
255 *
256  IF( .NOT.lsame( uplo, 'U' ) .AND. .NOT.lsame( uplo, 'L' ) ) THEN
257  info = -1
258  ELSE IF( n.LT.0 ) THEN
259  info = -2
260  ELSE IF( nrhs.LT.0 ) THEN
261  info = -3
262  ELSE IF( lda.LT.max( 1, n ) ) THEN
263  info = -5
264  ELSE IF( ldb.LT.max( 1, n ) ) THEN
265  info = -7
266  ELSE IF( ldx.LT.max( 1, n ) ) THEN
267  info = -9
268  END IF
269  IF( info.NE.0 ) THEN
270  CALL xerbla( 'DSPOSV', -info )
271  RETURN
272  END IF
273 *
274 * Quick return if (N.EQ.0).
275 *
276  IF( n.EQ.0 )
277  $ RETURN
278 *
279 * Skip single precision iterative refinement if a priori slower
280 * than double precision factorization.
281 *
282  IF( .NOT.doitref ) THEN
283  iter = -1
284  GO TO 40
285  END IF
286 *
287 * Compute some constants.
288 *
289  anrm = dlansy( 'I', uplo, n, a, lda, work )
290  eps = dlamch( 'Epsilon' )
291  cte = anrm*eps*sqrt( dble( n ) )*bwdmax
292 *
293 * Set the indices PTSA, PTSX for referencing SA and SX in SWORK.
294 *
295  ptsa = 1
296  ptsx = ptsa + n*n
297 *
298 * Convert B from double precision to single precision and store the
299 * result in SX.
300 *
301  CALL dlag2s( n, nrhs, b, ldb, swork( ptsx ), n, info )
302 *
303  IF( info.NE.0 ) THEN
304  iter = -2
305  GO TO 40
306  END IF
307 *
308 * Convert A from double precision to single precision and store the
309 * result in SA.
310 *
311  CALL dlat2s( uplo, n, a, lda, swork( ptsa ), n, info )
312 *
313  IF( info.NE.0 ) THEN
314  iter = -2
315  GO TO 40
316  END IF
317 *
318 * Compute the Cholesky factorization of SA.
319 *
320  CALL spotrf( uplo, n, swork( ptsa ), n, info )
321 *
322  IF( info.NE.0 ) THEN
323  iter = -3
324  GO TO 40
325  END IF
326 *
327 * Solve the system SA*SX = SB.
328 *
329  CALL spotrs( uplo, n, nrhs, swork( ptsa ), n, swork( ptsx ), n,
330  $ info )
331 *
332 * Convert SX back to double precision
333 *
334  CALL slag2d( n, nrhs, swork( ptsx ), n, x, ldx, info )
335 *
336 * Compute R = B - AX (R is WORK).
337 *
338  CALL dlacpy( 'All', n, nrhs, b, ldb, work, n )
339 *
340  CALL dsymm( 'Left', uplo, n, nrhs, negone, a, lda, x, ldx, one,
341  $ work, n )
342 *
343 * Check whether the NRHS normwise backward errors satisfy the
344 * stopping criterion. If yes, set ITER=0 and return.
345 *
346  DO i = 1, nrhs
347  xnrm = abs( x( idamax( n, x( 1, i ), 1 ), i ) )
348  rnrm = abs( work( idamax( n, work( 1, i ), 1 ), i ) )
349  IF( rnrm.GT.xnrm*cte )
350  $ GO TO 10
351  END DO
352 *
353 * If we are here, the NRHS normwise backward errors satisfy the
354 * stopping criterion. We are good to exit.
355 *
356  iter = 0
357  RETURN
358 *
359  10 CONTINUE
360 *
361  DO 30 iiter = 1, itermax
362 *
363 * Convert R (in WORK) from double precision to single precision
364 * and store the result in SX.
365 *
366  CALL dlag2s( n, nrhs, work, n, swork( ptsx ), n, info )
367 *
368  IF( info.NE.0 ) THEN
369  iter = -2
370  GO TO 40
371  END IF
372 *
373 * Solve the system SA*SX = SR.
374 *
375  CALL spotrs( uplo, n, nrhs, swork( ptsa ), n, swork( ptsx ), n,
376  $ info )
377 *
378 * Convert SX back to double precision and update the current
379 * iterate.
380 *
381  CALL slag2d( n, nrhs, swork( ptsx ), n, work, n, info )
382 *
383  DO i = 1, nrhs
384  CALL daxpy( n, one, work( 1, i ), 1, x( 1, i ), 1 )
385  END DO
386 *
387 * Compute R = B - AX (R is WORK).
388 *
389  CALL dlacpy( 'All', n, nrhs, b, ldb, work, n )
390 *
391  CALL dsymm( 'L', uplo, n, nrhs, negone, a, lda, x, ldx, one,
392  $ work, n )
393 *
394 * Check whether the NRHS normwise backward errors satisfy the
395 * stopping criterion. If yes, set ITER=IITER>0 and return.
396 *
397  DO i = 1, nrhs
398  xnrm = abs( x( idamax( n, x( 1, i ), 1 ), i ) )
399  rnrm = abs( work( idamax( n, work( 1, i ), 1 ), i ) )
400  IF( rnrm.GT.xnrm*cte )
401  $ GO TO 20
402  END DO
403 *
404 * If we are here, the NRHS normwise backward errors satisfy the
405 * stopping criterion, we are good to exit.
406 *
407  iter = iiter
408 *
409  RETURN
410 *
411  20 CONTINUE
412 *
413  30 CONTINUE
414 *
415 * If we are at this place of the code, this is because we have
416 * performed ITER=ITERMAX iterations and never satisified the
417 * stopping criterion, set up the ITER flag accordingly and follow
418 * up on double precision routine.
419 *
420  iter = -itermax - 1
421 *
422  40 CONTINUE
423 *
424 * Single-precision iterative refinement failed to converge to a
425 * satisfactory solution, so we resort to double precision.
426 *
427  CALL dpotrf( uplo, n, a, lda, info )
428 *
429  IF( info.NE.0 )
430  $ RETURN
431 *
432  CALL dlacpy( 'All', n, nrhs, b, ldb, x, ldx )
433  CALL dpotrs( uplo, n, nrhs, a, lda, x, ldx, info )
434 *
435  RETURN
436 *
437 * End of DSPOSV.
438 *
subroutine dlacpy(UPLO, M, N, A, LDA, B, LDB)
DLACPY copies all or part of one two-dimensional array to another.
Definition: dlacpy.f:105
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
double precision function dlansy(NORM, UPLO, N, A, LDA, WORK)
DLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric matrix.
Definition: dlansy.f:124
integer function idamax(N, DX, INCX)
IDAMAX
Definition: idamax.f:73
subroutine dpotrf(UPLO, N, A, LDA, INFO)
DPOTRF
Definition: dpotrf.f:109
subroutine dsymm(SIDE, UPLO, M, N, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
DSYMM
Definition: dsymm.f:191
subroutine daxpy(N, DA, DX, INCX, DY, INCY)
DAXPY
Definition: daxpy.f:91
subroutine dlag2s(M, N, A, LDA, SA, LDSA, INFO)
DLAG2S converts a double precision matrix to a single precision matrix.
Definition: dlag2s.f:110
subroutine slag2d(M, N, SA, LDSA, A, LDA, INFO)
SLAG2D converts a single precision matrix to a double precision matrix.
Definition: slag2d.f:106
subroutine spotrf(UPLO, N, A, LDA, INFO)
SPOTRF
Definition: spotrf.f:109
subroutine dpotrs(UPLO, N, NRHS, A, LDA, B, LDB, INFO)
DPOTRS
Definition: dpotrs.f:112
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine spotrs(UPLO, N, NRHS, A, LDA, B, LDB, INFO)
SPOTRS
Definition: spotrs.f:112
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine dlat2s(UPLO, N, A, LDA, SA, LDSA, INFO)
DLAT2S converts a double-precision triangular matrix to a single-precision triangular matrix...
Definition: dlat2s.f:113
Here is the call graph for this function:
Here is the caller graph for this function: