C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / SRC / dtprfb.c
1 #include <math.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdio.h>
5 #include <complex.h>
6 #ifdef complex
7 #undef complex
8 #endif
9 #ifdef I
10 #undef I
11 #endif
12
13 #if defined(_WIN64)
14 typedef long long BLASLONG;
15 typedef unsigned long long BLASULONG;
16 #else
17 typedef long BLASLONG;
18 typedef unsigned long BLASULONG;
19 #endif
20
21 #ifdef LAPACK_ILP64
22 typedef BLASLONG blasint;
23 #if defined(_WIN64)
24 #define blasabs(x) llabs(x)
25 #else
26 #define blasabs(x) labs(x)
27 #endif
28 #else
29 typedef int blasint;
30 #define blasabs(x) abs(x)
31 #endif
32
33 typedef blasint integer;
34
35 typedef unsigned int uinteger;
36 typedef char *address;
37 typedef short int shortint;
38 typedef float real;
39 typedef double doublereal;
40 typedef struct { real r, i; } complex;
41 typedef struct { doublereal r, i; } doublecomplex;
42 #ifdef _MSC_VER
43 static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
44 static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
45 static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
46 static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
47 #else
48 static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49 static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50 static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51 static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
52 #endif
53 #define pCf(z) (*_pCf(z))
54 #define pCd(z) (*_pCd(z))
55 typedef int logical;
56 typedef short int shortlogical;
57 typedef char logical1;
58 typedef char integer1;
59
60 #define TRUE_ (1)
61 #define FALSE_ (0)
62
63 /* Extern is for use with -E */
64 #ifndef Extern
65 #define Extern extern
66 #endif
67
68 /* I/O stuff */
69
70 typedef int flag;
71 typedef int ftnlen;
72 typedef int ftnint;
73
74 /*external read, write*/
75 typedef struct
76 {       flag cierr;
77         ftnint ciunit;
78         flag ciend;
79         char *cifmt;
80         ftnint cirec;
81 } cilist;
82
83 /*internal read, write*/
84 typedef struct
85 {       flag icierr;
86         char *iciunit;
87         flag iciend;
88         char *icifmt;
89         ftnint icirlen;
90         ftnint icirnum;
91 } icilist;
92
93 /*open*/
94 typedef struct
95 {       flag oerr;
96         ftnint ounit;
97         char *ofnm;
98         ftnlen ofnmlen;
99         char *osta;
100         char *oacc;
101         char *ofm;
102         ftnint orl;
103         char *oblnk;
104 } olist;
105
106 /*close*/
107 typedef struct
108 {       flag cerr;
109         ftnint cunit;
110         char *csta;
111 } cllist;
112
113 /*rewind, backspace, endfile*/
114 typedef struct
115 {       flag aerr;
116         ftnint aunit;
117 } alist;
118
119 /* inquire */
120 typedef struct
121 {       flag inerr;
122         ftnint inunit;
123         char *infile;
124         ftnlen infilen;
125         ftnint  *inex;  /*parameters in standard's order*/
126         ftnint  *inopen;
127         ftnint  *innum;
128         ftnint  *innamed;
129         char    *inname;
130         ftnlen  innamlen;
131         char    *inacc;
132         ftnlen  inacclen;
133         char    *inseq;
134         ftnlen  inseqlen;
135         char    *indir;
136         ftnlen  indirlen;
137         char    *infmt;
138         ftnlen  infmtlen;
139         char    *inform;
140         ftnint  informlen;
141         char    *inunf;
142         ftnlen  inunflen;
143         ftnint  *inrecl;
144         ftnint  *innrec;
145         char    *inblank;
146         ftnlen  inblanklen;
147 } inlist;
148
149 #define VOID void
150
151 union Multitype {       /* for multiple entry points */
152         integer1 g;
153         shortint h;
154         integer i;
155         /* longint j; */
156         real r;
157         doublereal d;
158         complex c;
159         doublecomplex z;
160         };
161
162 typedef union Multitype Multitype;
163
164 struct Vardesc {        /* for Namelist */
165         char *name;
166         char *addr;
167         ftnlen *dims;
168         int  type;
169         };
170 typedef struct Vardesc Vardesc;
171
172 struct Namelist {
173         char *name;
174         Vardesc **vars;
175         int nvars;
176         };
177 typedef struct Namelist Namelist;
178
179 #define abs(x) ((x) >= 0 ? (x) : -(x))
180 #define dabs(x) (fabs(x))
181 #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182 #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
183 #define dmin(a,b) (f2cmin(a,b))
184 #define dmax(a,b) (f2cmax(a,b))
185 #define bit_test(a,b)   ((a) >> (b) & 1)
186 #define bit_clear(a,b)  ((a) & ~((uinteger)1 << (b)))
187 #define bit_set(a,b)    ((a) |  ((uinteger)1 << (b)))
188
189 #define abort_() { sig_die("Fortran abort routine called", 1); }
190 #define c_abs(z) (cabsf(Cf(z)))
191 #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
192 #ifdef _MSC_VER
193 #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
194 #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);}
195 #else
196 #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
197 #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
198 #endif
199 #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
200 #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
201 #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
202 //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
203 #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
204 #define d_abs(x) (fabs(*(x)))
205 #define d_acos(x) (acos(*(x)))
206 #define d_asin(x) (asin(*(x)))
207 #define d_atan(x) (atan(*(x)))
208 #define d_atn2(x, y) (atan2(*(x),*(y)))
209 #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
210 #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
211 #define d_cos(x) (cos(*(x)))
212 #define d_cosh(x) (cosh(*(x)))
213 #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
214 #define d_exp(x) (exp(*(x)))
215 #define d_imag(z) (cimag(Cd(z)))
216 #define r_imag(z) (cimagf(Cf(z)))
217 #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
218 #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
219 #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
220 #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
221 #define d_log(x) (log(*(x)))
222 #define d_mod(x, y) (fmod(*(x), *(y)))
223 #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
224 #define d_nint(x) u_nint(*(x))
225 #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
226 #define d_sign(a,b) u_sign(*(a),*(b))
227 #define r_sign(a,b) u_sign(*(a),*(b))
228 #define d_sin(x) (sin(*(x)))
229 #define d_sinh(x) (sinh(*(x)))
230 #define d_sqrt(x) (sqrt(*(x)))
231 #define d_tan(x) (tan(*(x)))
232 #define d_tanh(x) (tanh(*(x)))
233 #define i_abs(x) abs(*(x))
234 #define i_dnnt(x) ((integer)u_nint(*(x)))
235 #define i_len(s, n) (n)
236 #define i_nint(x) ((integer)u_nint(*(x)))
237 #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
238 #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
239 #define pow_si(B,E) spow_ui(*(B),*(E))
240 #define pow_ri(B,E) spow_ui(*(B),*(E))
241 #define pow_di(B,E) dpow_ui(*(B),*(E))
242 #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
243 #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
244 #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
245 #define s_cat(lpp, rpp, rnp, np, llp) {         ftnlen i, nc, ll; char *f__rp, *lp;     ll = (llp); lp = (lpp);         for(i=0; i < (int)*(np); ++i) {                 nc = ll;                if((rnp)[i] < nc) nc = (rnp)[i];                ll -= nc;               f__rp = (rpp)[i];               while(--nc >= 0) *lp++ = *(f__rp)++;         }  while(--ll >= 0) *lp++ = ' '; }
246 #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
247 #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
248 #define sig_die(s, kill) { exit(1); }
249 #define s_stop(s, n) {exit(0);}
250 static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
251 #define z_abs(z) (cabs(Cd(z)))
252 #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
253 #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
254 #define myexit_() break;
255 #define mycycle() continue;
256 #define myceiling(w) {ceil(w)}
257 #define myhuge(w) {HUGE_VAL}
258 //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
259 #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
260
261 /* procedure parameter types for -A and -C++ */
262
263 #define F2C_proc_par_types 1
264 #ifdef __cplusplus
265 typedef logical (*L_fp)(...);
266 #else
267 typedef logical (*L_fp)();
268 #endif
269
270 static float spow_ui(float x, integer n) {
271         float pow=1.0; unsigned long int u;
272         if(n != 0) {
273                 if(n < 0) n = -n, x = 1/x;
274                 for(u = n; ; ) {
275                         if(u & 01) pow *= x;
276                         if(u >>= 1) x *= x;
277                         else break;
278                 }
279         }
280         return pow;
281 }
282 static double dpow_ui(double x, integer n) {
283         double pow=1.0; unsigned long int u;
284         if(n != 0) {
285                 if(n < 0) n = -n, x = 1/x;
286                 for(u = n; ; ) {
287                         if(u & 01) pow *= x;
288                         if(u >>= 1) x *= x;
289                         else break;
290                 }
291         }
292         return pow;
293 }
294 #ifdef _MSC_VER
295 static _Fcomplex cpow_ui(complex x, integer n) {
296         complex pow={1.0,0.0}; unsigned long int u;
297                 if(n != 0) {
298                 if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
299                 for(u = n; ; ) {
300                         if(u & 01) pow.r *= x.r, pow.i *= x.i;
301                         if(u >>= 1) x.r *= x.r, x.i *= x.i;
302                         else break;
303                 }
304         }
305         _Fcomplex p={pow.r, pow.i};
306         return p;
307 }
308 #else
309 static _Complex float cpow_ui(_Complex float x, integer n) {
310         _Complex float pow=1.0; unsigned long int u;
311         if(n != 0) {
312                 if(n < 0) n = -n, x = 1/x;
313                 for(u = n; ; ) {
314                         if(u & 01) pow *= x;
315                         if(u >>= 1) x *= x;
316                         else break;
317                 }
318         }
319         return pow;
320 }
321 #endif
322 #ifdef _MSC_VER
323 static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
324         _Dcomplex pow={1.0,0.0}; unsigned long int u;
325         if(n != 0) {
326                 if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
327                 for(u = n; ; ) {
328                         if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
329                         if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
330                         else break;
331                 }
332         }
333         _Dcomplex p = {pow._Val[0], pow._Val[1]};
334         return p;
335 }
336 #else
337 static _Complex double zpow_ui(_Complex double x, integer n) {
338         _Complex double pow=1.0; unsigned long int u;
339         if(n != 0) {
340                 if(n < 0) n = -n, x = 1/x;
341                 for(u = n; ; ) {
342                         if(u & 01) pow *= x;
343                         if(u >>= 1) x *= x;
344                         else break;
345                 }
346         }
347         return pow;
348 }
349 #endif
350 static integer pow_ii(integer x, integer n) {
351         integer pow; unsigned long int u;
352         if (n <= 0) {
353                 if (n == 0 || x == 1) pow = 1;
354                 else if (x != -1) pow = x == 0 ? 1/x : 0;
355                 else n = -n;
356         }
357         if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
358                 u = n;
359                 for(pow = 1; ; ) {
360                         if(u & 01) pow *= x;
361                         if(u >>= 1) x *= x;
362                         else break;
363                 }
364         }
365         return pow;
366 }
367 static integer dmaxloc_(double *w, integer s, integer e, integer *n)
368 {
369         double m; integer i, mi;
370         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371                 if (w[i-1]>m) mi=i ,m=w[i-1];
372         return mi-s+1;
373 }
374 static integer smaxloc_(float *w, integer s, integer e, integer *n)
375 {
376         float m; integer i, mi;
377         for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378                 if (w[i-1]>m) mi=i ,m=w[i-1];
379         return mi-s+1;
380 }
381 static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382         integer n = *n_, incx = *incx_, incy = *incy_, i;
383 #ifdef _MSC_VER
384         _Fcomplex zdotc = {0.0, 0.0};
385         if (incx == 1 && incy == 1) {
386                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387                         zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388                         zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
389                 }
390         } else {
391                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392                         zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393                         zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
394                 }
395         }
396         pCf(z) = zdotc;
397 }
398 #else
399         _Complex float zdotc = 0.0;
400         if (incx == 1 && incy == 1) {
401                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402                         zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
403                 }
404         } else {
405                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406                         zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
407                 }
408         }
409         pCf(z) = zdotc;
410 }
411 #endif
412 static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413         integer n = *n_, incx = *incx_, incy = *incy_, i;
414 #ifdef _MSC_VER
415         _Dcomplex zdotc = {0.0, 0.0};
416         if (incx == 1 && incy == 1) {
417                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418                         zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419                         zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
420                 }
421         } else {
422                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423                         zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424                         zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
425                 }
426         }
427         pCd(z) = zdotc;
428 }
429 #else
430         _Complex double zdotc = 0.0;
431         if (incx == 1 && incy == 1) {
432                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433                         zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
434                 }
435         } else {
436                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437                         zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
438                 }
439         }
440         pCd(z) = zdotc;
441 }
442 #endif  
443 static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444         integer n = *n_, incx = *incx_, incy = *incy_, i;
445 #ifdef _MSC_VER
446         _Fcomplex zdotc = {0.0, 0.0};
447         if (incx == 1 && incy == 1) {
448                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449                         zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450                         zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
451                 }
452         } else {
453                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454                         zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455                         zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
456                 }
457         }
458         pCf(z) = zdotc;
459 }
460 #else
461         _Complex float zdotc = 0.0;
462         if (incx == 1 && incy == 1) {
463                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464                         zdotc += Cf(&x[i]) * Cf(&y[i]);
465                 }
466         } else {
467                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468                         zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
469                 }
470         }
471         pCf(z) = zdotc;
472 }
473 #endif
474 static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475         integer n = *n_, incx = *incx_, incy = *incy_, i;
476 #ifdef _MSC_VER
477         _Dcomplex zdotc = {0.0, 0.0};
478         if (incx == 1 && incy == 1) {
479                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480                         zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481                         zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
482                 }
483         } else {
484                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485                         zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486                         zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
487                 }
488         }
489         pCd(z) = zdotc;
490 }
491 #else
492         _Complex double zdotc = 0.0;
493         if (incx == 1 && incy == 1) {
494                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495                         zdotc += Cd(&x[i]) * Cd(&y[i]);
496                 }
497         } else {
498                 for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499                         zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
500                 }
501         }
502         pCd(z) = zdotc;
503 }
504 #endif
505 /*  -- translated by f2c (version 20000121).
506    You must link the resulting object file with the libraries:
507         -lf2c -lm   (in that order)
508 */
509
510
511
512
513 /* Table of constant values */
514
515 static doublereal c_b12 = 1.;
516 static doublereal c_b20 = 0.;
517 static doublereal c_b27 = -1.;
518
519 /* > \brief \b DTPRFB applies a real or complex "triangular-pentagonal" blocked reflector to a real or complex
520  matrix, which is composed of two blocks. */
521
522 /*  =========== DOCUMENTATION =========== */
523
524 /* Online html documentation available at */
525 /*            http://www.netlib.org/lapack/explore-html/ */
526
527 /* > \htmlonly */
528 /* > Download DTPRFB + dependencies */
529 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtprfb.
530 f"> */
531 /* > [TGZ]</a> */
532 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtprfb.
533 f"> */
534 /* > [ZIP]</a> */
535 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtprfb.
536 f"> */
537 /* > [TXT]</a> */
538 /* > \endhtmlonly */
539
540 /*  Definition: */
541 /*  =========== */
542
543 /*       SUBROUTINE DTPRFB( SIDE, TRANS, DIRECT, STOREV, M, N, K, L, */
544 /*                          V, LDV, T, LDT, A, LDA, B, LDB, WORK, LDWORK ) */
545
546 /*       CHARACTER DIRECT, SIDE, STOREV, TRANS */
547 /*       INTEGER   K, L, LDA, LDB, LDT, LDV, LDWORK, M, N */
548 /*       DOUBLE PRECISION   A( LDA, * ), B( LDB, * ), T( LDT, * ), */
549 /*      $          V( LDV, * ), WORK( LDWORK, * ) */
550
551
552 /* > \par Purpose: */
553 /*  ============= */
554 /* > */
555 /* > \verbatim */
556 /* > */
557 /* > DTPRFB applies a real "triangular-pentagonal" block reflector H or its */
558 /* > transpose H**T to a real matrix C, which is composed of two */
559 /* > blocks A and B, either from the left or right. */
560 /* > */
561 /* > \endverbatim */
562
563 /*  Arguments: */
564 /*  ========== */
565
566 /* > \param[in] SIDE */
567 /* > \verbatim */
568 /* >          SIDE is CHARACTER*1 */
569 /* >          = 'L': apply H or H**T from the Left */
570 /* >          = 'R': apply H or H**T from the Right */
571 /* > \endverbatim */
572 /* > */
573 /* > \param[in] TRANS */
574 /* > \verbatim */
575 /* >          TRANS is CHARACTER*1 */
576 /* >          = 'N': apply H (No transpose) */
577 /* >          = 'T': apply H**T (Transpose) */
578 /* > \endverbatim */
579 /* > */
580 /* > \param[in] DIRECT */
581 /* > \verbatim */
582 /* >          DIRECT is CHARACTER*1 */
583 /* >          Indicates how H is formed from a product of elementary */
584 /* >          reflectors */
585 /* >          = 'F': H = H(1) H(2) . . . H(k) (Forward) */
586 /* >          = 'B': H = H(k) . . . H(2) H(1) (Backward) */
587 /* > \endverbatim */
588 /* > */
589 /* > \param[in] STOREV */
590 /* > \verbatim */
591 /* >          STOREV is CHARACTER*1 */
592 /* >          Indicates how the vectors which define the elementary */
593 /* >          reflectors are stored: */
594 /* >          = 'C': Columns */
595 /* >          = 'R': Rows */
596 /* > \endverbatim */
597 /* > */
598 /* > \param[in] M */
599 /* > \verbatim */
600 /* >          M is INTEGER */
601 /* >          The number of rows of the matrix B. */
602 /* >          M >= 0. */
603 /* > \endverbatim */
604 /* > */
605 /* > \param[in] N */
606 /* > \verbatim */
607 /* >          N is INTEGER */
608 /* >          The number of columns of the matrix B. */
609 /* >          N >= 0. */
610 /* > \endverbatim */
611 /* > */
612 /* > \param[in] K */
613 /* > \verbatim */
614 /* >          K is INTEGER */
615 /* >          The order of the matrix T, i.e. the number of elementary */
616 /* >          reflectors whose product defines the block reflector. */
617 /* >          K >= 0. */
618 /* > \endverbatim */
619 /* > */
620 /* > \param[in] L */
621 /* > \verbatim */
622 /* >          L is INTEGER */
623 /* >          The order of the trapezoidal part of V. */
624 /* >          K >= L >= 0.  See Further Details. */
625 /* > \endverbatim */
626 /* > */
627 /* > \param[in] V */
628 /* > \verbatim */
629 /* >          V is DOUBLE PRECISION array, dimension */
630 /* >                                (LDV,K) if STOREV = 'C' */
631 /* >                                (LDV,M) if STOREV = 'R' and SIDE = 'L' */
632 /* >                                (LDV,N) if STOREV = 'R' and SIDE = 'R' */
633 /* >          The pentagonal matrix V, which contains the elementary reflectors */
634 /* >          H(1), H(2), ..., H(K).  See Further Details. */
635 /* > \endverbatim */
636 /* > */
637 /* > \param[in] LDV */
638 /* > \verbatim */
639 /* >          LDV is INTEGER */
640 /* >          The leading dimension of the array V. */
641 /* >          If STOREV = 'C' and SIDE = 'L', LDV >= f2cmax(1,M); */
642 /* >          if STOREV = 'C' and SIDE = 'R', LDV >= f2cmax(1,N); */
643 /* >          if STOREV = 'R', LDV >= K. */
644 /* > \endverbatim */
645 /* > */
646 /* > \param[in] T */
647 /* > \verbatim */
648 /* >          T is DOUBLE PRECISION array, dimension (LDT,K) */
649 /* >          The triangular K-by-K matrix T in the representation of the */
650 /* >          block reflector. */
651 /* > \endverbatim */
652 /* > */
653 /* > \param[in] LDT */
654 /* > \verbatim */
655 /* >          LDT is INTEGER */
656 /* >          The leading dimension of the array T. */
657 /* >          LDT >= K. */
658 /* > \endverbatim */
659 /* > */
660 /* > \param[in,out] A */
661 /* > \verbatim */
662 /* >          A is DOUBLE PRECISION array, dimension */
663 /* >          (LDA,N) if SIDE = 'L' or (LDA,K) if SIDE = 'R' */
664 /* >          On entry, the K-by-N or M-by-K matrix A. */
665 /* >          On exit, A is overwritten by the corresponding block of */
666 /* >          H*C or H**T*C or C*H or C*H**T.  See Further Details. */
667 /* > \endverbatim */
668 /* > */
669 /* > \param[in] LDA */
670 /* > \verbatim */
671 /* >          LDA is INTEGER */
672 /* >          The leading dimension of the array A. */
673 /* >          If SIDE = 'L', LDA >= f2cmax(1,K); */
674 /* >          If SIDE = 'R', LDA >= f2cmax(1,M). */
675 /* > \endverbatim */
676 /* > */
677 /* > \param[in,out] B */
678 /* > \verbatim */
679 /* >          B is DOUBLE PRECISION array, dimension (LDB,N) */
680 /* >          On entry, the M-by-N matrix B. */
681 /* >          On exit, B is overwritten by the corresponding block of */
682 /* >          H*C or H**T*C or C*H or C*H**T.  See Further Details. */
683 /* > \endverbatim */
684 /* > */
685 /* > \param[in] LDB */
686 /* > \verbatim */
687 /* >          LDB is INTEGER */
688 /* >          The leading dimension of the array B. */
689 /* >          LDB >= f2cmax(1,M). */
690 /* > \endverbatim */
691 /* > */
692 /* > \param[out] WORK */
693 /* > \verbatim */
694 /* >          WORK is DOUBLE PRECISION array, dimension */
695 /* >          (LDWORK,N) if SIDE = 'L', */
696 /* >          (LDWORK,K) if SIDE = 'R'. */
697 /* > \endverbatim */
698 /* > */
699 /* > \param[in] LDWORK */
700 /* > \verbatim */
701 /* >          LDWORK is INTEGER */
702 /* >          The leading dimension of the array WORK. */
703 /* >          If SIDE = 'L', LDWORK >= K; */
704 /* >          if SIDE = 'R', LDWORK >= M. */
705 /* > \endverbatim */
706
707 /*  Authors: */
708 /*  ======== */
709
710 /* > \author Univ. of Tennessee */
711 /* > \author Univ. of California Berkeley */
712 /* > \author Univ. of Colorado Denver */
713 /* > \author NAG Ltd. */
714
715 /* > \date December 2016 */
716
717 /* > \ingroup doubleOTHERauxiliary */
718
719 /* > \par Further Details: */
720 /*  ===================== */
721 /* > */
722 /* > \verbatim */
723 /* > */
724 /* >  The matrix C is a composite matrix formed from blocks A and B. */
725 /* >  The block B is of size M-by-N; if SIDE = 'R', A is of size M-by-K, */
726 /* >  and if SIDE = 'L', A is of size K-by-N. */
727 /* > */
728 /* >  If SIDE = 'R' and DIRECT = 'F', C = [A B]. */
729 /* > */
730 /* >  If SIDE = 'L' and DIRECT = 'F', C = [A] */
731 /* >                                      [B]. */
732 /* > */
733 /* >  If SIDE = 'R' and DIRECT = 'B', C = [B A]. */
734 /* > */
735 /* >  If SIDE = 'L' and DIRECT = 'B', C = [B] */
736 /* >                                      [A]. */
737 /* > */
738 /* >  The pentagonal matrix V is composed of a rectangular block V1 and a */
739 /* >  trapezoidal block V2.  The size of the trapezoidal block is determined by */
740 /* >  the parameter L, where 0<=L<=K.  If L=K, the V2 block of V is triangular; */
741 /* >  if L=0, there is no trapezoidal block, thus V = V1 is rectangular. */
742 /* > */
743 /* >  If DIRECT = 'F' and STOREV = 'C':  V = [V1] */
744 /* >                                         [V2] */
745 /* >     - V2 is upper trapezoidal (first L rows of K-by-K upper triangular) */
746 /* > */
747 /* >  If DIRECT = 'F' and STOREV = 'R':  V = [V1 V2] */
748 /* > */
749 /* >     - V2 is lower trapezoidal (first L columns of K-by-K lower triangular) */
750 /* > */
751 /* >  If DIRECT = 'B' and STOREV = 'C':  V = [V2] */
752 /* >                                         [V1] */
753 /* >     - V2 is lower trapezoidal (last L rows of K-by-K lower triangular) */
754 /* > */
755 /* >  If DIRECT = 'B' and STOREV = 'R':  V = [V2 V1] */
756 /* > */
757 /* >     - V2 is upper trapezoidal (last L columns of K-by-K upper triangular) */
758 /* > */
759 /* >  If STOREV = 'C' and SIDE = 'L', V is M-by-K with V2 L-by-K. */
760 /* > */
761 /* >  If STOREV = 'C' and SIDE = 'R', V is N-by-K with V2 L-by-K. */
762 /* > */
763 /* >  If STOREV = 'R' and SIDE = 'L', V is K-by-M with V2 K-by-L. */
764 /* > */
765 /* >  If STOREV = 'R' and SIDE = 'R', V is K-by-N with V2 K-by-L. */
766 /* > \endverbatim */
767 /* > */
768 /*  ===================================================================== */
769 /* Subroutine */ int dtprfb_(char *side, char *trans, char *direct, char *
770         storev, integer *m, integer *n, integer *k, integer *l, doublereal *v,
771          integer *ldv, doublereal *t, integer *ldt, doublereal *a, integer *
772         lda, doublereal *b, integer *ldb, doublereal *work, integer *ldwork)
773 {
774     /* System generated locals */
775     integer a_dim1, a_offset, b_dim1, b_offset, t_dim1, t_offset, v_dim1, 
776             v_offset, work_dim1, work_offset, i__1, i__2;
777
778     /* Local variables */
779     logical left, backward;
780     integer i__, j;
781     extern /* Subroutine */ int dgemm_(char *, char *, integer *, integer *, 
782             integer *, doublereal *, doublereal *, integer *, doublereal *, 
783             integer *, doublereal *, doublereal *, integer *);
784     extern logical lsame_(char *, char *);
785     logical right;
786     extern /* Subroutine */ int dtrmm_(char *, char *, char *, char *, 
787             integer *, integer *, doublereal *, doublereal *, integer *, 
788             doublereal *, integer *);
789     integer kp, mp, np;
790     logical column, row, forward;
791
792
793 /*  -- LAPACK auxiliary routine (version 3.7.0) -- */
794 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
795 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
796 /*     December 2016 */
797
798
799 /*  ========================================================================== */
800
801
802 /*     Quick return if possible */
803
804     /* Parameter adjustments */
805     v_dim1 = *ldv;
806     v_offset = 1 + v_dim1 * 1;
807     v -= v_offset;
808     t_dim1 = *ldt;
809     t_offset = 1 + t_dim1 * 1;
810     t -= t_offset;
811     a_dim1 = *lda;
812     a_offset = 1 + a_dim1 * 1;
813     a -= a_offset;
814     b_dim1 = *ldb;
815     b_offset = 1 + b_dim1 * 1;
816     b -= b_offset;
817     work_dim1 = *ldwork;
818     work_offset = 1 + work_dim1 * 1;
819     work -= work_offset;
820
821     /* Function Body */
822     if (*m <= 0 || *n <= 0 || *k <= 0 || *l < 0) {
823         return 0;
824     }
825
826     if (lsame_(storev, "C")) {
827         column = TRUE_;
828         row = FALSE_;
829     } else if (lsame_(storev, "R")) {
830         column = FALSE_;
831         row = TRUE_;
832     } else {
833         column = FALSE_;
834         row = FALSE_;
835     }
836
837     if (lsame_(side, "L")) {
838         left = TRUE_;
839         right = FALSE_;
840     } else if (lsame_(side, "R")) {
841         left = FALSE_;
842         right = TRUE_;
843     } else {
844         left = FALSE_;
845         right = FALSE_;
846     }
847
848     if (lsame_(direct, "F")) {
849         forward = TRUE_;
850         backward = FALSE_;
851     } else if (lsame_(direct, "B")) {
852         forward = FALSE_;
853         backward = TRUE_;
854     } else {
855         forward = FALSE_;
856         backward = FALSE_;
857     }
858
859 /* --------------------------------------------------------------------------- */
860
861     if (column && forward && left) {
862
863 /* --------------------------------------------------------------------------- */
864
865 /*        Let  W =  [ I ]    (K-by-K) */
866 /*                  [ V ]    (M-by-K) */
867
868 /*        Form  H C  or  H**T C  where  C = [ A ]  (K-by-N) */
869 /*                                          [ B ]  (M-by-N) */
870
871 /*        H = I - W T W**T          or  H**T = I - W T**T W**T */
872
873 /*        A = A -   T (A + V**T B)  or  A = A -   T**T (A + V**T B) */
874 /*        B = B - V T (A + V**T B)  or  B = B - V T**T (A + V**T B) */
875
876 /* --------------------------------------------------------------------------- */
877
878 /* Computing MIN */
879         i__1 = *m - *l + 1;
880         mp = f2cmin(i__1,*m);
881 /* Computing MIN */
882         i__1 = *l + 1;
883         kp = f2cmin(i__1,*k);
884
885         i__1 = *n;
886         for (j = 1; j <= i__1; ++j) {
887             i__2 = *l;
888             for (i__ = 1; i__ <= i__2; ++i__) {
889                 work[i__ + j * work_dim1] = b[*m - *l + i__ + j * b_dim1];
890             }
891         }
892         dtrmm_("L", "U", "T", "N", l, n, &c_b12, &v[mp + v_dim1], ldv, &work[
893                 work_offset], ldwork);
894         i__1 = *m - *l;
895         dgemm_("T", "N", l, n, &i__1, &c_b12, &v[v_offset], ldv, &b[b_offset],
896                  ldb, &c_b12, &work[work_offset], ldwork);
897         i__1 = *k - *l;
898         dgemm_("T", "N", &i__1, n, m, &c_b12, &v[kp * v_dim1 + 1], ldv, &b[
899                 b_offset], ldb, &c_b20, &work[kp + work_dim1], ldwork);
900
901         i__1 = *n;
902         for (j = 1; j <= i__1; ++j) {
903             i__2 = *k;
904             for (i__ = 1; i__ <= i__2; ++i__) {
905                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
906             }
907         }
908
909         dtrmm_("L", "U", trans, "N", k, n, &c_b12, &t[t_offset], ldt, &work[
910                 work_offset], ldwork);
911
912         i__1 = *n;
913         for (j = 1; j <= i__1; ++j) {
914             i__2 = *k;
915             for (i__ = 1; i__ <= i__2; ++i__) {
916                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
917             }
918         }
919
920         i__1 = *m - *l;
921         dgemm_("N", "N", &i__1, n, k, &c_b27, &v[v_offset], ldv, &work[
922                 work_offset], ldwork, &c_b12, &b[b_offset], ldb);
923         i__1 = *k - *l;
924         dgemm_("N", "N", l, n, &i__1, &c_b27, &v[mp + kp * v_dim1], ldv, &
925                 work[kp + work_dim1], ldwork, &c_b12, &b[mp + b_dim1], ldb);
926         dtrmm_("L", "U", "N", "N", l, n, &c_b12, &v[mp + v_dim1], ldv, &work[
927                 work_offset], ldwork);
928         i__1 = *n;
929         for (j = 1; j <= i__1; ++j) {
930             i__2 = *l;
931             for (i__ = 1; i__ <= i__2; ++i__) {
932                 b[*m - *l + i__ + j * b_dim1] -= work[i__ + j * work_dim1];
933             }
934         }
935
936 /* --------------------------------------------------------------------------- */
937
938     } else if (column && forward && right) {
939
940 /* --------------------------------------------------------------------------- */
941
942 /*        Let  W =  [ I ]    (K-by-K) */
943 /*                  [ V ]    (N-by-K) */
944
945 /*        Form  C H or  C H**T  where  C = [ A B ] (A is M-by-K, B is M-by-N) */
946
947 /*        H = I - W T W**T          or  H**T = I - W T**T W**T */
948
949 /*        A = A - (A + B V) T      or  A = A - (A + B V) T**T */
950 /*        B = B - (A + B V) T V**T  or  B = B - (A + B V) T**T V**T */
951
952 /* --------------------------------------------------------------------------- */
953
954 /* Computing MIN */
955         i__1 = *n - *l + 1;
956         np = f2cmin(i__1,*n);
957 /* Computing MIN */
958         i__1 = *l + 1;
959         kp = f2cmin(i__1,*k);
960
961         i__1 = *l;
962         for (j = 1; j <= i__1; ++j) {
963             i__2 = *m;
964             for (i__ = 1; i__ <= i__2; ++i__) {
965                 work[i__ + j * work_dim1] = b[i__ + (*n - *l + j) * b_dim1];
966             }
967         }
968         dtrmm_("R", "U", "N", "N", m, l, &c_b12, &v[np + v_dim1], ldv, &work[
969                 work_offset], ldwork);
970         i__1 = *n - *l;
971         dgemm_("N", "N", m, l, &i__1, &c_b12, &b[b_offset], ldb, &v[v_offset],
972                  ldv, &c_b12, &work[work_offset], ldwork);
973         i__1 = *k - *l;
974         dgemm_("N", "N", m, &i__1, n, &c_b12, &b[b_offset], ldb, &v[kp * 
975                 v_dim1 + 1], ldv, &c_b20, &work[kp * work_dim1 + 1], ldwork);
976
977         i__1 = *k;
978         for (j = 1; j <= i__1; ++j) {
979             i__2 = *m;
980             for (i__ = 1; i__ <= i__2; ++i__) {
981                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
982             }
983         }
984
985         dtrmm_("R", "U", trans, "N", m, k, &c_b12, &t[t_offset], ldt, &work[
986                 work_offset], ldwork);
987
988         i__1 = *k;
989         for (j = 1; j <= i__1; ++j) {
990             i__2 = *m;
991             for (i__ = 1; i__ <= i__2; ++i__) {
992                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
993             }
994         }
995
996         i__1 = *n - *l;
997         dgemm_("N", "T", m, &i__1, k, &c_b27, &work[work_offset], ldwork, &v[
998                 v_offset], ldv, &c_b12, &b[b_offset], ldb);
999         i__1 = *k - *l;
1000         dgemm_("N", "T", m, l, &i__1, &c_b27, &work[kp * work_dim1 + 1], 
1001                 ldwork, &v[np + kp * v_dim1], ldv, &c_b12, &b[np * b_dim1 + 1]
1002                 , ldb);
1003         dtrmm_("R", "U", "T", "N", m, l, &c_b12, &v[np + v_dim1], ldv, &work[
1004                 work_offset], ldwork);
1005         i__1 = *l;
1006         for (j = 1; j <= i__1; ++j) {
1007             i__2 = *m;
1008             for (i__ = 1; i__ <= i__2; ++i__) {
1009                 b[i__ + (*n - *l + j) * b_dim1] -= work[i__ + j * work_dim1];
1010             }
1011         }
1012
1013 /* --------------------------------------------------------------------------- */
1014
1015     } else if (column && backward && left) {
1016
1017 /* --------------------------------------------------------------------------- */
1018
1019 /*        Let  W =  [ V ]    (M-by-K) */
1020 /*                  [ I ]    (K-by-K) */
1021
1022 /*        Form  H C  or  H**T C  where  C = [ B ]  (M-by-N) */
1023 /*                                          [ A ]  (K-by-N) */
1024
1025 /*        H = I - W T W**T          or  H**T = I - W T**T W**T */
1026
1027 /*        A = A -   T (A + V**T B)  or  A = A -   T**T (A + V**T B) */
1028 /*        B = B - V T (A + V**T B)  or  B = B - V T**T (A + V**T B) */
1029
1030 /* --------------------------------------------------------------------------- */
1031
1032 /* Computing MIN */
1033         i__1 = *l + 1;
1034         mp = f2cmin(i__1,*m);
1035 /* Computing MIN */
1036         i__1 = *k - *l + 1;
1037         kp = f2cmin(i__1,*k);
1038
1039         i__1 = *n;
1040         for (j = 1; j <= i__1; ++j) {
1041             i__2 = *l;
1042             for (i__ = 1; i__ <= i__2; ++i__) {
1043                 work[*k - *l + i__ + j * work_dim1] = b[i__ + j * b_dim1];
1044             }
1045         }
1046
1047         dtrmm_("L", "L", "T", "N", l, n, &c_b12, &v[kp * v_dim1 + 1], ldv, &
1048                 work[kp + work_dim1], ldwork);
1049         i__1 = *m - *l;
1050         dgemm_("T", "N", l, n, &i__1, &c_b12, &v[mp + kp * v_dim1], ldv, &b[
1051                 mp + b_dim1], ldb, &c_b12, &work[kp + work_dim1], ldwork);
1052         i__1 = *k - *l;
1053         dgemm_("T", "N", &i__1, n, m, &c_b12, &v[v_offset], ldv, &b[b_offset],
1054                  ldb, &c_b20, &work[work_offset], ldwork);
1055
1056         i__1 = *n;
1057         for (j = 1; j <= i__1; ++j) {
1058             i__2 = *k;
1059             for (i__ = 1; i__ <= i__2; ++i__) {
1060                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
1061             }
1062         }
1063
1064         dtrmm_("L", "L", trans, "N", k, n, &c_b12, &t[t_offset], ldt, &work[
1065                 work_offset], ldwork);
1066
1067         i__1 = *n;
1068         for (j = 1; j <= i__1; ++j) {
1069             i__2 = *k;
1070             for (i__ = 1; i__ <= i__2; ++i__) {
1071                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
1072             }
1073         }
1074
1075         i__1 = *m - *l;
1076         dgemm_("N", "N", &i__1, n, k, &c_b27, &v[mp + v_dim1], ldv, &work[
1077                 work_offset], ldwork, &c_b12, &b[mp + b_dim1], ldb);
1078         i__1 = *k - *l;
1079         dgemm_("N", "N", l, n, &i__1, &c_b27, &v[v_offset], ldv, &work[
1080                 work_offset], ldwork, &c_b12, &b[b_offset], ldb);
1081         dtrmm_("L", "L", "N", "N", l, n, &c_b12, &v[kp * v_dim1 + 1], ldv, &
1082                 work[kp + work_dim1], ldwork);
1083         i__1 = *n;
1084         for (j = 1; j <= i__1; ++j) {
1085             i__2 = *l;
1086             for (i__ = 1; i__ <= i__2; ++i__) {
1087                 b[i__ + j * b_dim1] -= work[*k - *l + i__ + j * work_dim1];
1088             }
1089         }
1090
1091 /* --------------------------------------------------------------------------- */
1092
1093     } else if (column && backward && right) {
1094
1095 /* --------------------------------------------------------------------------- */
1096
1097 /*        Let  W =  [ V ]    (N-by-K) */
1098 /*                  [ I ]    (K-by-K) */
1099
1100 /*        Form  C H  or  C H**T  where  C = [ B A ] (B is M-by-N, A is M-by-K) */
1101
1102 /*        H = I - W T W**T          or  H**T = I - W T**T W**T */
1103
1104 /*        A = A - (A + B V) T      or  A = A - (A + B V) T**T */
1105 /*        B = B - (A + B V) T V**T  or  B = B - (A + B V) T**T V**T */
1106
1107 /* --------------------------------------------------------------------------- */
1108
1109 /* Computing MIN */
1110         i__1 = *l + 1;
1111         np = f2cmin(i__1,*n);
1112 /* Computing MIN */
1113         i__1 = *k - *l + 1;
1114         kp = f2cmin(i__1,*k);
1115
1116         i__1 = *l;
1117         for (j = 1; j <= i__1; ++j) {
1118             i__2 = *m;
1119             for (i__ = 1; i__ <= i__2; ++i__) {
1120                 work[i__ + (*k - *l + j) * work_dim1] = b[i__ + j * b_dim1];
1121             }
1122         }
1123         dtrmm_("R", "L", "N", "N", m, l, &c_b12, &v[kp * v_dim1 + 1], ldv, &
1124                 work[kp * work_dim1 + 1], ldwork);
1125         i__1 = *n - *l;
1126         dgemm_("N", "N", m, l, &i__1, &c_b12, &b[np * b_dim1 + 1], ldb, &v[np 
1127                 + kp * v_dim1], ldv, &c_b12, &work[kp * work_dim1 + 1], 
1128                 ldwork);
1129         i__1 = *k - *l;
1130         dgemm_("N", "N", m, &i__1, n, &c_b12, &b[b_offset], ldb, &v[v_offset],
1131                  ldv, &c_b20, &work[work_offset], ldwork);
1132
1133         i__1 = *k;
1134         for (j = 1; j <= i__1; ++j) {
1135             i__2 = *m;
1136             for (i__ = 1; i__ <= i__2; ++i__) {
1137                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
1138             }
1139         }
1140
1141         dtrmm_("R", "L", trans, "N", m, k, &c_b12, &t[t_offset], ldt, &work[
1142                 work_offset], ldwork);
1143
1144         i__1 = *k;
1145         for (j = 1; j <= i__1; ++j) {
1146             i__2 = *m;
1147             for (i__ = 1; i__ <= i__2; ++i__) {
1148                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
1149             }
1150         }
1151
1152         i__1 = *n - *l;
1153         dgemm_("N", "T", m, &i__1, k, &c_b27, &work[work_offset], ldwork, &v[
1154                 np + v_dim1], ldv, &c_b12, &b[np * b_dim1 + 1], ldb);
1155         i__1 = *k - *l;
1156         dgemm_("N", "T", m, l, &i__1, &c_b27, &work[work_offset], ldwork, &v[
1157                 v_offset], ldv, &c_b12, &b[b_offset], ldb);
1158         dtrmm_("R", "L", "T", "N", m, l, &c_b12, &v[kp * v_dim1 + 1], ldv, &
1159                 work[kp * work_dim1 + 1], ldwork);
1160         i__1 = *l;
1161         for (j = 1; j <= i__1; ++j) {
1162             i__2 = *m;
1163             for (i__ = 1; i__ <= i__2; ++i__) {
1164                 b[i__ + j * b_dim1] -= work[i__ + (*k - *l + j) * work_dim1];
1165             }
1166         }
1167
1168 /* --------------------------------------------------------------------------- */
1169
1170     } else if (row && forward && left) {
1171
1172 /* --------------------------------------------------------------------------- */
1173
1174 /*        Let  W =  [ I V ] ( I is K-by-K, V is K-by-M ) */
1175
1176 /*        Form  H C  or  H**T C  where  C = [ A ]  (K-by-N) */
1177 /*                                          [ B ]  (M-by-N) */
1178
1179 /*        H = I - W**T T W          or  H**T = I - W**T T**T W */
1180
1181 /*        A = A -     T (A + V B)  or  A = A -     T**T (A + V B) */
1182 /*        B = B - V**T T (A + V B)  or  B = B - V**T T**T (A + V B) */
1183
1184 /* --------------------------------------------------------------------------- */
1185
1186 /* Computing MIN */
1187         i__1 = *m - *l + 1;
1188         mp = f2cmin(i__1,*m);
1189 /* Computing MIN */
1190         i__1 = *l + 1;
1191         kp = f2cmin(i__1,*k);
1192
1193         i__1 = *n;
1194         for (j = 1; j <= i__1; ++j) {
1195             i__2 = *l;
1196             for (i__ = 1; i__ <= i__2; ++i__) {
1197                 work[i__ + j * work_dim1] = b[*m - *l + i__ + j * b_dim1];
1198             }
1199         }
1200         dtrmm_("L", "L", "N", "N", l, n, &c_b12, &v[mp * v_dim1 + 1], ldv, &
1201                 work[work_offset], ldb);
1202         i__1 = *m - *l;
1203         dgemm_("N", "N", l, n, &i__1, &c_b12, &v[v_offset], ldv, &b[b_offset],
1204                  ldb, &c_b12, &work[work_offset], ldwork);
1205         i__1 = *k - *l;
1206         dgemm_("N", "N", &i__1, n, m, &c_b12, &v[kp + v_dim1], ldv, &b[
1207                 b_offset], ldb, &c_b20, &work[kp + work_dim1], ldwork);
1208
1209         i__1 = *n;
1210         for (j = 1; j <= i__1; ++j) {
1211             i__2 = *k;
1212             for (i__ = 1; i__ <= i__2; ++i__) {
1213                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
1214             }
1215         }
1216
1217         dtrmm_("L", "U", trans, "N", k, n, &c_b12, &t[t_offset], ldt, &work[
1218                 work_offset], ldwork);
1219
1220         i__1 = *n;
1221         for (j = 1; j <= i__1; ++j) {
1222             i__2 = *k;
1223             for (i__ = 1; i__ <= i__2; ++i__) {
1224                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
1225             }
1226         }
1227
1228         i__1 = *m - *l;
1229         dgemm_("T", "N", &i__1, n, k, &c_b27, &v[v_offset], ldv, &work[
1230                 work_offset], ldwork, &c_b12, &b[b_offset], ldb);
1231         i__1 = *k - *l;
1232         dgemm_("T", "N", l, n, &i__1, &c_b27, &v[kp + mp * v_dim1], ldv, &
1233                 work[kp + work_dim1], ldwork, &c_b12, &b[mp + b_dim1], ldb);
1234         dtrmm_("L", "L", "T", "N", l, n, &c_b12, &v[mp * v_dim1 + 1], ldv, &
1235                 work[work_offset], ldwork);
1236         i__1 = *n;
1237         for (j = 1; j <= i__1; ++j) {
1238             i__2 = *l;
1239             for (i__ = 1; i__ <= i__2; ++i__) {
1240                 b[*m - *l + i__ + j * b_dim1] -= work[i__ + j * work_dim1];
1241             }
1242         }
1243
1244 /* --------------------------------------------------------------------------- */
1245
1246     } else if (row && forward && right) {
1247
1248 /* --------------------------------------------------------------------------- */
1249
1250 /*        Let  W =  [ I V ] ( I is K-by-K, V is K-by-N ) */
1251
1252 /*        Form  C H  or  C H**T  where  C = [ A B ] (A is M-by-K, B is M-by-N) */
1253
1254 /*        H = I - W**T T W            or  H**T = I - W**T T**T W */
1255
1256 /*        A = A - (A + B V**T) T      or  A = A - (A + B V**T) T**T */
1257 /*        B = B - (A + B V**T) T V    or  B = B - (A + B V**T) T**T V */
1258
1259 /* --------------------------------------------------------------------------- */
1260
1261 /* Computing MIN */
1262         i__1 = *n - *l + 1;
1263         np = f2cmin(i__1,*n);
1264 /* Computing MIN */
1265         i__1 = *l + 1;
1266         kp = f2cmin(i__1,*k);
1267
1268         i__1 = *l;
1269         for (j = 1; j <= i__1; ++j) {
1270             i__2 = *m;
1271             for (i__ = 1; i__ <= i__2; ++i__) {
1272                 work[i__ + j * work_dim1] = b[i__ + (*n - *l + j) * b_dim1];
1273             }
1274         }
1275         dtrmm_("R", "L", "T", "N", m, l, &c_b12, &v[np * v_dim1 + 1], ldv, &
1276                 work[work_offset], ldwork);
1277         i__1 = *n - *l;
1278         dgemm_("N", "T", m, l, &i__1, &c_b12, &b[b_offset], ldb, &v[v_offset],
1279                  ldv, &c_b12, &work[work_offset], ldwork);
1280         i__1 = *k - *l;
1281         dgemm_("N", "T", m, &i__1, n, &c_b12, &b[b_offset], ldb, &v[kp + 
1282                 v_dim1], ldv, &c_b20, &work[kp * work_dim1 + 1], ldwork);
1283
1284         i__1 = *k;
1285         for (j = 1; j <= i__1; ++j) {
1286             i__2 = *m;
1287             for (i__ = 1; i__ <= i__2; ++i__) {
1288                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
1289             }
1290         }
1291
1292         dtrmm_("R", "U", trans, "N", m, k, &c_b12, &t[t_offset], ldt, &work[
1293                 work_offset], ldwork);
1294
1295         i__1 = *k;
1296         for (j = 1; j <= i__1; ++j) {
1297             i__2 = *m;
1298             for (i__ = 1; i__ <= i__2; ++i__) {
1299                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
1300             }
1301         }
1302
1303         i__1 = *n - *l;
1304         dgemm_("N", "N", m, &i__1, k, &c_b27, &work[work_offset], ldwork, &v[
1305                 v_offset], ldv, &c_b12, &b[b_offset], ldb);
1306         i__1 = *k - *l;
1307         dgemm_("N", "N", m, l, &i__1, &c_b27, &work[kp * work_dim1 + 1], 
1308                 ldwork, &v[kp + np * v_dim1], ldv, &c_b12, &b[np * b_dim1 + 1]
1309                 , ldb);
1310         dtrmm_("R", "L", "N", "N", m, l, &c_b12, &v[np * v_dim1 + 1], ldv, &
1311                 work[work_offset], ldwork);
1312         i__1 = *l;
1313         for (j = 1; j <= i__1; ++j) {
1314             i__2 = *m;
1315             for (i__ = 1; i__ <= i__2; ++i__) {
1316                 b[i__ + (*n - *l + j) * b_dim1] -= work[i__ + j * work_dim1];
1317             }
1318         }
1319
1320 /* --------------------------------------------------------------------------- */
1321
1322     } else if (row && backward && left) {
1323
1324 /* --------------------------------------------------------------------------- */
1325
1326 /*        Let  W =  [ V I ] ( I is K-by-K, V is K-by-M ) */
1327
1328 /*        Form  H C  or  H**T C  where  C = [ B ]  (M-by-N) */
1329 /*                                          [ A ]  (K-by-N) */
1330
1331 /*        H = I - W**T T W          or  H**T = I - W**T T**T W */
1332
1333 /*        A = A -     T (A + V B)  or  A = A -     T**T (A + V B) */
1334 /*        B = B - V**T T (A + V B)  or  B = B - V**T T**T (A + V B) */
1335
1336 /* --------------------------------------------------------------------------- */
1337
1338 /* Computing MIN */
1339         i__1 = *l + 1;
1340         mp = f2cmin(i__1,*m);
1341 /* Computing MIN */
1342         i__1 = *k - *l + 1;
1343         kp = f2cmin(i__1,*k);
1344
1345         i__1 = *n;
1346         for (j = 1; j <= i__1; ++j) {
1347             i__2 = *l;
1348             for (i__ = 1; i__ <= i__2; ++i__) {
1349                 work[*k - *l + i__ + j * work_dim1] = b[i__ + j * b_dim1];
1350             }
1351         }
1352         dtrmm_("L", "U", "N", "N", l, n, &c_b12, &v[kp + v_dim1], ldv, &work[
1353                 kp + work_dim1], ldwork);
1354         i__1 = *m - *l;
1355         dgemm_("N", "N", l, n, &i__1, &c_b12, &v[kp + mp * v_dim1], ldv, &b[
1356                 mp + b_dim1], ldb, &c_b12, &work[kp + work_dim1], ldwork);
1357         i__1 = *k - *l;
1358         dgemm_("N", "N", &i__1, n, m, &c_b12, &v[v_offset], ldv, &b[b_offset],
1359                  ldb, &c_b20, &work[work_offset], ldwork);
1360
1361         i__1 = *n;
1362         for (j = 1; j <= i__1; ++j) {
1363             i__2 = *k;
1364             for (i__ = 1; i__ <= i__2; ++i__) {
1365                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
1366             }
1367         }
1368
1369         dtrmm_("L", "L ", trans, "N", k, n, &c_b12, &t[t_offset], ldt, &work[
1370                 work_offset], ldwork);
1371
1372         i__1 = *n;
1373         for (j = 1; j <= i__1; ++j) {
1374             i__2 = *k;
1375             for (i__ = 1; i__ <= i__2; ++i__) {
1376                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
1377             }
1378         }
1379
1380         i__1 = *m - *l;
1381         dgemm_("T", "N", &i__1, n, k, &c_b27, &v[mp * v_dim1 + 1], ldv, &work[
1382                 work_offset], ldwork, &c_b12, &b[mp + b_dim1], ldb);
1383         i__1 = *k - *l;
1384         dgemm_("T", "N", l, n, &i__1, &c_b27, &v[v_offset], ldv, &work[
1385                 work_offset], ldwork, &c_b12, &b[b_offset], ldb);
1386         dtrmm_("L", "U", "T", "N", l, n, &c_b12, &v[kp + v_dim1], ldv, &work[
1387                 kp + work_dim1], ldwork);
1388         i__1 = *n;
1389         for (j = 1; j <= i__1; ++j) {
1390             i__2 = *l;
1391             for (i__ = 1; i__ <= i__2; ++i__) {
1392                 b[i__ + j * b_dim1] -= work[*k - *l + i__ + j * work_dim1];
1393             }
1394         }
1395
1396 /* --------------------------------------------------------------------------- */
1397
1398     } else if (row && backward && right) {
1399
1400 /* --------------------------------------------------------------------------- */
1401
1402 /*        Let  W =  [ V I ] ( I is K-by-K, V is K-by-N ) */
1403
1404 /*        Form  C H  or  C H**T  where  C = [ B A ] (A is M-by-K, B is M-by-N) */
1405
1406 /*        H = I - W**T T W            or  H**T = I - W**T T**T W */
1407
1408 /*        A = A - (A + B V**T) T      or  A = A - (A + B V**T) T**T */
1409 /*        B = B - (A + B V**T) T V    or  B = B - (A + B V**T) T**T V */
1410
1411 /* --------------------------------------------------------------------------- */
1412
1413 /* Computing MIN */
1414         i__1 = *l + 1;
1415         np = f2cmin(i__1,*n);
1416 /* Computing MIN */
1417         i__1 = *k - *l + 1;
1418         kp = f2cmin(i__1,*k);
1419
1420         i__1 = *l;
1421         for (j = 1; j <= i__1; ++j) {
1422             i__2 = *m;
1423             for (i__ = 1; i__ <= i__2; ++i__) {
1424                 work[i__ + (*k - *l + j) * work_dim1] = b[i__ + j * b_dim1];
1425             }
1426         }
1427         dtrmm_("R", "U", "T", "N", m, l, &c_b12, &v[kp + v_dim1], ldv, &work[
1428                 kp * work_dim1 + 1], ldwork);
1429         i__1 = *n - *l;
1430         dgemm_("N", "T", m, l, &i__1, &c_b12, &b[np * b_dim1 + 1], ldb, &v[kp 
1431                 + np * v_dim1], ldv, &c_b12, &work[kp * work_dim1 + 1], 
1432                 ldwork);
1433         i__1 = *k - *l;
1434         dgemm_("N", "T", m, &i__1, n, &c_b12, &b[b_offset], ldb, &v[v_offset],
1435                  ldv, &c_b20, &work[work_offset], ldwork);
1436
1437         i__1 = *k;
1438         for (j = 1; j <= i__1; ++j) {
1439             i__2 = *m;
1440             for (i__ = 1; i__ <= i__2; ++i__) {
1441                 work[i__ + j * work_dim1] += a[i__ + j * a_dim1];
1442             }
1443         }
1444
1445         dtrmm_("R", "L", trans, "N", m, k, &c_b12, &t[t_offset], ldt, &work[
1446                 work_offset], ldwork);
1447
1448         i__1 = *k;
1449         for (j = 1; j <= i__1; ++j) {
1450             i__2 = *m;
1451             for (i__ = 1; i__ <= i__2; ++i__) {
1452                 a[i__ + j * a_dim1] -= work[i__ + j * work_dim1];
1453             }
1454         }
1455
1456         i__1 = *n - *l;
1457         dgemm_("N", "N", m, &i__1, k, &c_b27, &work[work_offset], ldwork, &v[
1458                 np * v_dim1 + 1], ldv, &c_b12, &b[np * b_dim1 + 1], ldb);
1459         i__1 = *k - *l;
1460         dgemm_("N", "N", m, l, &i__1, &c_b27, &work[work_offset], ldwork, &v[
1461                 v_offset], ldv, &c_b12, &b[b_offset], ldb);
1462         dtrmm_("R", "U", "N", "N", m, l, &c_b12, &v[kp + v_dim1], ldv, &work[
1463                 kp * work_dim1 + 1], ldwork);
1464         i__1 = *l;
1465         for (j = 1; j <= i__1; ++j) {
1466             i__2 = *m;
1467             for (i__ = 1; i__ <= i__2; ++i__) {
1468                 b[i__ + j * b_dim1] -= work[i__ + (*k - *l + j) * work_dim1];
1469             }
1470         }
1471
1472     }
1473
1474     return 0;
1475
1476 /*     End of DTPRFB */
1477
1478 } /* dtprfb_ */
1479