1 /* ../netlib/sormtr.f -- translated by f2c (version 20100827). You must link the resulting object file with libf2c: on Microsoft Windows system, link with libf2c.lib;
2  on Linux or Unix systems, link with .../path/to/libf2c.a -lm or, if you install libf2c.a in a standard place, with -lf2c -lm -- in that order, at the end of the command line, as in cc *.o -lf2c -lm Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., http://www.netlib.org/f2c/libf2c.zip */
3 #include "FLA_f2c.h" /* Table of constant values */
4 static integer c__1 = 1;
5 static integer c_n1 = -1;
6 /* > \brief \b SORMTR */
7 /* =========== DOCUMENTATION =========== */
8 /* Online html documentation available at */
9 /* http://www.netlib.org/lapack/explore-html/ */
10 /* > \htmlonly */
11 /* > Download SORMTR + dependencies */
12 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sormtr. f"> */
13 /* > [TGZ]</a> */
14 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sormtr. f"> */
15 /* > [ZIP]</a> */
16 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sormtr. f"> */
17 /* > [TXT]</a> */
18 /* > \endhtmlonly */
19 /* Definition: */
20 /* =========== */
21 /* SUBROUTINE SORMTR( SIDE, UPLO, TRANS, M, N, A, LDA, TAU, C, LDC, */
22 /* WORK, LWORK, INFO ) */
23 /* .. Scalar Arguments .. */
24 /* CHARACTER SIDE, TRANS, UPLO */
25 /* INTEGER INFO, LDA, LDC, LWORK, M, N */
26 /* .. */
27 /* .. Array Arguments .. */
28 /* REAL A( LDA, * ), C( LDC, * ), TAU( * ), */
29 /* $ WORK( * ) */
30 /* .. */
31 /* > \par Purpose: */
32 /* ============= */
33 /* > */
34 /* > \verbatim */
35 /* > */
36 /* > SORMTR overwrites the general real M-by-N matrix C with */
37 /* > */
38 /* > SIDE = 'L' SIDE = 'R' */
39 /* > TRANS = 'N': Q * C C * Q */
40 /* > TRANS = 'T': Q**T * C C * Q**T */
41 /* > */
42 /* > where Q is a real orthogonal matrix of order nq, with nq = m if */
43 /* > SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of */
44 /* > nq-1 elementary reflectors, as returned by SSYTRD: */
45 /* > */
46 /* > if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1);
47 */
48 /* > */
49 /* > if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1). */
50 /* > \endverbatim */
51 /* Arguments: */
52 /* ========== */
53 /* > \param[in] SIDE */
54 /* > \verbatim */
55 /* > SIDE is CHARACTER*1 */
56 /* > = 'L': apply Q or Q**T from the Left;
57 */
58 /* > = 'R': apply Q or Q**T from the Right. */
59 /* > \endverbatim */
60 /* > */
61 /* > \param[in] UPLO */
62 /* > \verbatim */
63 /* > UPLO is CHARACTER*1 */
64 /* > = 'U': Upper triangle of A contains elementary reflectors */
65 /* > from SSYTRD;
66 */
67 /* > = 'L': Lower triangle of A contains elementary reflectors */
68 /* > from SSYTRD. */
69 /* > \endverbatim */
70 /* > */
71 /* > \param[in] TRANS */
72 /* > \verbatim */
73 /* > TRANS is CHARACTER*1 */
74 /* > = 'N': No transpose, apply Q;
75 */
76 /* > = 'T': Transpose, apply Q**T. */
77 /* > \endverbatim */
78 /* > */
79 /* > \param[in] M */
80 /* > \verbatim */
81 /* > M is INTEGER */
82 /* > The number of rows of the matrix C. M >= 0. */
83 /* > \endverbatim */
84 /* > */
85 /* > \param[in] N */
86 /* > \verbatim */
87 /* > N is INTEGER */
88 /* > The number of columns of the matrix C. N >= 0. */
89 /* > \endverbatim */
90 /* > */
91 /* > \param[in] A */
92 /* > \verbatim */
93 /* > A is REAL array, dimension */
94 /* > (LDA,M) if SIDE = 'L' */
95 /* > (LDA,N) if SIDE = 'R' */
96 /* > The vectors which define the elementary reflectors, as */
97 /* > returned by SSYTRD. */
98 /* > \endverbatim */
99 /* > */
100 /* > \param[in] LDA */
101 /* > \verbatim */
102 /* > LDA is INTEGER */
103 /* > The leading dimension of the array A. */
104 /* > LDA >= max(1,M) if SIDE = 'L';
105 LDA >= max(1,N) if SIDE = 'R'. */
106 /* > \endverbatim */
107 /* > */
108 /* > \param[in] TAU */
109 /* > \verbatim */
110 /* > TAU is REAL array, dimension */
111 /* > (M-1) if SIDE = 'L' */
112 /* > (N-1) if SIDE = 'R' */
113 /* > TAU(i) must contain the scalar factor of the elementary */
114 /* > reflector H(i), as returned by SSYTRD. */
115 /* > \endverbatim */
116 /* > */
117 /* > \param[in,out] C */
118 /* > \verbatim */
119 /* > C is REAL array, dimension (LDC,N) */
120 /* > On entry, the M-by-N matrix C. */
121 /* > On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q. */
122 /* > \endverbatim */
123 /* > */
124 /* > \param[in] LDC */
125 /* > \verbatim */
126 /* > LDC is INTEGER */
127 /* > The leading dimension of the array C. LDC >= max(1,M). */
128 /* > \endverbatim */
129 /* > */
130 /* > \param[out] WORK */
131 /* > \verbatim */
132 /* > WORK is REAL array, dimension (MAX(1,LWORK)) */
133 /* > On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
134 /* > \endverbatim */
135 /* > */
136 /* > \param[in] LWORK */
137 /* > \verbatim */
138 /* > LWORK is INTEGER */
139 /* > The dimension of the array WORK. */
140 /* > If SIDE = 'L', LWORK >= max(1,N);
141 */
142 /* > if SIDE = 'R', LWORK >= max(1,M). */
143 /* > For optimum performance LWORK >= N*NB if SIDE = 'L', and */
144 /* > LWORK >= M*NB if SIDE = 'R', where NB is the optimal */
145 /* > blocksize. */
146 /* > */
147 /* > If LWORK = -1, then a workspace query is assumed;
148 the routine */
149 /* > only calculates the optimal size of the WORK array, returns */
150 /* > this value as the first entry of the WORK array, and no error */
151 /* > message related to LWORK is issued by XERBLA. */
152 /* > \endverbatim */
153 /* > */
154 /* > \param[out] INFO */
155 /* > \verbatim */
156 /* > INFO is INTEGER */
157 /* > = 0: successful exit */
158 /* > < 0: if INFO = -i, the i-th argument had an illegal value */
159 /* > \endverbatim */
160 /* Authors: */
161 /* ======== */
162 /* > \author Univ. of Tennessee */
163 /* > \author Univ. of California Berkeley */
164 /* > \author Univ. of Colorado Denver */
165 /* > \author NAG Ltd. */
166 /* > \date November 2011 */
167 /* > \ingroup realOTHERcomputational */
168 /* ===================================================================== */
169 /* Subroutine */
sormtr_fla(char * side,char * uplo,char * trans,integer * m,integer * n,real * a,integer * lda,real * tau,real * c__,integer * ldc,real * work,integer * lwork,integer * info)170 int sormtr_fla(char *side, char *uplo, char *trans, integer *m, integer *n, real *a, integer *lda, real *tau, real *c__, integer *ldc, real *work, integer *lwork, integer *info)
171 {
172     /* System generated locals */
173     integer a_dim1, a_offset, c_dim1, c_offset, i__2, i__3;
174     char ch__1[2];
175     /* Builtin functions */
176     /* Subroutine */
177 
178     /* Local variables */
179     integer i1, i2, nb, mi, ni, nq, nw;
180     logical left;
181     extern logical lsame_(char *, char *);
182     integer iinfo;
183     logical upper;
184     extern /* Subroutine */
185     int xerbla_(char *, integer *);
186     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *);
187     extern /* Subroutine */
188     int sormql_(char *, char *, integer *, integer *, integer *, real *, integer *, real *, real *, integer *, real *, integer *, integer *);
189     integer lwkopt;
190     logical lquery;
191     extern /* Subroutine */
192     int sormqr_fla(char *, char *, integer *, integer *, integer *, real *, integer *, real *, real *, integer *, real *, integer *, integer *);
193     /* -- LAPACK computational routine (version 3.4.0) -- */
194     /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
195     /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
196     /* November 2011 */
197     /* .. Scalar Arguments .. */
198     /* .. */
199     /* .. Array Arguments .. */
200     /* .. */
201     /* ===================================================================== */
202     /* .. Local Scalars .. */
203     /* .. */
204     /* .. External Functions .. */
205     /* .. */
206     /* .. External Subroutines .. */
207     /* .. */
208     /* .. Intrinsic Functions .. */
209     /* .. */
210     /* .. Executable Statements .. */
211     /* Test the input arguments */
212     /* Parameter adjustments */
213     a_dim1 = *lda;
214     a_offset = 1 + a_dim1;
215     a -= a_offset;
216     --tau;
217     c_dim1 = *ldc;
218     c_offset = 1 + c_dim1;
219     c__ -= c_offset;
220     --work;
221     /* Function Body */
222     *info = 0;
223     left = lsame_(side, "L");
224     upper = lsame_(uplo, "U");
225     lquery = *lwork == -1;
226     /* NQ is the order of Q and NW is the minimum dimension of WORK */
227     if (left)
228     {
229         nq = *m;
230         nw = *n;
231     }
232     else
233     {
234         nq = *n;
235         nw = *m;
236     }
237     if (! left && ! lsame_(side, "R"))
238     {
239         *info = -1;
240     }
241     else if (! upper && ! lsame_(uplo, "L"))
242     {
243         *info = -2;
244     }
245     else if (! lsame_(trans, "N") && ! lsame_(trans, "T"))
246     {
247         *info = -3;
248     }
249     else if (*m < 0)
250     {
251         *info = -4;
252     }
253     else if (*n < 0)
254     {
255         *info = -5;
256     }
257     else if (*lda < max(1,nq))
258     {
259         *info = -7;
260     }
261     else if (*ldc < max(1,*m))
262     {
263         *info = -10;
264     }
265     else if (*lwork < max(1,nw) && ! lquery)
266     {
267         *info = -12;
268     }
269     if (*info == 0)
270     {
271         if (upper)
272         {
273             if (left)
274             {
275                 i__2 = *m - 1;
276                 i__3 = *m - 1;
277                 nb = ilaenv_(&c__1, "SORMQL", ch__1, &i__2, n, &i__3, &c_n1);
278             }
279             else
280             {
281                 i__2 = *n - 1;
282                 i__3 = *n - 1;
283                 nb = ilaenv_(&c__1, "SORMQL", ch__1, m, &i__2, &i__3, &c_n1);
284             }
285         }
286         else
287         {
288             if (left)
289             {
290                 i__2 = *m - 1;
291                 i__3 = *m - 1;
292                 nb = ilaenv_(&c__1, "SORMQR", ch__1, &i__2, n, &i__3, &c_n1);
293             }
294             else
295             {
296                 i__2 = *n - 1;
297                 i__3 = *n - 1;
298                 nb = ilaenv_(&c__1, "SORMQR", ch__1, m, &i__2, &i__3, &c_n1);
299             }
300         }
301         lwkopt = max(1,nw) * nb;
302         work[1] = (real) lwkopt;
303     }
304     if (*info != 0)
305     {
306         i__2 = -(*info);
307         xerbla_("SORMTR", &i__2);
308         return 0;
309     }
310     else if (lquery)
311     {
312         return 0;
313     }
314     /* Quick return if possible */
315     if (*m == 0 || *n == 0 || nq == 1)
316     {
317         work[1] = 1.f;
318         return 0;
319     }
320     if (left)
321     {
322         mi = *m - 1;
323         ni = *n;
324     }
325     else
326     {
327         mi = *m;
328         ni = *n - 1;
329     }
330     if (upper)
331     {
332         /* Q was determined by a call to SSYTRD with UPLO = 'U' */
333         i__2 = nq - 1;
334         sormql_(side, trans, &mi, &ni, &i__2, &a[(a_dim1 << 1) + 1], lda, & tau[1], &c__[c_offset], ldc, &work[1], lwork, &iinfo);
335     }
336     else
337     {
338         /* Q was determined by a call to SSYTRD with UPLO = 'L' */
339         if (left)
340         {
341             i1 = 2;
342             i2 = 1;
343         }
344         else
345         {
346             i1 = 1;
347             i2 = 2;
348         }
349         i__2 = nq - 1;
350         sormqr_fla(side, trans, &mi, &ni, &i__2, &a[a_dim1 + 2], lda, &tau[1], & c__[i1 + i2 * c_dim1], ldc, &work[1], lwork, &iinfo);
351     }
352     work[1] = (real) lwkopt;
353     return 0;
354     /* End of SORMTR */
355 }
356 /* sormtr_ */
357