File:  [local] / rpl / lapack / lapack / dlanv2.f
Revision 1.20: download - view: text, annotated - select for diffs - revision graph
Mon Aug 7 08:38:55 2023 UTC (9 months, 1 week 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 DLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric matrix in standard form.
    2: *
    3: *  =========== DOCUMENTATION ===========
    4: *
    5: * Online html documentation available at
    6: *            http://www.netlib.org/lapack/explore-html/
    7: *
    8: *> \htmlonly
    9: *> Download DLANV2 + dependencies
   10: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlanv2.f">
   11: *> [TGZ]</a>
   12: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlanv2.f">
   13: *> [ZIP]</a>
   14: *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlanv2.f">
   15: *> [TXT]</a>
   16: *> \endhtmlonly
   17: *
   18: *  Definition:
   19: *  ===========
   20: *
   21: *       SUBROUTINE DLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
   22: *
   23: *       .. Scalar Arguments ..
   24: *       DOUBLE PRECISION   A, B, C, CS, D, RT1I, RT1R, RT2I, RT2R, SN
   25: *       ..
   26: *
   27: *
   28: *> \par Purpose:
   29: *  =============
   30: *>
   31: *> \verbatim
   32: *>
   33: *> DLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric
   34: *> matrix in standard form:
   35: *>
   36: *>      [ A  B ] = [ CS -SN ] [ AA  BB ] [ CS  SN ]
   37: *>      [ C  D ]   [ SN  CS ] [ CC  DD ] [-SN  CS ]
   38: *>
   39: *> where either
   40: *> 1) CC = 0 so that AA and DD are real eigenvalues of the matrix, or
   41: *> 2) AA = DD and BB*CC < 0, so that AA + or - sqrt(BB*CC) are complex
   42: *> conjugate eigenvalues.
   43: *> \endverbatim
   44: *
   45: *  Arguments:
   46: *  ==========
   47: *
   48: *> \param[in,out] A
   49: *> \verbatim
   50: *>          A is DOUBLE PRECISION
   51: *> \endverbatim
   52: *>
   53: *> \param[in,out] B
   54: *> \verbatim
   55: *>          B is DOUBLE PRECISION
   56: *> \endverbatim
   57: *>
   58: *> \param[in,out] C
   59: *> \verbatim
   60: *>          C is DOUBLE PRECISION
   61: *> \endverbatim
   62: *>
   63: *> \param[in,out] D
   64: *> \verbatim
   65: *>          D is DOUBLE PRECISION
   66: *>          On entry, the elements of the input matrix.
   67: *>          On exit, they are overwritten by the elements of the
   68: *>          standardised Schur form.
   69: *> \endverbatim
   70: *>
   71: *> \param[out] RT1R
   72: *> \verbatim
   73: *>          RT1R is DOUBLE PRECISION
   74: *> \endverbatim
   75: *>
   76: *> \param[out] RT1I
   77: *> \verbatim
   78: *>          RT1I is DOUBLE PRECISION
   79: *> \endverbatim
   80: *>
   81: *> \param[out] RT2R
   82: *> \verbatim
   83: *>          RT2R is DOUBLE PRECISION
   84: *> \endverbatim
   85: *>
   86: *> \param[out] RT2I
   87: *> \verbatim
   88: *>          RT2I is DOUBLE PRECISION
   89: *>          The real and imaginary parts of the eigenvalues. If the
   90: *>          eigenvalues are a complex conjugate pair, RT1I > 0.
   91: *> \endverbatim
   92: *>
   93: *> \param[out] CS
   94: *> \verbatim
   95: *>          CS is DOUBLE PRECISION
   96: *> \endverbatim
   97: *>
   98: *> \param[out] SN
   99: *> \verbatim
  100: *>          SN is DOUBLE PRECISION
  101: *>          Parameters of the rotation matrix.
  102: *> \endverbatim
  103: *
  104: *  Authors:
  105: *  ========
  106: *
  107: *> \author Univ. of Tennessee
  108: *> \author Univ. of California Berkeley
  109: *> \author Univ. of Colorado Denver
  110: *> \author NAG Ltd.
  111: *
  112: *> \ingroup doubleOTHERauxiliary
  113: *
  114: *> \par Further Details:
  115: *  =====================
  116: *>
  117: *> \verbatim
  118: *>
  119: *>  Modified by V. Sima, Research Institute for Informatics, Bucharest,
  120: *>  Romania, to reduce the risk of cancellation errors,
  121: *>  when computing real eigenvalues, and to ensure, if possible, that
  122: *>  abs(RT1R) >= abs(RT2R).
  123: *> \endverbatim
  124: *>
  125: *  =====================================================================
  126:       SUBROUTINE DLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
  127: *
  128: *  -- LAPACK auxiliary routine --
  129: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
  130: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  131: *
  132: *     .. Scalar Arguments ..
  133:       DOUBLE PRECISION   A, B, C, CS, D, RT1I, RT1R, RT2I, RT2R, SN
  134: *     ..
  135: *
  136: *  =====================================================================
  137: *
  138: *     .. Parameters ..
  139:       DOUBLE PRECISION   ZERO, HALF, ONE, TWO
  140:       PARAMETER          ( ZERO = 0.0D+0, HALF = 0.5D+0, ONE = 1.0D+0,
  141:      $                     TWO = 2.0D0 )
  142:       DOUBLE PRECISION   MULTPL
  143:       PARAMETER          ( MULTPL = 4.0D+0 )
  144: *     ..
  145: *     .. Local Scalars ..
  146:       DOUBLE PRECISION   AA, BB, BCMAX, BCMIS, CC, CS1, DD, EPS, P, SAB,
  147:      $                   SAC, SCALE, SIGMA, SN1, TAU, TEMP, Z, SAFMIN, 
  148:      $                   SAFMN2, SAFMX2
  149:       INTEGER            COUNT
  150: *     ..
  151: *     .. External Functions ..
  152:       DOUBLE PRECISION   DLAMCH, DLAPY2
  153:       EXTERNAL           DLAMCH, DLAPY2
  154: *     ..
  155: *     .. Intrinsic Functions ..
  156:       INTRINSIC          ABS, MAX, MIN, SIGN, SQRT
  157: *     ..
  158: *     .. Executable Statements ..
  159: *
  160:       SAFMIN = DLAMCH( 'S' )
  161:       EPS = DLAMCH( 'P' )
  162:       SAFMN2 = DLAMCH( 'B' )**INT( LOG( SAFMIN / EPS ) /
  163:      $            LOG( DLAMCH( 'B' ) ) / TWO )
  164:       SAFMX2 = ONE / SAFMN2
  165:       IF( C.EQ.ZERO ) THEN
  166:          CS = ONE
  167:          SN = ZERO
  168: *
  169:       ELSE IF( B.EQ.ZERO ) THEN
  170: *
  171: *        Swap rows and columns
  172: *
  173:          CS = ZERO
  174:          SN = ONE
  175:          TEMP = D
  176:          D = A
  177:          A = TEMP
  178:          B = -C
  179:          C = ZERO
  180: *
  181:       ELSE IF( ( A-D ).EQ.ZERO .AND. SIGN( ONE, B ).NE.SIGN( ONE, C ) )
  182:      $          THEN
  183:          CS = ONE
  184:          SN = ZERO
  185: *
  186:       ELSE
  187: *
  188:          TEMP = A - D
  189:          P = HALF*TEMP
  190:          BCMAX = MAX( ABS( B ), ABS( C ) )
  191:          BCMIS = MIN( ABS( B ), ABS( C ) )*SIGN( ONE, B )*SIGN( ONE, C )
  192:          SCALE = MAX( ABS( P ), BCMAX )
  193:          Z = ( P / SCALE )*P + ( BCMAX / SCALE )*BCMIS
  194: *
  195: *        If Z is of the order of the machine accuracy, postpone the
  196: *        decision on the nature of eigenvalues
  197: *
  198:          IF( Z.GE.MULTPL*EPS ) THEN
  199: *
  200: *           Real eigenvalues. Compute A and D.
  201: *
  202:             Z = P + SIGN( SQRT( SCALE )*SQRT( Z ), P )
  203:             A = D + Z
  204:             D = D - ( BCMAX / Z )*BCMIS
  205: *
  206: *           Compute B and the rotation matrix
  207: *
  208:             TAU = DLAPY2( C, Z )
  209:             CS = Z / TAU
  210:             SN = C / TAU
  211:             B = B - C
  212:             C = ZERO
  213: *
  214:          ELSE
  215: *
  216: *           Complex eigenvalues, or real (almost) equal eigenvalues.
  217: *           Make diagonal elements equal.
  218: *
  219:             COUNT = 0
  220:             SIGMA = B + C
  221:    10       CONTINUE
  222:             COUNT = COUNT + 1
  223:             SCALE = MAX( ABS(TEMP), ABS(SIGMA) )
  224:             IF( SCALE.GE.SAFMX2 ) THEN
  225:                SIGMA = SIGMA * SAFMN2
  226:                TEMP = TEMP * SAFMN2
  227:                IF (COUNT .LE. 20)
  228:      $            GOTO 10
  229:             END IF
  230:             IF( SCALE.LE.SAFMN2 ) THEN
  231:                SIGMA = SIGMA * SAFMX2
  232:                TEMP = TEMP * SAFMX2
  233:                IF (COUNT .LE. 20)
  234:      $            GOTO 10
  235:             END IF
  236:             P = HALF*TEMP
  237:             TAU = DLAPY2( SIGMA, TEMP )
  238:             CS = SQRT( HALF*( ONE+ABS( SIGMA ) / TAU ) )
  239:             SN = -( P / ( TAU*CS ) )*SIGN( ONE, SIGMA )
  240: *
  241: *           Compute [ AA  BB ] = [ A  B ] [ CS -SN ]
  242: *                   [ CC  DD ]   [ C  D ] [ SN  CS ]
  243: *
  244:             AA = A*CS + B*SN
  245:             BB = -A*SN + B*CS
  246:             CC = C*CS + D*SN
  247:             DD = -C*SN + D*CS
  248: *
  249: *           Compute [ A  B ] = [ CS  SN ] [ AA  BB ]
  250: *                   [ C  D ]   [-SN  CS ] [ CC  DD ]
  251: *
  252:             A = AA*CS + CC*SN
  253:             B = BB*CS + DD*SN
  254:             C = -AA*SN + CC*CS
  255:             D = -BB*SN + DD*CS
  256: *
  257:             TEMP = HALF*( A+D )
  258:             A = TEMP
  259:             D = TEMP
  260: *
  261:             IF( C.NE.ZERO ) THEN
  262:                IF( B.NE.ZERO ) THEN
  263:                   IF( SIGN( ONE, B ).EQ.SIGN( ONE, C ) ) THEN
  264: *
  265: *                    Real eigenvalues: reduce to upper triangular form
  266: *
  267:                      SAB = SQRT( ABS( B ) )
  268:                      SAC = SQRT( ABS( C ) )
  269:                      P = SIGN( SAB*SAC, C )
  270:                      TAU = ONE / SQRT( ABS( B+C ) )
  271:                      A = TEMP + P
  272:                      D = TEMP - P
  273:                      B = B - C
  274:                      C = ZERO
  275:                      CS1 = SAB*TAU
  276:                      SN1 = SAC*TAU
  277:                      TEMP = CS*CS1 - SN*SN1
  278:                      SN = CS*SN1 + SN*CS1
  279:                      CS = TEMP
  280:                   END IF
  281:                ELSE
  282:                   B = -C
  283:                   C = ZERO
  284:                   TEMP = CS
  285:                   CS = -SN
  286:                   SN = TEMP
  287:                END IF
  288:             END IF
  289:          END IF
  290: *
  291:       END IF
  292: *
  293: *     Store eigenvalues in (RT1R,RT1I) and (RT2R,RT2I).
  294: *
  295:       RT1R = A
  296:       RT2R = D
  297:       IF( C.EQ.ZERO ) THEN
  298:          RT1I = ZERO
  299:          RT2I = ZERO
  300:       ELSE
  301:          RT1I = SQRT( ABS( B ) )*SQRT( ABS( C ) )
  302:          RT2I = -RT1I
  303:       END IF
  304:       RETURN
  305: *
  306: *     End of DLANV2
  307: *
  308:       END

CVSweb interface <joel.bertrand@systella.fr>