00001 /* dorghr.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 static integer c_n1 = -1; 00020 00021 /* Subroutine */ int dorghr_(integer *n, integer *ilo, integer *ihi, 00022 doublereal *a, integer *lda, doublereal *tau, doublereal *work, 00023 integer *lwork, integer *info) 00024 { 00025 /* System generated locals */ 00026 integer a_dim1, a_offset, i__1, i__2; 00027 00028 /* Local variables */ 00029 integer i__, j, nb, nh, iinfo; 00030 extern /* Subroutine */ int xerbla_(char *, integer *); 00031 extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 00032 integer *, integer *); 00033 extern /* Subroutine */ int dorgqr_(integer *, integer *, integer *, 00034 doublereal *, integer *, doublereal *, doublereal *, integer *, 00035 integer *); 00036 integer lwkopt; 00037 logical lquery; 00038 00039 00040 /* -- LAPACK routine (version 3.2) -- */ 00041 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00042 /* November 2006 */ 00043 00044 /* .. Scalar Arguments .. */ 00045 /* .. */ 00046 /* .. Array Arguments .. */ 00047 /* .. */ 00048 00049 /* Purpose */ 00050 /* ======= */ 00051 00052 /* DORGHR generates a real orthogonal matrix Q which is defined as the */ 00053 /* product of IHI-ILO elementary reflectors of order N, as returned by */ 00054 /* DGEHRD: */ 00055 00056 /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ 00057 00058 /* Arguments */ 00059 /* ========= */ 00060 00061 /* N (input) INTEGER */ 00062 /* The order of the matrix Q. N >= 0. */ 00063 00064 /* ILO (input) INTEGER */ 00065 /* IHI (input) INTEGER */ 00066 /* ILO and IHI must have the same values as in the previous call */ 00067 /* of DGEHRD. Q is equal to the unit matrix except in the */ 00068 /* submatrix Q(ilo+1:ihi,ilo+1:ihi). */ 00069 /* 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */ 00070 00071 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ 00072 /* On entry, the vectors which define the elementary reflectors, */ 00073 /* as returned by DGEHRD. */ 00074 /* On exit, the N-by-N orthogonal matrix Q. */ 00075 00076 /* LDA (input) INTEGER */ 00077 /* The leading dimension of the array A. LDA >= max(1,N). */ 00078 00079 /* TAU (input) DOUBLE PRECISION array, dimension (N-1) */ 00080 /* TAU(i) must contain the scalar factor of the elementary */ 00081 /* reflector H(i), as returned by DGEHRD. */ 00082 00083 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */ 00084 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ 00085 00086 /* LWORK (input) INTEGER */ 00087 /* The dimension of the array WORK. LWORK >= IHI-ILO. */ 00088 /* For optimum performance LWORK >= (IHI-ILO)*NB, where NB is */ 00089 /* the optimal blocksize. */ 00090 00091 /* If LWORK = -1, then a workspace query is assumed; the routine */ 00092 /* only calculates the optimal size of the WORK array, returns */ 00093 /* this value as the first entry of the WORK array, and no error */ 00094 /* message related to LWORK is issued by XERBLA. */ 00095 00096 /* INFO (output) INTEGER */ 00097 /* = 0: successful exit */ 00098 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00099 00100 /* ===================================================================== */ 00101 00102 /* .. Parameters .. */ 00103 /* .. */ 00104 /* .. Local Scalars .. */ 00105 /* .. */ 00106 /* .. External Subroutines .. */ 00107 /* .. */ 00108 /* .. External Functions .. */ 00109 /* .. */ 00110 /* .. Intrinsic Functions .. */ 00111 /* .. */ 00112 /* .. Executable Statements .. */ 00113 00114 /* Test the input arguments */ 00115 00116 /* Parameter adjustments */ 00117 a_dim1 = *lda; 00118 a_offset = 1 + a_dim1; 00119 a -= a_offset; 00120 --tau; 00121 --work; 00122 00123 /* Function Body */ 00124 *info = 0; 00125 nh = *ihi - *ilo; 00126 lquery = *lwork == -1; 00127 if (*n < 0) { 00128 *info = -1; 00129 } else if (*ilo < 1 || *ilo > max(1,*n)) { 00130 *info = -2; 00131 } else if (*ihi < min(*ilo,*n) || *ihi > *n) { 00132 *info = -3; 00133 } else if (*lda < max(1,*n)) { 00134 *info = -5; 00135 } else if (*lwork < max(1,nh) && ! lquery) { 00136 *info = -8; 00137 } 00138 00139 if (*info == 0) { 00140 nb = ilaenv_(&c__1, "DORGQR", " ", &nh, &nh, &nh, &c_n1); 00141 lwkopt = max(1,nh) * nb; 00142 work[1] = (doublereal) lwkopt; 00143 } 00144 00145 if (*info != 0) { 00146 i__1 = -(*info); 00147 xerbla_("DORGHR", &i__1); 00148 return 0; 00149 } else if (lquery) { 00150 return 0; 00151 } 00152 00153 /* Quick return if possible */ 00154 00155 if (*n == 0) { 00156 work[1] = 1.; 00157 return 0; 00158 } 00159 00160 /* Shift the vectors which define the elementary reflectors one */ 00161 /* column to the right, and set the first ilo and the last n-ihi */ 00162 /* rows and columns to those of the unit matrix */ 00163 00164 i__1 = *ilo + 1; 00165 for (j = *ihi; j >= i__1; --j) { 00166 i__2 = j - 1; 00167 for (i__ = 1; i__ <= i__2; ++i__) { 00168 a[i__ + j * a_dim1] = 0.; 00169 /* L10: */ 00170 } 00171 i__2 = *ihi; 00172 for (i__ = j + 1; i__ <= i__2; ++i__) { 00173 a[i__ + j * a_dim1] = a[i__ + (j - 1) * a_dim1]; 00174 /* L20: */ 00175 } 00176 i__2 = *n; 00177 for (i__ = *ihi + 1; i__ <= i__2; ++i__) { 00178 a[i__ + j * a_dim1] = 0.; 00179 /* L30: */ 00180 } 00181 /* L40: */ 00182 } 00183 i__1 = *ilo; 00184 for (j = 1; j <= i__1; ++j) { 00185 i__2 = *n; 00186 for (i__ = 1; i__ <= i__2; ++i__) { 00187 a[i__ + j * a_dim1] = 0.; 00188 /* L50: */ 00189 } 00190 a[j + j * a_dim1] = 1.; 00191 /* L60: */ 00192 } 00193 i__1 = *n; 00194 for (j = *ihi + 1; j <= i__1; ++j) { 00195 i__2 = *n; 00196 for (i__ = 1; i__ <= i__2; ++i__) { 00197 a[i__ + j * a_dim1] = 0.; 00198 /* L70: */ 00199 } 00200 a[j + j * a_dim1] = 1.; 00201 /* L80: */ 00202 } 00203 00204 if (nh > 0) { 00205 00206 /* Generate Q(ilo+1:ihi,ilo+1:ihi) */ 00207 00208 dorgqr_(&nh, &nh, &nh, &a[*ilo + 1 + (*ilo + 1) * a_dim1], lda, &tau[* 00209 ilo], &work[1], lwork, &iinfo); 00210 } 00211 work[1] = (doublereal) lwkopt; 00212 return 0; 00213 00214 /* End of DORGHR */ 00215 00216 } /* dorghr_ */