00001 /* dgehd2.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 00020 /* Subroutine */ int dgehd2_(integer *n, integer *ilo, integer *ihi, 00021 doublereal *a, integer *lda, doublereal *tau, doublereal *work, 00022 integer *info) 00023 { 00024 /* System generated locals */ 00025 integer a_dim1, a_offset, i__1, i__2, i__3; 00026 00027 /* Local variables */ 00028 integer i__; 00029 doublereal aii; 00030 extern /* Subroutine */ int dlarf_(char *, integer *, integer *, 00031 doublereal *, integer *, doublereal *, doublereal *, integer *, 00032 doublereal *), dlarfg_(integer *, doublereal *, 00033 doublereal *, integer *, doublereal *), xerbla_(char *, integer *); 00034 00035 00036 /* -- LAPACK routine (version 3.2) -- */ 00037 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00038 /* November 2006 */ 00039 00040 /* .. Scalar Arguments .. */ 00041 /* .. */ 00042 /* .. Array Arguments .. */ 00043 /* .. */ 00044 00045 /* Purpose */ 00046 /* ======= */ 00047 00048 /* DGEHD2 reduces a real general matrix A to upper Hessenberg form H by */ 00049 /* an orthogonal similarity transformation: Q' * A * Q = H . */ 00050 00051 /* Arguments */ 00052 /* ========= */ 00053 00054 /* N (input) INTEGER */ 00055 /* The order of the matrix A. N >= 0. */ 00056 00057 /* ILO (input) INTEGER */ 00058 /* IHI (input) INTEGER */ 00059 /* It is assumed that A is already upper triangular in rows */ 00060 /* and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */ 00061 /* set by a previous call to DGEBAL; otherwise they should be */ 00062 /* set to 1 and N respectively. See Further Details. */ 00063 /* 1 <= ILO <= IHI <= max(1,N). */ 00064 00065 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ 00066 /* On entry, the n by n general matrix to be reduced. */ 00067 /* On exit, the upper triangle and the first subdiagonal of A */ 00068 /* are overwritten with the upper Hessenberg matrix H, and the */ 00069 /* elements below the first subdiagonal, with the array TAU, */ 00070 /* represent the orthogonal matrix Q as a product of elementary */ 00071 /* reflectors. See Further Details. */ 00072 00073 /* LDA (input) INTEGER */ 00074 /* The leading dimension of the array A. LDA >= max(1,N). */ 00075 00076 /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */ 00077 /* The scalar factors of the elementary reflectors (see Further */ 00078 /* Details). */ 00079 00080 /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */ 00081 00082 /* INFO (output) INTEGER */ 00083 /* = 0: successful exit. */ 00084 /* < 0: if INFO = -i, the i-th argument had an illegal value. */ 00085 00086 /* Further Details */ 00087 /* =============== */ 00088 00089 /* The matrix Q is represented as a product of (ihi-ilo) elementary */ 00090 /* reflectors */ 00091 00092 /* Q = H(ilo) H(ilo+1) . . . H(ihi-1). */ 00093 00094 /* Each H(i) has the form */ 00095 00096 /* H(i) = I - tau * v * v' */ 00097 00098 /* where tau is a real scalar, and v is a real vector with */ 00099 /* v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on */ 00100 /* exit in A(i+2:ihi,i), and tau in TAU(i). */ 00101 00102 /* The contents of A are illustrated by the following example, with */ 00103 /* n = 7, ilo = 2 and ihi = 6: */ 00104 00105 /* on entry, on exit, */ 00106 00107 /* ( a a a a a a a ) ( a a h h h h a ) */ 00108 /* ( a a a a a a ) ( a h h h h a ) */ 00109 /* ( a a a a a a ) ( h h h h h h ) */ 00110 /* ( a a a a a a ) ( v2 h h h h h ) */ 00111 /* ( a a a a a a ) ( v2 v3 h h h h ) */ 00112 /* ( a a a a a a ) ( v2 v3 v4 h h h ) */ 00113 /* ( a ) ( a ) */ 00114 00115 /* where a denotes an element of the original matrix A, h denotes a */ 00116 /* modified element of the upper Hessenberg matrix H, and vi denotes an */ 00117 /* element of the vector defining H(i). */ 00118 00119 /* ===================================================================== */ 00120 00121 /* .. Parameters .. */ 00122 /* .. */ 00123 /* .. Local Scalars .. */ 00124 /* .. */ 00125 /* .. External Subroutines .. */ 00126 /* .. */ 00127 /* .. Intrinsic Functions .. */ 00128 /* .. */ 00129 /* .. Executable Statements .. */ 00130 00131 /* Test the input parameters */ 00132 00133 /* Parameter adjustments */ 00134 a_dim1 = *lda; 00135 a_offset = 1 + a_dim1; 00136 a -= a_offset; 00137 --tau; 00138 --work; 00139 00140 /* Function Body */ 00141 *info = 0; 00142 if (*n < 0) { 00143 *info = -1; 00144 } else if (*ilo < 1 || *ilo > max(1,*n)) { 00145 *info = -2; 00146 } else if (*ihi < min(*ilo,*n) || *ihi > *n) { 00147 *info = -3; 00148 } else if (*lda < max(1,*n)) { 00149 *info = -5; 00150 } 00151 if (*info != 0) { 00152 i__1 = -(*info); 00153 xerbla_("DGEHD2", &i__1); 00154 return 0; 00155 } 00156 00157 i__1 = *ihi - 1; 00158 for (i__ = *ilo; i__ <= i__1; ++i__) { 00159 00160 /* Compute elementary reflector H(i) to annihilate A(i+2:ihi,i) */ 00161 00162 i__2 = *ihi - i__; 00163 /* Computing MIN */ 00164 i__3 = i__ + 2; 00165 dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *n)+ i__ * 00166 a_dim1], &c__1, &tau[i__]); 00167 aii = a[i__ + 1 + i__ * a_dim1]; 00168 a[i__ + 1 + i__ * a_dim1] = 1.; 00169 00170 /* Apply H(i) to A(1:ihi,i+1:ihi) from the right */ 00171 00172 i__2 = *ihi - i__; 00173 dlarf_("Right", ihi, &i__2, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[ 00174 i__], &a[(i__ + 1) * a_dim1 + 1], lda, &work[1]); 00175 00176 /* Apply H(i) to A(i+1:ihi,i+1:n) from the left */ 00177 00178 i__2 = *ihi - i__; 00179 i__3 = *n - i__; 00180 dlarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &c__1, &tau[ 00181 i__], &a[i__ + 1 + (i__ + 1) * a_dim1], lda, &work[1]); 00182 00183 a[i__ + 1 + i__ * a_dim1] = aii; 00184 /* L10: */ 00185 } 00186 00187 return 0; 00188 00189 /* End of DGEHD2 */ 00190 00191 } /* dgehd2_ */