Coverage Report

Created: 2025-09-12 18:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/contrib/openblas/lapack-netlib/SRC/sgebd2.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
265
/* > \brief \b SGEBD2 reduces a general matrix to bidiagonal form using an unblocked algorithm. */
266
267
/*  =========== DOCUMENTATION =========== */
268
269
/* Online html documentation available at */
270
/*            http://www.netlib.org/lapack/explore-html/ */
271
272
/* > \htmlonly */
273
/* > Download SGEBD2 + dependencies */
274
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgebd2.
275
f"> */
276
/* > [TGZ]</a> */
277
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgebd2.
278
f"> */
279
/* > [ZIP]</a> */
280
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgebd2.
281
f"> */
282
/* > [TXT]</a> */
283
/* > \endhtmlonly */
284
285
/*  Definition: */
286
/*  =========== */
287
288
/*       SUBROUTINE SGEBD2( M, N, A, LDA, D, E, TAUQ, TAUP, WORK, INFO ) */
289
290
/*       INTEGER            INFO, LDA, M, N */
291
/*       REAL               A( LDA, * ), D( * ), E( * ), TAUP( * ), */
292
/*      $                   TAUQ( * ), WORK( * ) */
293
294
295
/* > \par Purpose: */
296
/*  ============= */
297
/* > */
298
/* > \verbatim */
299
/* > */
300
/* > SGEBD2 reduces a real general m by n matrix A to upper or lower */
301
/* > bidiagonal form B by an orthogonal transformation: Q**T * A * P = B. */
302
/* > */
303
/* > If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */
304
/* > \endverbatim */
305
306
/*  Arguments: */
307
/*  ========== */
308
309
/* > \param[in] M */
310
/* > \verbatim */
311
/* >          M is INTEGER */
312
/* >          The number of rows in the matrix A.  M >= 0. */
313
/* > \endverbatim */
314
/* > */
315
/* > \param[in] N */
316
/* > \verbatim */
317
/* >          N is INTEGER */
318
/* >          The number of columns in the matrix A.  N >= 0. */
319
/* > \endverbatim */
320
/* > */
321
/* > \param[in,out] A */
322
/* > \verbatim */
323
/* >          A is REAL array, dimension (LDA,N) */
324
/* >          On entry, the m by n general matrix to be reduced. */
325
/* >          On exit, */
326
/* >          if m >= n, the diagonal and the first superdiagonal are */
327
/* >            overwritten with the upper bidiagonal matrix B; the */
328
/* >            elements below the diagonal, with the array TAUQ, represent */
329
/* >            the orthogonal matrix Q as a product of elementary */
330
/* >            reflectors, and the elements above the first superdiagonal, */
331
/* >            with the array TAUP, represent the orthogonal matrix P as */
332
/* >            a product of elementary reflectors; */
333
/* >          if m < n, the diagonal and the first subdiagonal are */
334
/* >            overwritten with the lower bidiagonal matrix B; the */
335
/* >            elements below the first subdiagonal, with the array TAUQ, */
336
/* >            represent the orthogonal matrix Q as a product of */
337
/* >            elementary reflectors, and the elements above the diagonal, */
338
/* >            with the array TAUP, represent the orthogonal matrix P as */
339
/* >            a product of elementary reflectors. */
340
/* >          See Further Details. */
341
/* > \endverbatim */
342
/* > */
343
/* > \param[in] LDA */
344
/* > \verbatim */
345
/* >          LDA is INTEGER */
346
/* >          The leading dimension of the array A.  LDA >= f2cmax(1,M). */
347
/* > \endverbatim */
348
/* > */
349
/* > \param[out] D */
350
/* > \verbatim */
351
/* >          D is REAL array, dimension (f2cmin(M,N)) */
352
/* >          The diagonal elements of the bidiagonal matrix B: */
353
/* >          D(i) = A(i,i). */
354
/* > \endverbatim */
355
/* > */
356
/* > \param[out] E */
357
/* > \verbatim */
358
/* >          E is REAL array, dimension (f2cmin(M,N)-1) */
359
/* >          The off-diagonal elements of the bidiagonal matrix B: */
360
/* >          if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */
361
/* >          if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */
362
/* > \endverbatim */
363
/* > */
364
/* > \param[out] TAUQ */
365
/* > \verbatim */
366
/* >          TAUQ is REAL array, dimension (f2cmin(M,N)) */
367
/* >          The scalar factors of the elementary reflectors which */
368
/* >          represent the orthogonal matrix Q. See Further Details. */
369
/* > \endverbatim */
370
/* > */
371
/* > \param[out] TAUP */
372
/* > \verbatim */
373
/* >          TAUP is REAL array, dimension (f2cmin(M,N)) */
374
/* >          The scalar factors of the elementary reflectors which */
375
/* >          represent the orthogonal matrix P. See Further Details. */
376
/* > \endverbatim */
377
/* > */
378
/* > \param[out] WORK */
379
/* > \verbatim */
380
/* >          WORK is REAL array, dimension (f2cmax(M,N)) */
381
/* > \endverbatim */
382
/* > */
383
/* > \param[out] INFO */
384
/* > \verbatim */
385
/* >          INFO is INTEGER */
386
/* >          = 0: successful exit. */
387
/* >          < 0: if INFO = -i, the i-th argument had an illegal value. */
388
/* > \endverbatim */
389
390
/*  Authors: */
391
/*  ======== */
392
393
/* > \author Univ. of Tennessee */
394
/* > \author Univ. of California Berkeley */
395
/* > \author Univ. of Colorado Denver */
396
/* > \author NAG Ltd. */
397
398
/* > \date June 2017 */
399
400
/* > \ingroup realGEcomputational */
401
402
/* > \par Further Details: */
403
/*  ===================== */
404
/* > */
405
/* > \verbatim */
406
/* > */
407
/* >  The matrices Q and P are represented as products of elementary */
408
/* >  reflectors: */
409
/* > */
410
/* >  If m >= n, */
411
/* > */
412
/* >     Q = H(1) H(2) . . . H(n)  and  P = G(1) G(2) . . . G(n-1) */
413
/* > */
414
/* >  Each H(i) and G(i) has the form: */
415
/* > */
416
/* >     H(i) = I - tauq * v * v**T  and G(i) = I - taup * u * u**T */
417
/* > */
418
/* >  where tauq and taup are real scalars, and v and u are real vectors; */
419
/* >  v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); */
420
/* >  u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); */
421
/* >  tauq is stored in TAUQ(i) and taup in TAUP(i). */
422
/* > */
423
/* >  If m < n, */
424
/* > */
425
/* >     Q = H(1) H(2) . . . H(m-1)  and  P = G(1) G(2) . . . G(m) */
426
/* > */
427
/* >  Each H(i) and G(i) has the form: */
428
/* > */
429
/* >     H(i) = I - tauq * v * v**T  and G(i) = I - taup * u * u**T */
430
/* > */
431
/* >  where tauq and taup are real scalars, and v and u are real vectors; */
432
/* >  v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */
433
/* >  u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */
434
/* >  tauq is stored in TAUQ(i) and taup in TAUP(i). */
435
/* > */
436
/* >  The contents of A on exit are illustrated by the following examples: */
437
/* > */
438
/* >  m = 6 and n = 5 (m > n):          m = 5 and n = 6 (m < n): */
439
/* > */
440
/* >    (  d   e   u1  u1  u1 )           (  d   u1  u1  u1  u1  u1 ) */
441
/* >    (  v1  d   e   u2  u2 )           (  e   d   u2  u2  u2  u2 ) */
442
/* >    (  v1  v2  d   e   u3 )           (  v1  e   d   u3  u3  u3 ) */
443
/* >    (  v1  v2  v3  d   e  )           (  v1  v2  e   d   u4  u4 ) */
444
/* >    (  v1  v2  v3  v4  d  )           (  v1  v2  v3  e   d   u5 ) */
445
/* >    (  v1  v2  v3  v4  v5 ) */
446
/* > */
447
/* >  where d and e denote diagonal and off-diagonal elements of B, vi */
448
/* >  denotes an element of the vector defining H(i), and ui an element of */
449
/* >  the vector defining G(i). */
450
/* > \endverbatim */
451
/* > */
452
/*  ===================================================================== */
453
/* Subroutine */ void sgebd2_(integer *m, integer *n, real *a, integer *lda, 
454
  real *d__, real *e, real *tauq, real *taup, real *work, integer *info)
455
0
{
456
    /* System generated locals */
457
0
    integer a_dim1, a_offset, i__1, i__2, i__3;
458
459
    /* Local variables */
460
0
    integer i__;
461
0
    extern /* Subroutine */ void slarf_(char *, integer *, integer *, real *, 
462
0
      integer *, real *, real *, integer *, real *);
463
0
    extern int xerbla_(char *, integer *, ftnlen);
464
0
    extern void slarfg_(integer *, real *, real *, 
465
0
      integer *, real *);
466
467
468
/*  -- LAPACK computational routine (version 3.7.1) -- */
469
/*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
470
/*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
471
/*     June 2017 */
472
473
474
/*  ===================================================================== */
475
476
477
/*     Test the input parameters */
478
479
    /* Parameter adjustments */
480
0
    a_dim1 = *lda;
481
0
    a_offset = 1 + a_dim1 * 1;
482
0
    a -= a_offset;
483
0
    --d__;
484
0
    --e;
485
0
    --tauq;
486
0
    --taup;
487
0
    --work;
488
489
    /* Function Body */
490
0
    *info = 0;
491
0
    if (*m < 0) {
492
0
  *info = -1;
493
0
    } else if (*n < 0) {
494
0
  *info = -2;
495
0
    } else if (*lda < f2cmax(1,*m)) {
496
0
  *info = -4;
497
0
    }
498
0
    if (*info < 0) {
499
0
  i__1 = -(*info);
500
0
  xerbla_("SGEBD2", &i__1, (ftnlen)6);
501
0
  return;
502
0
    }
503
504
0
    if (*m >= *n) {
505
506
/*        Reduce to upper bidiagonal form */
507
508
0
  i__1 = *n;
509
0
  for (i__ = 1; i__ <= i__1; ++i__) {
510
511
/*           Generate elementary reflector H(i) to annihilate A(i+1:m,i) */
512
513
0
      i__2 = *m - i__ + 1;
514
/* Computing MIN */
515
0
      i__3 = i__ + 1;
516
0
      slarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[f2cmin(i__3,*m) + i__ * 
517
0
        a_dim1], &c__1, &tauq[i__]);
518
0
      d__[i__] = a[i__ + i__ * a_dim1];
519
0
      a[i__ + i__ * a_dim1] = 1.f;
520
521
/*           Apply H(i) to A(i:m,i+1:n) from the left */
522
523
0
      if (i__ < *n) {
524
0
    i__2 = *m - i__ + 1;
525
0
    i__3 = *n - i__;
526
0
    slarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &
527
0
      tauq[i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]
528
0
      );
529
0
      }
530
0
      a[i__ + i__ * a_dim1] = d__[i__];
531
532
0
      if (i__ < *n) {
533
534
/*              Generate elementary reflector G(i) to annihilate */
535
/*              A(i,i+2:n) */
536
537
0
    i__2 = *n - i__;
538
/* Computing MIN */
539
0
    i__3 = i__ + 2;
540
0
    slarfg_(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + f2cmin(
541
0
      i__3,*n) * a_dim1], lda, &taup[i__]);
542
0
    e[i__] = a[i__ + (i__ + 1) * a_dim1];
543
0
    a[i__ + (i__ + 1) * a_dim1] = 1.f;
544
545
/*              Apply G(i) to A(i+1:m,i+1:n) from the right */
546
547
0
    i__2 = *m - i__;
548
0
    i__3 = *n - i__;
549
0
    slarf_("Right", &i__2, &i__3, &a[i__ + (i__ + 1) * a_dim1], 
550
0
      lda, &taup[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], 
551
0
      lda, &work[1]);
552
0
    a[i__ + (i__ + 1) * a_dim1] = e[i__];
553
0
      } else {
554
0
    taup[i__] = 0.f;
555
0
      }
556
/* L10: */
557
0
  }
558
0
    } else {
559
560
/*        Reduce to lower bidiagonal form */
561
562
0
  i__1 = *m;
563
0
  for (i__ = 1; i__ <= i__1; ++i__) {
564
565
/*           Generate elementary reflector G(i) to annihilate A(i,i+1:n) */
566
567
0
      i__2 = *n - i__ + 1;
568
/* Computing MIN */
569
0
      i__3 = i__ + 1;
570
0
      slarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + f2cmin(i__3,*n) * 
571
0
        a_dim1], lda, &taup[i__]);
572
0
      d__[i__] = a[i__ + i__ * a_dim1];
573
0
      a[i__ + i__ * a_dim1] = 1.f;
574
575
/*           Apply G(i) to A(i+1:m,i:n) from the right */
576
577
0
      if (i__ < *m) {
578
0
    i__2 = *m - i__;
579
0
    i__3 = *n - i__ + 1;
580
0
    slarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &
581
0
      taup[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
582
0
      }
583
0
      a[i__ + i__ * a_dim1] = d__[i__];
584
585
0
      if (i__ < *m) {
586
587
/*              Generate elementary reflector H(i) to annihilate */
588
/*              A(i+2:m,i) */
589
590
0
    i__2 = *m - i__;
591
/* Computing MIN */
592
0
    i__3 = i__ + 2;
593
0
    slarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[f2cmin(i__3,*m) + 
594
0
      i__ * a_dim1], &c__1, &tauq[i__]);
595
0
    e[i__] = a[i__ + 1 + i__ * a_dim1];
596
0
    a[i__ + 1 + i__ * a_dim1] = 1.f;
597
598
/*              Apply H(i) to A(i+1:m,i+1:n) from the left */
599
600
0
    i__2 = *m - i__;
601
0
    i__3 = *n - i__;
602
0
    slarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &
603
0
      c__1, &tauq[i__], &a[i__ + 1 + (i__ + 1) * a_dim1], 
604
0
      lda, &work[1]);
605
0
    a[i__ + 1 + i__ * a_dim1] = e[i__];
606
0
      } else {
607
0
    tauq[i__] = 0.f;
608
0
      }
609
/* L20: */
610
0
  }
611
0
    }
612
0
    return;
613
614
/*     End of SGEBD2 */
615
616
0
} /* sgebd2_ */
617