File:  [local] / rpl / lapack / lapack / dorgtr.f
Revision 1.6: download - view: text, annotated - select for diffs - revision graph
Fri Aug 13 21:03:54 2010 UTC (13 years, 9 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_0_19, rpl-4_0_18, HEAD
Patches pour OS/2

    1:       SUBROUTINE DORGTR( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )
    2: *
    3: *  -- LAPACK routine (version 3.2) --
    4: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
    5: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
    6: *     November 2006
    7: *
    8: *     .. Scalar Arguments ..
    9:       CHARACTER          UPLO
   10:       INTEGER            INFO, LDA, LWORK, N
   11: *     ..
   12: *     .. Array Arguments ..
   13:       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
   14: *     ..
   15: *
   16: *  Purpose
   17: *  =======
   18: *
   19: *  DORGTR generates a real orthogonal matrix Q which is defined as the
   20: *  product of n-1 elementary reflectors of order N, as returned by
   21: *  DSYTRD:
   22: *
   23: *  if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),
   24: *
   25: *  if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
   26: *
   27: *  Arguments
   28: *  =========
   29: *
   30: *  UPLO    (input) CHARACTER*1
   31: *          = 'U': Upper triangle of A contains elementary reflectors
   32: *                 from DSYTRD;
   33: *          = 'L': Lower triangle of A contains elementary reflectors
   34: *                 from DSYTRD.
   35: *
   36: *  N       (input) INTEGER
   37: *          The order of the matrix Q. N >= 0.
   38: *
   39: *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
   40: *          On entry, the vectors which define the elementary reflectors,
   41: *          as returned by DSYTRD.
   42: *          On exit, the N-by-N orthogonal matrix Q.
   43: *
   44: *  LDA     (input) INTEGER
   45: *          The leading dimension of the array A. LDA >= max(1,N).
   46: *
   47: *  TAU     (input) DOUBLE PRECISION array, dimension (N-1)
   48: *          TAU(i) must contain the scalar factor of the elementary
   49: *          reflector H(i), as returned by DSYTRD.
   50: *
   51: *  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
   52: *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
   53: *
   54: *  LWORK   (input) INTEGER
   55: *          The dimension of the array WORK. LWORK >= max(1,N-1).
   56: *          For optimum performance LWORK >= (N-1)*NB, where NB is
   57: *          the optimal blocksize.
   58: *
   59: *          If LWORK = -1, then a workspace query is assumed; the routine
   60: *          only calculates the optimal size of the WORK array, returns
   61: *          this value as the first entry of the WORK array, and no error
   62: *          message related to LWORK is issued by XERBLA.
   63: *
   64: *  INFO    (output) INTEGER
   65: *          = 0:  successful exit
   66: *          < 0:  if INFO = -i, the i-th argument had an illegal value
   67: *
   68: *  =====================================================================
   69: *
   70: *     .. Parameters ..
   71:       DOUBLE PRECISION   ZERO, ONE
   72:       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
   73: *     ..
   74: *     .. Local Scalars ..
   75:       LOGICAL            LQUERY, UPPER
   76:       INTEGER            I, IINFO, J, LWKOPT, NB
   77: *     ..
   78: *     .. External Functions ..
   79:       LOGICAL            LSAME
   80:       INTEGER            ILAENV
   81:       EXTERNAL           LSAME, ILAENV
   82: *     ..
   83: *     .. External Subroutines ..
   84:       EXTERNAL           DORGQL, DORGQR, XERBLA
   85: *     ..
   86: *     .. Intrinsic Functions ..
   87:       INTRINSIC          MAX
   88: *     ..
   89: *     .. Executable Statements ..
   90: *
   91: *     Test the input arguments
   92: *
   93:       INFO = 0
   94:       LQUERY = ( LWORK.EQ.-1 )
   95:       UPPER = LSAME( UPLO, 'U' )
   96:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
   97:          INFO = -1
   98:       ELSE IF( N.LT.0 ) THEN
   99:          INFO = -2
  100:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  101:          INFO = -4
  102:       ELSE IF( LWORK.LT.MAX( 1, N-1 ) .AND. .NOT.LQUERY ) THEN
  103:          INFO = -7
  104:       END IF
  105: *
  106:       IF( INFO.EQ.0 ) THEN
  107:          IF( UPPER ) THEN
  108:             NB = ILAENV( 1, 'DORGQL', ' ', N-1, N-1, N-1, -1 )
  109:          ELSE
  110:             NB = ILAENV( 1, 'DORGQR', ' ', N-1, N-1, N-1, -1 )
  111:          END IF
  112:          LWKOPT = MAX( 1, N-1 )*NB
  113:          WORK( 1 ) = LWKOPT
  114:       END IF
  115: *
  116:       IF( INFO.NE.0 ) THEN
  117:          CALL XERBLA( 'DORGTR', -INFO )
  118:          RETURN
  119:       ELSE IF( LQUERY ) THEN
  120:          RETURN
  121:       END IF
  122: *
  123: *     Quick return if possible
  124: *
  125:       IF( N.EQ.0 ) THEN
  126:          WORK( 1 ) = 1
  127:          RETURN
  128:       END IF
  129: *
  130:       IF( UPPER ) THEN
  131: *
  132: *        Q was determined by a call to DSYTRD with UPLO = 'U'
  133: *
  134: *        Shift the vectors which define the elementary reflectors one
  135: *        column to the left, and set the last row and column of Q to
  136: *        those of the unit matrix
  137: *
  138:          DO 20 J = 1, N - 1
  139:             DO 10 I = 1, J - 1
  140:                A( I, J ) = A( I, J+1 )
  141:    10       CONTINUE
  142:             A( N, J ) = ZERO
  143:    20    CONTINUE
  144:          DO 30 I = 1, N - 1
  145:             A( I, N ) = ZERO
  146:    30    CONTINUE
  147:          A( N, N ) = ONE
  148: *
  149: *        Generate Q(1:n-1,1:n-1)
  150: *
  151:          CALL DORGQL( N-1, N-1, N-1, A, LDA, TAU, WORK, LWORK, IINFO )
  152: *
  153:       ELSE
  154: *
  155: *        Q was determined by a call to DSYTRD with UPLO = 'L'.
  156: *
  157: *        Shift the vectors which define the elementary reflectors one
  158: *        column to the right, and set the first row and column of Q to
  159: *        those of the unit matrix
  160: *
  161:          DO 50 J = N, 2, -1
  162:             A( 1, J ) = ZERO
  163:             DO 40 I = J + 1, N
  164:                A( I, J ) = A( I, J-1 )
  165:    40       CONTINUE
  166:    50    CONTINUE
  167:          A( 1, 1 ) = ONE
  168:          DO 60 I = 2, N
  169:             A( I, 1 ) = ZERO
  170:    60    CONTINUE
  171:          IF( N.GT.1 ) THEN
  172: *
  173: *           Generate Q(2:n,2:n)
  174: *
  175:             CALL DORGQR( N-1, N-1, N-1, A( 2, 2 ), LDA, TAU, WORK,
  176:      $                   LWORK, IINFO )
  177:          END IF
  178:       END IF
  179:       WORK( 1 ) = LWKOPT
  180:       RETURN
  181: *
  182: *     End of DORGTR
  183: *
  184:       END

CVSweb interface <joel.bertrand@systella.fr>