sorgtr.c
Go to the documentation of this file.
00001 /* sorgtr.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 sorgtr_(char *uplo, integer *n, real *a, integer *lda, 
00022         real *tau, real *work, integer *lwork, 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__, j, nb;
00029     extern logical lsame_(char *, char *);
00030     integer iinfo;
00031     logical upper;
00032     extern /* Subroutine */ int xerbla_(char *, integer *);
00033     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00034             integer *, integer *);
00035     extern /* Subroutine */ int sorgql_(integer *, integer *, integer *, real 
00036             *, integer *, real *, real *, integer *, integer *), sorgqr_(
00037             integer *, integer *, integer *, real *, integer *, real *, real *
00038 , integer *, integer *);
00039     logical lquery;
00040     integer lwkopt;
00041 
00042 
00043 /*  -- LAPACK routine (version 3.2) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  SORGTR generates a real orthogonal matrix Q which is defined as the */
00056 /*  product of n-1 elementary reflectors of order N, as returned by */
00057 /*  SSYTRD: */
00058 
00059 /*  if UPLO = 'U', Q = H(n-1) . . . H(2) H(1), */
00060 
00061 /*  if UPLO = 'L', Q = H(1) H(2) . . . H(n-1). */
00062 
00063 /*  Arguments */
00064 /*  ========= */
00065 
00066 /*  UPLO    (input) CHARACTER*1 */
00067 /*          = 'U': Upper triangle of A contains elementary reflectors */
00068 /*                 from SSYTRD; */
00069 /*          = 'L': Lower triangle of A contains elementary reflectors */
00070 /*                 from SSYTRD. */
00071 
00072 /*  N       (input) INTEGER */
00073 /*          The order of the matrix Q. N >= 0. */
00074 
00075 /*  A       (input/output) REAL array, dimension (LDA,N) */
00076 /*          On entry, the vectors which define the elementary reflectors, */
00077 /*          as returned by SSYTRD. */
00078 /*          On exit, the N-by-N orthogonal matrix Q. */
00079 
00080 /*  LDA     (input) INTEGER */
00081 /*          The leading dimension of the array A. LDA >= max(1,N). */
00082 
00083 /*  TAU     (input) REAL array, dimension (N-1) */
00084 /*          TAU(i) must contain the scalar factor of the elementary */
00085 /*          reflector H(i), as returned by SSYTRD. */
00086 
00087 /*  WORK    (workspace/output) REAL array, dimension (MAX(1,LWORK)) */
00088 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00089 
00090 /*  LWORK   (input) INTEGER */
00091 /*          The dimension of the array WORK. LWORK >= max(1,N-1). */
00092 /*          For optimum performance LWORK >= (N-1)*NB, where NB is */
00093 /*          the optimal blocksize. */
00094 
00095 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00096 /*          only calculates the optimal size of the WORK array, returns */
00097 /*          this value as the first entry of the WORK array, and no error */
00098 /*          message related to LWORK is issued by XERBLA. */
00099 
00100 /*  INFO    (output) INTEGER */
00101 /*          = 0:  successful exit */
00102 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00103 
00104 /*  ===================================================================== */
00105 
00106 /*     .. Parameters .. */
00107 /*     .. */
00108 /*     .. Local Scalars .. */
00109 /*     .. */
00110 /*     .. External Functions .. */
00111 /*     .. */
00112 /*     .. External Subroutines .. */
00113 /*     .. */
00114 /*     .. Intrinsic Functions .. */
00115 /*     .. */
00116 /*     .. Executable Statements .. */
00117 
00118 /*     Test the input arguments */
00119 
00120     /* Parameter adjustments */
00121     a_dim1 = *lda;
00122     a_offset = 1 + a_dim1;
00123     a -= a_offset;
00124     --tau;
00125     --work;
00126 
00127     /* Function Body */
00128     *info = 0;
00129     lquery = *lwork == -1;
00130     upper = lsame_(uplo, "U");
00131     if (! upper && ! lsame_(uplo, "L")) {
00132         *info = -1;
00133     } else if (*n < 0) {
00134         *info = -2;
00135     } else if (*lda < max(1,*n)) {
00136         *info = -4;
00137     } else /* if(complicated condition) */ {
00138 /* Computing MAX */
00139         i__1 = 1, i__2 = *n - 1;
00140         if (*lwork < max(i__1,i__2) && ! lquery) {
00141             *info = -7;
00142         }
00143     }
00144 
00145     if (*info == 0) {
00146         if (upper) {
00147             i__1 = *n - 1;
00148             i__2 = *n - 1;
00149             i__3 = *n - 1;
00150             nb = ilaenv_(&c__1, "SORGQL", " ", &i__1, &i__2, &i__3, &c_n1);
00151         } else {
00152             i__1 = *n - 1;
00153             i__2 = *n - 1;
00154             i__3 = *n - 1;
00155             nb = ilaenv_(&c__1, "SORGQR", " ", &i__1, &i__2, &i__3, &c_n1);
00156         }
00157 /* Computing MAX */
00158         i__1 = 1, i__2 = *n - 1;
00159         lwkopt = max(i__1,i__2) * nb;
00160         work[1] = (real) lwkopt;
00161     }
00162 
00163     if (*info != 0) {
00164         i__1 = -(*info);
00165         xerbla_("SORGTR", &i__1);
00166         return 0;
00167     } else if (lquery) {
00168         return 0;
00169     }
00170 
00171 /*     Quick return if possible */
00172 
00173     if (*n == 0) {
00174         work[1] = 1.f;
00175         return 0;
00176     }
00177 
00178     if (upper) {
00179 
00180 /*        Q was determined by a call to SSYTRD with UPLO = 'U' */
00181 
00182 /*        Shift the vectors which define the elementary reflectors one */
00183 /*        column to the left, and set the last row and column of Q to */
00184 /*        those of the unit matrix */
00185 
00186         i__1 = *n - 1;
00187         for (j = 1; j <= i__1; ++j) {
00188             i__2 = j - 1;
00189             for (i__ = 1; i__ <= i__2; ++i__) {
00190                 a[i__ + j * a_dim1] = a[i__ + (j + 1) * a_dim1];
00191 /* L10: */
00192             }
00193             a[*n + j * a_dim1] = 0.f;
00194 /* L20: */
00195         }
00196         i__1 = *n - 1;
00197         for (i__ = 1; i__ <= i__1; ++i__) {
00198             a[i__ + *n * a_dim1] = 0.f;
00199 /* L30: */
00200         }
00201         a[*n + *n * a_dim1] = 1.f;
00202 
00203 /*        Generate Q(1:n-1,1:n-1) */
00204 
00205         i__1 = *n - 1;
00206         i__2 = *n - 1;
00207         i__3 = *n - 1;
00208         sorgql_(&i__1, &i__2, &i__3, &a[a_offset], lda, &tau[1], &work[1], 
00209                 lwork, &iinfo);
00210 
00211     } else {
00212 
00213 /*        Q was determined by a call to SSYTRD with UPLO = 'L'. */
00214 
00215 /*        Shift the vectors which define the elementary reflectors one */
00216 /*        column to the right, and set the first row and column of Q to */
00217 /*        those of the unit matrix */
00218 
00219         for (j = *n; j >= 2; --j) {
00220             a[j * a_dim1 + 1] = 0.f;
00221             i__1 = *n;
00222             for (i__ = j + 1; i__ <= i__1; ++i__) {
00223                 a[i__ + j * a_dim1] = a[i__ + (j - 1) * a_dim1];
00224 /* L40: */
00225             }
00226 /* L50: */
00227         }
00228         a[a_dim1 + 1] = 1.f;
00229         i__1 = *n;
00230         for (i__ = 2; i__ <= i__1; ++i__) {
00231             a[i__ + a_dim1] = 0.f;
00232 /* L60: */
00233         }
00234         if (*n > 1) {
00235 
00236 /*           Generate Q(2:n,2:n) */
00237 
00238             i__1 = *n - 1;
00239             i__2 = *n - 1;
00240             i__3 = *n - 1;
00241             sorgqr_(&i__1, &i__2, &i__3, &a[(a_dim1 << 1) + 2], lda, &tau[1], 
00242                     &work[1], lwork, &iinfo);
00243         }
00244     }
00245     work[1] = (real) lwkopt;
00246     return 0;
00247 
00248 /*     End of SORGTR */
00249 
00250 } /* sorgtr_ */


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