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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:12