File:  [local] / rpl / lapack / lapack / zhetrs_rook.f
Revision 1.6: download - view: text, annotated - select for diffs - revision graph
Mon Aug 7 08:39:25 2023 UTC (9 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_35, rpl-4_1_34, HEAD
Première mise à jour de lapack et blas.

    1: *> \brief \b ZHETRS_ROOK computes the solution to a system of linear equations A * X = B for HE matrices using factorization obtained with one of the bounded diagonal pivoting methods (max 2 interchanges)
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at
    6: *            http://www.netlib.org/lapack/explore-html/
    7: *
    8: *> \htmlonly
    9: *> Download ZHETRS_ROOK + dependencies
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zhetrs_rook.f">
   11: *> [TGZ]</a>
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zhetrs_rook.f">
   13: *> [ZIP]</a>
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zhetrs_rook.f">
   15: *> [TXT]</a>
   16: *> \endhtmlonly
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE ZHETRS_ROOK( UPLO, N, NRHS, A, LDA, IPIV, B, LDB, INFO )
   22: *
   23: *       .. Scalar Arguments ..
   24: *       CHARACTER          UPLO
   25: *       INTEGER            INFO, LDA, LDB, N, NRHS
   26: *       ..
   27: *       .. Array Arguments ..
   28: *       INTEGER            IPIV( * )
   29: *       COMPLEX            A( LDA, * ), B( LDB, * )
   30: *       ..
   31: *
   32: *
   33: *> \par Purpose:
   34: *  =============
   35: *>
   36: *> \verbatim
   37: *>
   38: *> ZHETRS_ROOK solves a system of linear equations A*X = B with a complex
   39: *> Hermitian matrix A using the factorization A = U*D*U**H or
   40: *> A = L*D*L**H computed by ZHETRF_ROOK.
   41: *> \endverbatim
   42: *
   43: *  Arguments:
   44: *  ==========
   45: *
   46: *> \param[in] UPLO
   47: *> \verbatim
   48: *>          UPLO is CHARACTER*1
   49: *>          Specifies whether the details of the factorization are stored
   50: *>          as an upper or lower triangular matrix.
   51: *>          = 'U':  Upper triangular, form is A = U*D*U**H;
   52: *>          = 'L':  Lower triangular, form is A = L*D*L**H.
   53: *> \endverbatim
   54: *>
   55: *> \param[in] N
   56: *> \verbatim
   57: *>          N is INTEGER
   58: *>          The order of the matrix A.  N >= 0.
   59: *> \endverbatim
   60: *>
   61: *> \param[in] NRHS
   62: *> \verbatim
   63: *>          NRHS is INTEGER
   64: *>          The number of right hand sides, i.e., the number of columns
   65: *>          of the matrix B.  NRHS >= 0.
   66: *> \endverbatim
   67: *>
   68: *> \param[in] A
   69: *> \verbatim
   70: *>          A is COMPLEX*16 array, dimension (LDA,N)
   71: *>          The block diagonal matrix D and the multipliers used to
   72: *>          obtain the factor U or L as computed by ZHETRF_ROOK.
   73: *> \endverbatim
   74: *>
   75: *> \param[in] LDA
   76: *> \verbatim
   77: *>          LDA is INTEGER
   78: *>          The leading dimension of the array A.  LDA >= max(1,N).
   79: *> \endverbatim
   80: *>
   81: *> \param[in] IPIV
   82: *> \verbatim
   83: *>          IPIV is INTEGER array, dimension (N)
   84: *>          Details of the interchanges and the block structure of D
   85: *>          as determined by ZHETRF_ROOK.
   86: *> \endverbatim
   87: *>
   88: *> \param[in,out] B
   89: *> \verbatim
   90: *>          B is COMPLEX*16 array, dimension (LDB,NRHS)
   91: *>          On entry, the right hand side matrix B.
   92: *>          On exit, the solution matrix X.
   93: *> \endverbatim
   94: *>
   95: *> \param[in] LDB
   96: *> \verbatim
   97: *>          LDB is INTEGER
   98: *>          The leading dimension of the array B.  LDB >= max(1,N).
   99: *> \endverbatim
  100: *>
  101: *> \param[out] INFO
  102: *> \verbatim
  103: *>          INFO is INTEGER
  104: *>          = 0:  successful exit
  105: *>          < 0:  if INFO = -i, the i-th argument had an illegal value
  106: *> \endverbatim
  107: *
  108: *  Authors:
  109: *  ========
  110: *
  111: *> \author Univ. of Tennessee
  112: *> \author Univ. of California Berkeley
  113: *> \author Univ. of Colorado Denver
  114: *> \author NAG Ltd.
  115: *
  116: *> \ingroup complex16HEcomputational
  117: *
  118: *> \par Contributors:
  119: *  ==================
  120: *>
  121: *> \verbatim
  122: *>
  123: *>  November 2013,  Igor Kozachenko,
  124: *>                  Computer Science Division,
  125: *>                  University of California, Berkeley
  126: *>
  127: *>  September 2007, Sven Hammarling, Nicholas J. Higham, Craig Lucas,
  128: *>                  School of Mathematics,
  129: *>                  University of Manchester
  130: *>
  131: *> \endverbatim
  132: *
  133: *  =====================================================================
  134:       SUBROUTINE ZHETRS_ROOK( UPLO, N, NRHS, A, LDA, IPIV, B, LDB,
  135:      $                        INFO )
  136: *
  137: *  -- LAPACK computational routine --
  138: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  139: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  140: *
  141: *     .. Scalar Arguments ..
  142:       CHARACTER          UPLO
  143:       INTEGER            INFO, LDA, LDB, N, NRHS
  144: *     ..
  145: *     .. Array Arguments ..
  146:       INTEGER            IPIV( * )
  147:       COMPLEX*16         A( LDA, * ), B( LDB, * )
  148: *     ..
  149: *
  150: *  =====================================================================
  151: *
  152: *     .. Parameters ..
  153:       COMPLEX*16         ONE
  154:       PARAMETER          ( ONE = ( 1.0D+0, 0.0D+0 ) )
  155: *     ..
  156: *     .. Local Scalars ..
  157:       LOGICAL            UPPER
  158:       INTEGER            J, K, KP
  159:       DOUBLE PRECISION   S
  160:       COMPLEX*16         AK, AKM1, AKM1K, BK, BKM1, DENOM
  161: *     ..
  162: *     .. External Functions ..
  163:       LOGICAL            LSAME
  164:       EXTERNAL           LSAME
  165: *     ..
  166: *     .. External Subroutines ..
  167:       EXTERNAL           ZGEMV, ZGERU, ZLACGV, ZDSCAL, ZSWAP, XERBLA
  168: *     ..
  169: *     .. Intrinsic Functions ..
  170:       INTRINSIC          DCONJG, MAX, DBLE
  171: *     ..
  172: *     .. Executable Statements ..
  173: *
  174:       INFO = 0
  175:       UPPER = LSAME( UPLO, 'U' )
  176:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  177:          INFO = -1
  178:       ELSE IF( N.LT.0 ) THEN
  179:          INFO = -2
  180:       ELSE IF( NRHS.LT.0 ) THEN
  181:          INFO = -3
  182:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  183:          INFO = -5
  184:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
  185:          INFO = -8
  186:       END IF
  187:       IF( INFO.NE.0 ) THEN
  188:          CALL XERBLA( 'ZHETRS_ROOK', -INFO )
  189:          RETURN
  190:       END IF
  191: *
  192: *     Quick return if possible
  193: *
  194:       IF( N.EQ.0 .OR. NRHS.EQ.0 )
  195:      $   RETURN
  196: *
  197:       IF( UPPER ) THEN
  198: *
  199: *        Solve A*X = B, where A = U*D*U**H.
  200: *
  201: *        First solve U*D*X = B, overwriting B with X.
  202: *
  203: *        K is the main loop index, decreasing from N to 1 in steps of
  204: *        1 or 2, depending on the size of the diagonal blocks.
  205: *
  206:          K = N
  207:    10    CONTINUE
  208: *
  209: *        If K < 1, exit from loop.
  210: *
  211:          IF( K.LT.1 )
  212:      $      GO TO 30
  213: *
  214:          IF( IPIV( K ).GT.0 ) THEN
  215: *
  216: *           1 x 1 diagonal block
  217: *
  218: *           Interchange rows K and IPIV(K).
  219: *
  220:             KP = IPIV( K )
  221:             IF( KP.NE.K )
  222:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  223: *
  224: *           Multiply by inv(U(K)), where U(K) is the transformation
  225: *           stored in column K of A.
  226: *
  227:             CALL ZGERU( K-1, NRHS, -ONE, A( 1, K ), 1, B( K, 1 ), LDB,
  228:      $                  B( 1, 1 ), LDB )
  229: *
  230: *           Multiply by the inverse of the diagonal block.
  231: *
  232:             S = DBLE( ONE ) / DBLE( A( K, K ) )
  233:             CALL ZDSCAL( NRHS, S, B( K, 1 ), LDB )
  234:             K = K - 1
  235:          ELSE
  236: *
  237: *           2 x 2 diagonal block
  238: *
  239: *           Interchange rows K and -IPIV(K), then K-1 and -IPIV(K-1)
  240: *
  241:             KP = -IPIV( K )
  242:             IF( KP.NE.K )
  243:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  244: *
  245:             KP = -IPIV( K-1)
  246:             IF( KP.NE.K-1 )
  247:      $         CALL ZSWAP( NRHS, B( K-1, 1 ), LDB, B( KP, 1 ), LDB )
  248: *
  249: *           Multiply by inv(U(K)), where U(K) is the transformation
  250: *           stored in columns K-1 and K of A.
  251: *
  252:             CALL ZGERU( K-2, NRHS, -ONE, A( 1, K ), 1, B( K, 1 ), LDB,
  253:      $                  B( 1, 1 ), LDB )
  254:             CALL ZGERU( K-2, NRHS, -ONE, A( 1, K-1 ), 1, B( K-1, 1 ),
  255:      $                  LDB, B( 1, 1 ), LDB )
  256: *
  257: *           Multiply by the inverse of the diagonal block.
  258: *
  259:             AKM1K = A( K-1, K )
  260:             AKM1 = A( K-1, K-1 ) / AKM1K
  261:             AK = A( K, K ) / DCONJG( AKM1K )
  262:             DENOM = AKM1*AK - ONE
  263:             DO 20 J = 1, NRHS
  264:                BKM1 = B( K-1, J ) / AKM1K
  265:                BK = B( K, J ) / DCONJG( AKM1K )
  266:                B( K-1, J ) = ( AK*BKM1-BK ) / DENOM
  267:                B( K, J ) = ( AKM1*BK-BKM1 ) / DENOM
  268:    20       CONTINUE
  269:             K = K - 2
  270:          END IF
  271: *
  272:          GO TO 10
  273:    30    CONTINUE
  274: *
  275: *        Next solve U**H *X = B, overwriting B with X.
  276: *
  277: *        K is the main loop index, increasing from 1 to N in steps of
  278: *        1 or 2, depending on the size of the diagonal blocks.
  279: *
  280:          K = 1
  281:    40    CONTINUE
  282: *
  283: *        If K > N, exit from loop.
  284: *
  285:          IF( K.GT.N )
  286:      $      GO TO 50
  287: *
  288:          IF( IPIV( K ).GT.0 ) THEN
  289: *
  290: *           1 x 1 diagonal block
  291: *
  292: *           Multiply by inv(U**H(K)), where U(K) is the transformation
  293: *           stored in column K of A.
  294: *
  295:             IF( K.GT.1 ) THEN
  296:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  297:                CALL ZGEMV( 'Conjugate transpose', K-1, NRHS, -ONE, B,
  298:      $                     LDB, A( 1, K ), 1, ONE, B( K, 1 ), LDB )
  299:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  300:             END IF
  301: *
  302: *           Interchange rows K and IPIV(K).
  303: *
  304:             KP = IPIV( K )
  305:             IF( KP.NE.K )
  306:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  307:             K = K + 1
  308:          ELSE
  309: *
  310: *           2 x 2 diagonal block
  311: *
  312: *           Multiply by inv(U**H(K+1)), where U(K+1) is the transformation
  313: *           stored in columns K and K+1 of A.
  314: *
  315:             IF( K.GT.1 ) THEN
  316:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  317:                CALL ZGEMV( 'Conjugate transpose', K-1, NRHS, -ONE, B,
  318:      $                     LDB, A( 1, K ), 1, ONE, B( K, 1 ), LDB )
  319:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  320: *
  321:                CALL ZLACGV( NRHS, B( K+1, 1 ), LDB )
  322:                CALL ZGEMV( 'Conjugate transpose', K-1, NRHS, -ONE, B,
  323:      $                     LDB, A( 1, K+1 ), 1, ONE, B( K+1, 1 ), LDB )
  324:                CALL ZLACGV( NRHS, B( K+1, 1 ), LDB )
  325:             END IF
  326: *
  327: *           Interchange rows K and -IPIV(K), then K+1 and -IPIV(K+1)
  328: *
  329:             KP = -IPIV( K )
  330:             IF( KP.NE.K )
  331:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  332: *
  333:             KP = -IPIV( K+1 )
  334:             IF( KP.NE.K+1 )
  335:      $         CALL ZSWAP( NRHS, B( K+1, 1 ), LDB, B( KP, 1 ), LDB )
  336: *
  337:             K = K + 2
  338:          END IF
  339: *
  340:          GO TO 40
  341:    50    CONTINUE
  342: *
  343:       ELSE
  344: *
  345: *        Solve A*X = B, where A = L*D*L**H.
  346: *
  347: *        First solve L*D*X = B, overwriting B with X.
  348: *
  349: *        K is the main loop index, increasing from 1 to N in steps of
  350: *        1 or 2, depending on the size of the diagonal blocks.
  351: *
  352:          K = 1
  353:    60    CONTINUE
  354: *
  355: *        If K > N, exit from loop.
  356: *
  357:          IF( K.GT.N )
  358:      $      GO TO 80
  359: *
  360:          IF( IPIV( K ).GT.0 ) THEN
  361: *
  362: *           1 x 1 diagonal block
  363: *
  364: *           Interchange rows K and IPIV(K).
  365: *
  366:             KP = IPIV( K )
  367:             IF( KP.NE.K )
  368:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  369: *
  370: *           Multiply by inv(L(K)), where L(K) is the transformation
  371: *           stored in column K of A.
  372: *
  373:             IF( K.LT.N )
  374:      $         CALL ZGERU( N-K, NRHS, -ONE, A( K+1, K ), 1, B( K, 1 ),
  375:      $                     LDB, B( K+1, 1 ), LDB )
  376: *
  377: *           Multiply by the inverse of the diagonal block.
  378: *
  379:             S = DBLE( ONE ) / DBLE( A( K, K ) )
  380:             CALL ZDSCAL( NRHS, S, B( K, 1 ), LDB )
  381:             K = K + 1
  382:          ELSE
  383: *
  384: *           2 x 2 diagonal block
  385: *
  386: *           Interchange rows K and -IPIV(K), then K+1 and -IPIV(K+1)
  387: *
  388:             KP = -IPIV( K )
  389:             IF( KP.NE.K )
  390:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  391: *
  392:             KP = -IPIV( K+1 )
  393:             IF( KP.NE.K+1 )
  394:      $         CALL ZSWAP( NRHS, B( K+1, 1 ), LDB, B( KP, 1 ), LDB )
  395: *
  396: *           Multiply by inv(L(K)), where L(K) is the transformation
  397: *           stored in columns K and K+1 of A.
  398: *
  399:             IF( K.LT.N-1 ) THEN
  400:                CALL ZGERU( N-K-1, NRHS, -ONE, A( K+2, K ), 1, B( K, 1 ),
  401:      $                     LDB, B( K+2, 1 ), LDB )
  402:                CALL ZGERU( N-K-1, NRHS, -ONE, A( K+2, K+1 ), 1,
  403:      $                     B( K+1, 1 ), LDB, B( K+2, 1 ), LDB )
  404:             END IF
  405: *
  406: *           Multiply by the inverse of the diagonal block.
  407: *
  408:             AKM1K = A( K+1, K )
  409:             AKM1 = A( K, K ) / DCONJG( AKM1K )
  410:             AK = A( K+1, K+1 ) / AKM1K
  411:             DENOM = AKM1*AK - ONE
  412:             DO 70 J = 1, NRHS
  413:                BKM1 = B( K, J ) / DCONJG( AKM1K )
  414:                BK = B( K+1, J ) / AKM1K
  415:                B( K, J ) = ( AK*BKM1-BK ) / DENOM
  416:                B( K+1, J ) = ( AKM1*BK-BKM1 ) / DENOM
  417:    70       CONTINUE
  418:             K = K + 2
  419:          END IF
  420: *
  421:          GO TO 60
  422:    80    CONTINUE
  423: *
  424: *        Next solve L**H *X = B, overwriting B with X.
  425: *
  426: *        K is the main loop index, decreasing from N to 1 in steps of
  427: *        1 or 2, depending on the size of the diagonal blocks.
  428: *
  429:          K = N
  430:    90    CONTINUE
  431: *
  432: *        If K < 1, exit from loop.
  433: *
  434:          IF( K.LT.1 )
  435:      $      GO TO 100
  436: *
  437:          IF( IPIV( K ).GT.0 ) THEN
  438: *
  439: *           1 x 1 diagonal block
  440: *
  441: *           Multiply by inv(L**H(K)), where L(K) is the transformation
  442: *           stored in column K of A.
  443: *
  444:             IF( K.LT.N ) THEN
  445:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  446:                CALL ZGEMV( 'Conjugate transpose', N-K, NRHS, -ONE,
  447:      $                     B( K+1, 1 ), LDB, A( K+1, K ), 1, ONE,
  448:      $                     B( K, 1 ), LDB )
  449:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  450:             END IF
  451: *
  452: *           Interchange rows K and IPIV(K).
  453: *
  454:             KP = IPIV( K )
  455:             IF( KP.NE.K )
  456:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  457:             K = K - 1
  458:          ELSE
  459: *
  460: *           2 x 2 diagonal block
  461: *
  462: *           Multiply by inv(L**H(K-1)), where L(K-1) is the transformation
  463: *           stored in columns K-1 and K of A.
  464: *
  465:             IF( K.LT.N ) THEN
  466:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  467:                CALL ZGEMV( 'Conjugate transpose', N-K, NRHS, -ONE,
  468:      $                     B( K+1, 1 ), LDB, A( K+1, K ), 1, ONE,
  469:      $                     B( K, 1 ), LDB )
  470:                CALL ZLACGV( NRHS, B( K, 1 ), LDB )
  471: *
  472:                CALL ZLACGV( NRHS, B( K-1, 1 ), LDB )
  473:                CALL ZGEMV( 'Conjugate transpose', N-K, NRHS, -ONE,
  474:      $                     B( K+1, 1 ), LDB, A( K+1, K-1 ), 1, ONE,
  475:      $                     B( K-1, 1 ), LDB )
  476:                CALL ZLACGV( NRHS, B( K-1, 1 ), LDB )
  477:             END IF
  478: *
  479: *           Interchange rows K and -IPIV(K), then K-1 and -IPIV(K-1)
  480: *
  481:             KP = -IPIV( K )
  482:             IF( KP.NE.K )
  483:      $         CALL ZSWAP( NRHS, B( K, 1 ), LDB, B( KP, 1 ), LDB )
  484: *
  485:             KP = -IPIV( K-1 )
  486:             IF( KP.NE.K-1 )
  487:      $         CALL ZSWAP( NRHS, B( K-1, 1 ), LDB, B( KP, 1 ), LDB )
  488: *
  489:             K = K - 2
  490:          END IF
  491: *
  492:          GO TO 90
  493:   100    CONTINUE
  494:       END IF
  495: *
  496:       RETURN
  497: *
  498: *     End of ZHETRS_ROOK
  499: *
  500:       END

CVSweb interface <joel.bertrand@systella.fr>