Coverage Report

Created: 2025-09-11 18:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/contrib/openblas/lapack-netlib/SRC/sgebrd.c
Line
Count
Source
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
0
static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
49
0
static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
50
0
static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
51
0
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 blasint logical;
56
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
0
#define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
182
0
#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 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++ = ' '; }
239
#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
240
#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]; }
241
#define sig_die(s, kill) { exit(1); }
242
#define s_stop(s, n) {exit(0);}
243
#define z_abs(z) (cabs(Cd(z)))
244
#define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
245
#define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
246
#define myexit_() break;
247
#define mycycle() continue;
248
#define myceiling(w) {ceil(w)}
249
#define myhuge(w) {HUGE_VAL}
250
//#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
251
#define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
252
253
/*  -- translated by f2c (version 20000121).
254
   You must link the resulting object file with the libraries:
255
  -lf2c -lm   (in that order)
256
*/
257
258
259
260
261
/* Table of constant values */
262
263
static integer c__1 = 1;
264
static integer c_n1 = -1;
265
static integer c__3 = 3;
266
static integer c__2 = 2;
267
static real c_b21 = -1.f;
268
static real c_b22 = 1.f;
269
270
/* > \brief \b SGEBRD */
271
272
/*  =========== DOCUMENTATION =========== */
273
274
/* Online html documentation available at */
275
/*            http://www.netlib.org/lapack/explore-html/ */
276
277
/* > \htmlonly */
278
/* > Download SGEBRD + dependencies */
279
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgebrd.
280
f"> */
281
/* > [TGZ]</a> */
282
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgebrd.
283
f"> */
284
/* > [ZIP]</a> */
285
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgebrd.
286
f"> */
287
/* > [TXT]</a> */
288
/* > \endhtmlonly */
289
290
/*  Definition: */
291
/*  =========== */
292
293
/*       SUBROUTINE SGEBRD( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, LWORK, */
294
/*                          INFO ) */
295
296
/*       INTEGER            INFO, LDA, LWORK, M, N */
297
/*       REAL               A( LDA, * ), D( * ), E( * ), TAUP( * ), */
298
/*      $                   TAUQ( * ), WORK( * ) */
299
300
301
/* > \par Purpose: */
302
/*  ============= */
303
/* > */
304
/* > \verbatim */
305
/* > */
306
/* > SGEBRD reduces a general real M-by-N matrix A to upper or lower */
307
/* > bidiagonal form B by an orthogonal transformation: Q**T * A * P = B. */
308
/* > */
309
/* > If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */
310
/* > \endverbatim */
311
312
/*  Arguments: */
313
/*  ========== */
314
315
/* > \param[in] M */
316
/* > \verbatim */
317
/* >          M is INTEGER */
318
/* >          The number of rows in the matrix A.  M >= 0. */
319
/* > \endverbatim */
320
/* > */
321
/* > \param[in] N */
322
/* > \verbatim */
323
/* >          N is INTEGER */
324
/* >          The number of columns in the matrix A.  N >= 0. */
325
/* > \endverbatim */
326
/* > */
327
/* > \param[in,out] A */
328
/* > \verbatim */
329
/* >          A is REAL array, dimension (LDA,N) */
330
/* >          On entry, the M-by-N general matrix to be reduced. */
331
/* >          On exit, */
332
/* >          if m >= n, the diagonal and the first superdiagonal are */
333
/* >            overwritten with the upper bidiagonal matrix B; the */
334
/* >            elements below the diagonal, with the array TAUQ, represent */
335
/* >            the orthogonal matrix Q as a product of elementary */
336
/* >            reflectors, and the elements above the first superdiagonal, */
337
/* >            with the array TAUP, represent the orthogonal matrix P as */
338
/* >            a product of elementary reflectors; */
339
/* >          if m < n, the diagonal and the first subdiagonal are */
340
/* >            overwritten with the lower bidiagonal matrix B; the */
341
/* >            elements below the first subdiagonal, with the array TAUQ, */
342
/* >            represent the orthogonal matrix Q as a product of */
343
/* >            elementary reflectors, and the elements above the diagonal, */
344
/* >            with the array TAUP, represent the orthogonal matrix P as */
345
/* >            a product of elementary reflectors. */
346
/* >          See Further Details. */
347
/* > \endverbatim */
348
/* > */
349
/* > \param[in] LDA */
350
/* > \verbatim */
351
/* >          LDA is INTEGER */
352
/* >          The leading dimension of the array A.  LDA >= f2cmax(1,M). */
353
/* > \endverbatim */
354
/* > */
355
/* > \param[out] D */
356
/* > \verbatim */
357
/* >          D is REAL array, dimension (f2cmin(M,N)) */
358
/* >          The diagonal elements of the bidiagonal matrix B: */
359
/* >          D(i) = A(i,i). */
360
/* > \endverbatim */
361
/* > */
362
/* > \param[out] E */
363
/* > \verbatim */
364
/* >          E is REAL array, dimension (f2cmin(M,N)-1) */
365
/* >          The off-diagonal elements of the bidiagonal matrix B: */
366
/* >          if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */
367
/* >          if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */
368
/* > \endverbatim */
369
/* > */
370
/* > \param[out] TAUQ */
371
/* > \verbatim */
372
/* >          TAUQ is REAL array, dimension (f2cmin(M,N)) */
373
/* >          The scalar factors of the elementary reflectors which */
374
/* >          represent the orthogonal matrix Q. See Further Details. */
375
/* > \endverbatim */
376
/* > */
377
/* > \param[out] TAUP */
378
/* > \verbatim */
379
/* >          TAUP is REAL array, dimension (f2cmin(M,N)) */
380
/* >          The scalar factors of the elementary reflectors which */
381
/* >          represent the orthogonal matrix P. See Further Details. */
382
/* > \endverbatim */
383
/* > */
384
/* > \param[out] WORK */
385
/* > \verbatim */
386
/* >          WORK is REAL array, dimension (MAX(1,LWORK)) */
387
/* >          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
388
/* > \endverbatim */
389
/* > */
390
/* > \param[in] LWORK */
391
/* > \verbatim */
392
/* >          LWORK is INTEGER */
393
/* >          The length of the array WORK.  LWORK >= f2cmax(1,M,N). */
394
/* >          For optimum performance LWORK >= (M+N)*NB, where NB */
395
/* >          is the optimal blocksize. */
396
/* > */
397
/* >          If LWORK = -1, then a workspace query is assumed; the routine */
398
/* >          only calculates the optimal size of the WORK array, returns */
399
/* >          this value as the first entry of the WORK array, and no error */
400
/* >          message related to LWORK is issued by XERBLA. */
401
/* > \endverbatim */
402
/* > */
403
/* > \param[out] INFO */
404
/* > \verbatim */
405
/* >          INFO is INTEGER */
406
/* >          = 0:  successful exit */
407
/* >          < 0:  if INFO = -i, the i-th argument had an illegal value. */
408
/* > \endverbatim */
409
410
/*  Authors: */
411
/*  ======== */
412
413
/* > \author Univ. of Tennessee */
414
/* > \author Univ. of California Berkeley */
415
/* > \author Univ. of Colorado Denver */
416
/* > \author NAG Ltd. */
417
418
/* > \date November 2017 */
419
420
/* > \ingroup realGEcomputational */
421
422
/* > \par Further Details: */
423
/*  ===================== */
424
/* > */
425
/* > \verbatim */
426
/* > */
427
/* >  The matrices Q and P are represented as products of elementary */
428
/* >  reflectors: */
429
/* > */
430
/* >  If m >= n, */
431
/* > */
432
/* >     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1) */
433
/* > */
434
/* >  Each H(i) and G(i) has the form: */
435
/* > */
436
/* >     H(i) = I - tauq * v * v**T  and G(i) = I - taup * u * u**T */
437
/* > */
438
/* >  where tauq and taup are real scalars, and v and u are real vectors; */
439
/* >  v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); */
440
/* >  u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); */
441
/* >  tauq is stored in TAUQ(i) and taup in TAUP(i). */
442
/* > */
443
/* >  If m < n, */
444
/* > */
445
/* >     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m) */
446
/* > */
447
/* >  Each H(i) and G(i) has the form: */
448
/* > */
449
/* >     H(i) = I - tauq * v * v**T  and G(i) = I - taup * u * u**T */
450
/* > */
451
/* >  where tauq and taup are real scalars, and v and u are real vectors; */
452
/* >  v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */
453
/* >  u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */
454
/* >  tauq is stored in TAUQ(i) and taup in TAUP(i). */
455
/* > */
456
/* >  The contents of A on exit are illustrated by the following examples: */
457
/* > */
458
/* >  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n): */
459
/* > */
460
/* >    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 ) */
461
/* >    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 ) */
462
/* >    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 ) */
463
/* >    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 ) */
464
/* >    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 ) */
465
/* >    (  v1  v2  v3  v4  v5 ) */
466
/* > */
467
/* >  where d and e denote diagonal and off-diagonal elements of B, vi */
468
/* >  denotes an element of the vector defining H(i), and ui an element of */
469
/* >  the vector defining G(i). */
470
/* > \endverbatim */
471
/* > */
472
/*  ===================================================================== */
473
/* Subroutine */ void sgebrd_(integer *m, integer *n, real *a, integer *lda, 
474
  real *d__, real *e, real *tauq, real *taup, real *work, integer *
475
  lwork, integer *info)
476
0
{
477
    /* System generated locals */
478
0
    integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
479
480
    /* Local variables */
481
0
    integer i__, j, nbmin, iinfo;
482
0
    extern /* Subroutine */ void sgemm_(char *, char *, integer *, integer *, 
483
0
      integer *, real *, real *, integer *, real *, integer *, real *, 
484
0
      real *, integer *);
485
0
    integer minmn;
486
0
    extern /* Subroutine */ void sgebd2_(integer *, integer *, real *, integer 
487
0
      *, real *, real *, real *, real *, real *, integer *);
488
0
    integer nb, nx;
489
0
    extern /* Subroutine */ void slabrd_(integer *, integer *, integer *, real 
490
0
      *, integer *, real *, real *, real *, real *, real *, integer *, 
491
0
      real *, integer *);
492
0
    integer ws;
493
0
    extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
494
0
    extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
495
0
      integer *, integer *, ftnlen, ftnlen);
496
0
    integer ldwrkx, ldwrky, lwkopt;
497
0
    logical lquery;
498
499
500
/*  -- LAPACK computational routine (version 3.8.0) -- */
501
/*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
502
/*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
503
/*     November 2017 */
504
505
506
/*  ===================================================================== */
507
508
509
/*     Test the input parameters */
510
511
    /* Parameter adjustments */
512
0
    a_dim1 = *lda;
513
0
    a_offset = 1 + a_dim1 * 1;
514
0
    a -= a_offset;
515
0
    --d__;
516
0
    --e;
517
0
    --tauq;
518
0
    --taup;
519
0
    --work;
520
521
    /* Function Body */
522
0
    *info = 0;
523
/* Computing MAX */
524
0
    i__1 = 1, i__2 = ilaenv_(&c__1, "SGEBRD", " ", m, n, &c_n1, &c_n1, (
525
0
      ftnlen)6, (ftnlen)1);
526
0
    nb = f2cmax(i__1,i__2);
527
0
    lwkopt = (*m + *n) * nb;
528
0
    work[1] = (real) lwkopt;
529
0
    lquery = *lwork == -1;
530
0
    if (*m < 0) {
531
0
  *info = -1;
532
0
    } else if (*n < 0) {
533
0
  *info = -2;
534
0
    } else if (*lda < f2cmax(1,*m)) {
535
0
  *info = -4;
536
0
    } else /* if(complicated condition) */ {
537
/* Computing MAX */
538
0
  i__1 = f2cmax(1,*m);
539
0
  if (*lwork < f2cmax(i__1,*n) && ! lquery) {
540
0
      *info = -10;
541
0
  }
542
0
    }
543
0
    if (*info < 0) {
544
0
  i__1 = -(*info);
545
0
  xerbla_("SGEBRD", &i__1, (ftnlen)6);
546
0
  return;
547
0
    } else if (lquery) {
548
0
  return;
549
0
    }
550
551
/*     Quick return if possible */
552
553
0
    minmn = f2cmin(*m,*n);
554
0
    if (minmn == 0) {
555
0
  work[1] = 1.f;
556
0
  return;
557
0
    }
558
559
0
    ws = f2cmax(*m,*n);
560
0
    ldwrkx = *m;
561
0
    ldwrky = *n;
562
563
0
    if (nb > 1 && nb < minmn) {
564
565
/*        Set the crossover point NX. */
566
567
/* Computing MAX */
568
0
  i__1 = nb, i__2 = ilaenv_(&c__3, "SGEBRD", " ", m, n, &c_n1, &c_n1, (
569
0
    ftnlen)6, (ftnlen)1);
570
0
  nx = f2cmax(i__1,i__2);
571
572
/*        Determine when to switch from blocked to unblocked code. */
573
574
0
  if (nx < minmn) {
575
0
      ws = (*m + *n) * nb;
576
0
      if (*lwork < ws) {
577
578
/*              Not enough work space for the optimal NB, consider using */
579
/*              a smaller block size. */
580
581
0
    nbmin = ilaenv_(&c__2, "SGEBRD", " ", m, n, &c_n1, &c_n1, (
582
0
      ftnlen)6, (ftnlen)1);
583
0
    if (*lwork >= (*m + *n) * nbmin) {
584
0
        nb = *lwork / (*m + *n);
585
0
    } else {
586
0
        nb = 1;
587
0
        nx = minmn;
588
0
    }
589
0
      }
590
0
  }
591
0
    } else {
592
0
  nx = minmn;
593
0
    }
594
595
0
    i__1 = minmn - nx;
596
0
    i__2 = nb;
597
0
    for (i__ = 1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
598
599
/*        Reduce rows and columns i:i+nb-1 to bidiagonal form and return */
600
/*        the matrices X and Y which are needed to update the unreduced */
601
/*        part of the matrix */
602
603
0
  i__3 = *m - i__ + 1;
604
0
  i__4 = *n - i__ + 1;
605
0
  slabrd_(&i__3, &i__4, &nb, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[
606
0
    i__], &tauq[i__], &taup[i__], &work[1], &ldwrkx, &work[ldwrkx 
607
0
    * nb + 1], &ldwrky);
608
609
/*        Update the trailing submatrix A(i+nb:m,i+nb:n), using an update */
610
/*        of the form  A := A - V*Y**T - X*U**T */
611
612
0
  i__3 = *m - i__ - nb + 1;
613
0
  i__4 = *n - i__ - nb + 1;
614
0
  sgemm_("No transpose", "Transpose", &i__3, &i__4, &nb, &c_b21, &a[i__ 
615
0
    + nb + i__ * a_dim1], lda, &work[ldwrkx * nb + nb + 1], &
616
0
    ldwrky, &c_b22, &a[i__ + nb + (i__ + nb) * a_dim1], lda);
617
0
  i__3 = *m - i__ - nb + 1;
618
0
  i__4 = *n - i__ - nb + 1;
619
0
  sgemm_("No transpose", "No transpose", &i__3, &i__4, &nb, &c_b21, &
620
0
    work[nb + 1], &ldwrkx, &a[i__ + (i__ + nb) * a_dim1], lda, &
621
0
    c_b22, &a[i__ + nb + (i__ + nb) * a_dim1], lda);
622
623
/*        Copy diagonal and off-diagonal elements of B back into A */
624
625
0
  if (*m >= *n) {
626
0
      i__3 = i__ + nb - 1;
627
0
      for (j = i__; j <= i__3; ++j) {
628
0
    a[j + j * a_dim1] = d__[j];
629
0
    a[j + (j + 1) * a_dim1] = e[j];
630
/* L10: */
631
0
      }
632
0
  } else {
633
0
      i__3 = i__ + nb - 1;
634
0
      for (j = i__; j <= i__3; ++j) {
635
0
    a[j + j * a_dim1] = d__[j];
636
0
    a[j + 1 + j * a_dim1] = e[j];
637
/* L20: */
638
0
      }
639
0
  }
640
/* L30: */
641
0
    }
642
643
/*     Use unblocked code to reduce the remainder of the matrix */
644
645
0
    i__2 = *m - i__ + 1;
646
0
    i__1 = *n - i__ + 1;
647
0
    sgebd2_(&i__2, &i__1, &a[i__ + i__ * a_dim1], lda, &d__[i__], &e[i__], &
648
0
      tauq[i__], &taup[i__], &work[1], &iinfo);
649
0
    work[1] = (real) ws;
650
0
    return;
651
652
/*     End of SGEBRD */
653
654
0
} /* sgebrd_ */
655