Coverage Report

Created: 2025-09-21 19:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/contrib/openblas/lapack-netlib/SRC/slalsd.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
0
#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
0
#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
0
#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
264
#ifdef __cplusplus
265
typedef logical (*L_fp)(...);
266
#else
267
typedef logical (*L_fp)();
268
#endif
269
270
0
static float spow_ui(float x, integer n) {
271
0
  float pow=1.0; unsigned long int u;
272
0
  if(n != 0) {
273
0
    if(n < 0) n = -n, x = 1/x;
274
0
    for(u = n; ; ) {
275
0
      if(u & 01) pow *= x;
276
0
      if(u >>= 1) x *= x;
277
0
      else break;
278
0
    }
279
0
  }
280
0
  return pow;
281
0
}
282
0
static double dpow_ui(double x, integer n) {
283
0
  double pow=1.0; unsigned long int u;
284
0
  if(n != 0) {
285
0
    if(n < 0) n = -n, x = 1/x;
286
0
    for(u = n; ; ) {
287
0
      if(u & 01) pow *= x;
288
0
      if(u >>= 1) x *= x;
289
0
      else break;
290
0
    }
291
0
  }
292
0
  return pow;
293
0
}
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
0
static _Complex float cpow_ui(_Complex float x, integer n) {
310
0
  _Complex float pow=1.0; unsigned long int u;
311
0
  if(n != 0) {
312
0
    if(n < 0) n = -n, x = 1/x;
313
0
    for(u = n; ; ) {
314
0
      if(u & 01) pow *= x;
315
0
      if(u >>= 1) x *= x;
316
0
      else break;
317
0
    }
318
0
  }
319
0
  return pow;
320
0
}
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
0
static _Complex double zpow_ui(_Complex double x, integer n) {
338
0
  _Complex double pow=1.0; unsigned long int u;
339
0
  if(n != 0) {
340
0
    if(n < 0) n = -n, x = 1/x;
341
0
    for(u = n; ; ) {
342
0
      if(u & 01) pow *= x;
343
0
      if(u >>= 1) x *= x;
344
0
      else break;
345
0
    }
346
0
  }
347
0
  return pow;
348
0
}
349
#endif
350
0
static integer pow_ii(integer x, integer n) {
351
0
  integer pow; unsigned long int u;
352
0
  if (n <= 0) {
353
0
    if (n == 0 || x == 1) pow = 1;
354
0
    else if (x != -1) pow = x == 0 ? 1/x : 0;
355
0
    else n = -n;
356
0
  }
357
0
  if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
358
0
    u = n;
359
0
    for(pow = 1; ; ) {
360
0
      if(u & 01) pow *= x;
361
0
      if(u >>= 1) x *= x;
362
0
      else break;
363
0
    }
364
0
  }
365
0
  return pow;
366
0
}
367
static integer dmaxloc_(double *w, integer s, integer e, integer *n)
368
0
{
369
0
  double m; integer i, mi;
370
0
  for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
371
0
    if (w[i-1]>m) mi=i ,m=w[i-1];
372
0
  return mi-s+1;
373
0
}
374
static integer smaxloc_(float *w, integer s, integer e, integer *n)
375
0
{
376
0
  float m; integer i, mi;
377
0
  for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
378
0
    if (w[i-1]>m) mi=i ,m=w[i-1];
379
0
  return mi-s+1;
380
0
}
381
0
static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
382
0
  integer n = *n_, incx = *incx_, incy = *incy_, i;
383
0
#ifdef _MSC_VER
384
0
  _Fcomplex zdotc = {0.0, 0.0};
385
0
  if (incx == 1 && incy == 1) {
386
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
387
0
      zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
388
0
      zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
389
0
    }
390
0
  } else {
391
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
392
0
      zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
393
0
      zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
394
0
    }
395
0
  }
396
0
  pCf(z) = zdotc;
397
0
}
398
0
#else
399
0
  _Complex float zdotc = 0.0;
400
0
  if (incx == 1 && incy == 1) {
401
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
402
0
      zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
403
0
    }
404
0
  } else {
405
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
406
0
      zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
407
0
    }
408
0
  }
409
0
  pCf(z) = zdotc;
410
0
}
411
#endif
412
0
static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
413
0
  integer n = *n_, incx = *incx_, incy = *incy_, i;
414
0
#ifdef _MSC_VER
415
0
  _Dcomplex zdotc = {0.0, 0.0};
416
0
  if (incx == 1 && incy == 1) {
417
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
418
0
      zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
419
0
      zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
420
0
    }
421
0
  } else {
422
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
423
0
      zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
424
0
      zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
425
0
    }
426
0
  }
427
0
  pCd(z) = zdotc;
428
0
}
429
0
#else
430
0
  _Complex double zdotc = 0.0;
431
0
  if (incx == 1 && incy == 1) {
432
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
433
0
      zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
434
0
    }
435
0
  } else {
436
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
437
0
      zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
438
0
    }
439
0
  }
440
0
  pCd(z) = zdotc;
441
0
}
442
#endif  
443
0
static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
444
0
  integer n = *n_, incx = *incx_, incy = *incy_, i;
445
0
#ifdef _MSC_VER
446
0
  _Fcomplex zdotc = {0.0, 0.0};
447
0
  if (incx == 1 && incy == 1) {
448
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
449
0
      zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
450
0
      zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
451
0
    }
452
0
  } else {
453
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
454
0
      zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
455
0
      zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
456
0
    }
457
0
  }
458
0
  pCf(z) = zdotc;
459
0
}
460
0
#else
461
0
  _Complex float zdotc = 0.0;
462
0
  if (incx == 1 && incy == 1) {
463
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
464
0
      zdotc += Cf(&x[i]) * Cf(&y[i]);
465
0
    }
466
0
  } else {
467
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
468
0
      zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
469
0
    }
470
0
  }
471
0
  pCf(z) = zdotc;
472
0
}
473
#endif
474
0
static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
475
0
  integer n = *n_, incx = *incx_, incy = *incy_, i;
476
0
#ifdef _MSC_VER
477
0
  _Dcomplex zdotc = {0.0, 0.0};
478
0
  if (incx == 1 && incy == 1) {
479
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
480
0
      zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
481
0
      zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
482
0
    }
483
0
  } else {
484
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
485
0
      zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
486
0
      zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
487
0
    }
488
0
  }
489
0
  pCd(z) = zdotc;
490
0
}
491
0
#else
492
0
  _Complex double zdotc = 0.0;
493
0
  if (incx == 1 && incy == 1) {
494
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
495
0
      zdotc += Cd(&x[i]) * Cd(&y[i]);
496
0
    }
497
0
  } else {
498
0
    for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
499
0
      zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
500
0
    }
501
0
  }
502
0
  pCd(z) = zdotc;
503
0
}
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 integer c__1 = 1;
516
static real c_b6 = 0.f;
517
static integer c__0 = 0;
518
static real c_b11 = 1.f;
519
520
/* > \brief \b SLALSD uses the singular value decomposition of A to solve the least squares problem. */
521
522
/*  =========== DOCUMENTATION =========== */
523
524
/* Online html documentation available at */
525
/*            http://www.netlib.org/lapack/explore-html/ */
526
527
/* > \htmlonly */
528
/* > Download SLALSD + dependencies */
529
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slalsd.
530
f"> */
531
/* > [TGZ]</a> */
532
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slalsd.
533
f"> */
534
/* > [ZIP]</a> */
535
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slalsd.
536
f"> */
537
/* > [TXT]</a> */
538
/* > \endhtmlonly */
539
540
/*  Definition: */
541
/*  =========== */
542
543
/*       SUBROUTINE SLALSD( UPLO, SMLSIZ, N, NRHS, D, E, B, LDB, RCOND, */
544
/*                          RANK, WORK, IWORK, INFO ) */
545
546
/*       CHARACTER          UPLO */
547
/*       INTEGER            INFO, LDB, N, NRHS, RANK, SMLSIZ */
548
/*       REAL               RCOND */
549
/*       INTEGER            IWORK( * ) */
550
/*       REAL               B( LDB, * ), D( * ), E( * ), WORK( * ) */
551
552
553
/* > \par Purpose: */
554
/*  ============= */
555
/* > */
556
/* > \verbatim */
557
/* > */
558
/* > SLALSD uses the singular value decomposition of A to solve the least */
559
/* > squares problem of finding X to minimize the Euclidean norm of each */
560
/* > column of A*X-B, where A is N-by-N upper bidiagonal, and X and B */
561
/* > are N-by-NRHS. The solution X overwrites B. */
562
/* > */
563
/* > The singular values of A smaller than RCOND times the largest */
564
/* > singular value are treated as zero in solving the least squares */
565
/* > problem; in this case a minimum norm solution is returned. */
566
/* > The actual singular values are returned in D in ascending order. */
567
/* > */
568
/* > This code makes very mild assumptions about floating point */
569
/* > arithmetic. It will work on machines with a guard digit in */
570
/* > add/subtract, or on those binary machines without guard digits */
571
/* > which subtract like the Cray XMP, Cray YMP, Cray C 90, or Cray 2. */
572
/* > It could conceivably fail on hexadecimal or decimal machines */
573
/* > without guard digits, but we know of none. */
574
/* > \endverbatim */
575
576
/*  Arguments: */
577
/*  ========== */
578
579
/* > \param[in] UPLO */
580
/* > \verbatim */
581
/* >          UPLO is CHARACTER*1 */
582
/* >         = 'U': D and E define an upper bidiagonal matrix. */
583
/* >         = 'L': D and E define a  lower bidiagonal matrix. */
584
/* > \endverbatim */
585
/* > */
586
/* > \param[in] SMLSIZ */
587
/* > \verbatim */
588
/* >          SMLSIZ is INTEGER */
589
/* >         The maximum size of the subproblems at the bottom of the */
590
/* >         computation tree. */
591
/* > \endverbatim */
592
/* > */
593
/* > \param[in] N */
594
/* > \verbatim */
595
/* >          N is INTEGER */
596
/* >         The dimension of the  bidiagonal matrix.  N >= 0. */
597
/* > \endverbatim */
598
/* > */
599
/* > \param[in] NRHS */
600
/* > \verbatim */
601
/* >          NRHS is INTEGER */
602
/* >         The number of columns of B. NRHS must be at least 1. */
603
/* > \endverbatim */
604
/* > */
605
/* > \param[in,out] D */
606
/* > \verbatim */
607
/* >          D is REAL array, dimension (N) */
608
/* >         On entry D contains the main diagonal of the bidiagonal */
609
/* >         matrix. On exit, if INFO = 0, D contains its singular values. */
610
/* > \endverbatim */
611
/* > */
612
/* > \param[in,out] E */
613
/* > \verbatim */
614
/* >          E is REAL array, dimension (N-1) */
615
/* >         Contains the super-diagonal entries of the bidiagonal matrix. */
616
/* >         On exit, E has been destroyed. */
617
/* > \endverbatim */
618
/* > */
619
/* > \param[in,out] B */
620
/* > \verbatim */
621
/* >          B is REAL array, dimension (LDB,NRHS) */
622
/* >         On input, B contains the right hand sides of the least */
623
/* >         squares problem. On output, B contains the solution X. */
624
/* > \endverbatim */
625
/* > */
626
/* > \param[in] LDB */
627
/* > \verbatim */
628
/* >          LDB is INTEGER */
629
/* >         The leading dimension of B in the calling subprogram. */
630
/* >         LDB must be at least f2cmax(1,N). */
631
/* > \endverbatim */
632
/* > */
633
/* > \param[in] RCOND */
634
/* > \verbatim */
635
/* >          RCOND is REAL */
636
/* >         The singular values of A less than or equal to RCOND times */
637
/* >         the largest singular value are treated as zero in solving */
638
/* >         the least squares problem. If RCOND is negative, */
639
/* >         machine precision is used instead. */
640
/* >         For example, if diag(S)*X=B were the least squares problem, */
641
/* >         where diag(S) is a diagonal matrix of singular values, the */
642
/* >         solution would be X(i) = B(i) / S(i) if S(i) is greater than */
643
/* >         RCOND*f2cmax(S), and X(i) = 0 if S(i) is less than or equal to */
644
/* >         RCOND*f2cmax(S). */
645
/* > \endverbatim */
646
/* > */
647
/* > \param[out] RANK */
648
/* > \verbatim */
649
/* >          RANK is INTEGER */
650
/* >         The number of singular values of A greater than RCOND times */
651
/* >         the largest singular value. */
652
/* > \endverbatim */
653
/* > */
654
/* > \param[out] WORK */
655
/* > \verbatim */
656
/* >          WORK is REAL array, dimension at least */
657
/* >         (9*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2), */
658
/* >         where NLVL = f2cmax(0, INT(log_2 (N/(SMLSIZ+1))) + 1). */
659
/* > \endverbatim */
660
/* > */
661
/* > \param[out] IWORK */
662
/* > \verbatim */
663
/* >          IWORK is INTEGER array, dimension at least */
664
/* >         (3*N*NLVL + 11*N) */
665
/* > \endverbatim */
666
/* > */
667
/* > \param[out] INFO */
668
/* > \verbatim */
669
/* >          INFO is INTEGER */
670
/* >         = 0:  successful exit. */
671
/* >         < 0:  if INFO = -i, the i-th argument had an illegal value. */
672
/* >         > 0:  The algorithm failed to compute a singular value while */
673
/* >               working on the submatrix lying in rows and columns */
674
/* >               INFO/(N+1) through MOD(INFO,N+1). */
675
/* > \endverbatim */
676
677
/*  Authors: */
678
/*  ======== */
679
680
/* > \author Univ. of Tennessee */
681
/* > \author Univ. of California Berkeley */
682
/* > \author Univ. of Colorado Denver */
683
/* > \author NAG Ltd. */
684
685
/* > \date December 2016 */
686
687
/* > \ingroup realOTHERcomputational */
688
689
/* > \par Contributors: */
690
/*  ================== */
691
/* > */
692
/* >     Ming Gu and Ren-Cang Li, Computer Science Division, University of */
693
/* >       California at Berkeley, USA \n */
694
/* >     Osni Marques, LBNL/NERSC, USA \n */
695
696
/*  ===================================================================== */
697
/* Subroutine */ void slalsd_(char *uplo, integer *smlsiz, integer *n, integer 
698
  *nrhs, real *d__, real *e, real *b, integer *ldb, real *rcond, 
699
  integer *rank, real *work, integer *iwork, integer *info)
700
0
{
701
    /* System generated locals */
702
0
    integer b_dim1, b_offset, i__1, i__2;
703
0
    real r__1;
704
705
    /* Local variables */
706
0
    integer difl, difr;
707
0
    real rcnd;
708
0
    integer perm, nsub, nlvl, sqre, bxst;
709
0
    extern /* Subroutine */ void srot_(integer *, real *, integer *, real *, 
710
0
      integer *, real *, real *);
711
0
    integer c__, i__, j, k;
712
0
    real r__;
713
0
    integer s, u, z__;
714
0
    extern /* Subroutine */ void sgemm_(char *, char *, integer *, integer *, 
715
0
      integer *, real *, real *, integer *, real *, integer *, real *, 
716
0
      real *, integer *);
717
0
    integer poles, sizei, nsize;
718
0
    extern /* Subroutine */ void scopy_(integer *, real *, integer *, real *, 
719
0
      integer *);
720
0
    integer nwork, icmpq1, icmpq2;
721
0
    real cs;
722
0
    integer bx;
723
0
    real sn;
724
0
    integer st;
725
0
    extern real slamch_(char *);
726
0
    extern /* Subroutine */ void slasda_(integer *, integer *, integer *, 
727
0
      integer *, real *, real *, real *, integer *, real *, integer *, 
728
0
      real *, real *, real *, real *, integer *, integer *, integer *, 
729
0
      integer *, real *, real *, real *, real *, integer *, integer *);
730
0
    integer vt;
731
0
    extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
732
0
    extern void slalsa_(
733
0
      integer *, integer *, integer *, integer *, real *, integer *, 
734
0
      real *, integer *, real *, integer *, real *, integer *, real *, 
735
0
      real *, real *, real *, integer *, integer *, integer *, integer *
736
0
      , real *, real *, real *, real *, integer *, integer *), slascl_(
737
0
      char *, integer *, integer *, real *, real *, integer *, integer *
738
0
      , real *, integer *, integer *);
739
0
    integer givcol;
740
0
    extern integer isamax_(integer *, real *, integer *);
741
0
    extern /* Subroutine */ void slasdq_(char *, integer *, integer *, integer 
742
0
      *, integer *, integer *, real *, real *, real *, integer *, real *
743
0
      , integer *, real *, integer *, real *, integer *), 
744
0
      slacpy_(char *, integer *, integer *, real *, integer *, real *, 
745
0
      integer *), slartg_(real *, real *, real *, real *, real *
746
0
      ), slaset_(char *, integer *, integer *, real *, real *, real *, 
747
0
      integer *);
748
0
    real orgnrm;
749
0
    integer givnum;
750
0
    extern real slanst_(char *, integer *, real *, real *);
751
0
    extern /* Subroutine */ void slasrt_(char *, integer *, real *, integer *);
752
0
    integer givptr, nm1, smlszp, st1;
753
0
    real eps;
754
0
    integer iwk;
755
0
    real tol;
756
757
758
/*  -- LAPACK computational routine (version 3.7.0) -- */
759
/*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
760
/*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
761
/*     December 2016 */
762
763
764
/*  ===================================================================== */
765
766
767
/*     Test the input parameters. */
768
769
    /* Parameter adjustments */
770
0
    --d__;
771
0
    --e;
772
0
    b_dim1 = *ldb;
773
0
    b_offset = 1 + b_dim1 * 1;
774
0
    b -= b_offset;
775
0
    --work;
776
0
    --iwork;
777
778
    /* Function Body */
779
0
    *info = 0;
780
781
0
    if (*n < 0) {
782
0
  *info = -3;
783
0
    } else if (*nrhs < 1) {
784
0
  *info = -4;
785
0
    } else if (*ldb < 1 || *ldb < *n) {
786
0
  *info = -8;
787
0
    }
788
0
    if (*info != 0) {
789
0
  i__1 = -(*info);
790
0
  xerbla_("SLALSD", &i__1, (ftnlen)6);
791
0
  return;
792
0
    }
793
794
0
    eps = slamch_("Epsilon");
795
796
/*     Set up the tolerance. */
797
798
0
    if (*rcond <= 0.f || *rcond >= 1.f) {
799
0
  rcnd = eps;
800
0
    } else {
801
0
  rcnd = *rcond;
802
0
    }
803
804
0
    *rank = 0;
805
806
/*     Quick return if possible. */
807
808
0
    if (*n == 0) {
809
0
  return;
810
0
    } else if (*n == 1) {
811
0
  if (d__[1] == 0.f) {
812
0
      slaset_("A", &c__1, nrhs, &c_b6, &c_b6, &b[b_offset], ldb);
813
0
  } else {
814
0
      *rank = 1;
815
0
      slascl_("G", &c__0, &c__0, &d__[1], &c_b11, &c__1, nrhs, &b[
816
0
        b_offset], ldb, info);
817
0
      d__[1] = abs(d__[1]);
818
0
  }
819
0
  return;
820
0
    }
821
822
/*     Rotate the matrix if it is lower bidiagonal. */
823
824
0
    if (*(unsigned char *)uplo == 'L') {
825
0
  i__1 = *n - 1;
826
0
  for (i__ = 1; i__ <= i__1; ++i__) {
827
0
      slartg_(&d__[i__], &e[i__], &cs, &sn, &r__);
828
0
      d__[i__] = r__;
829
0
      e[i__] = sn * d__[i__ + 1];
830
0
      d__[i__ + 1] = cs * d__[i__ + 1];
831
0
      if (*nrhs == 1) {
832
0
    srot_(&c__1, &b[i__ + b_dim1], &c__1, &b[i__ + 1 + b_dim1], &
833
0
      c__1, &cs, &sn);
834
0
      } else {
835
0
    work[(i__ << 1) - 1] = cs;
836
0
    work[i__ * 2] = sn;
837
0
      }
838
/* L10: */
839
0
  }
840
0
  if (*nrhs > 1) {
841
0
      i__1 = *nrhs;
842
0
      for (i__ = 1; i__ <= i__1; ++i__) {
843
0
    i__2 = *n - 1;
844
0
    for (j = 1; j <= i__2; ++j) {
845
0
        cs = work[(j << 1) - 1];
846
0
        sn = work[j * 2];
847
0
        srot_(&c__1, &b[j + i__ * b_dim1], &c__1, &b[j + 1 + i__ *
848
0
           b_dim1], &c__1, &cs, &sn);
849
/* L20: */
850
0
    }
851
/* L30: */
852
0
      }
853
0
  }
854
0
    }
855
856
/*     Scale. */
857
858
0
    nm1 = *n - 1;
859
0
    orgnrm = slanst_("M", n, &d__[1], &e[1]);
860
0
    if (orgnrm == 0.f) {
861
0
  slaset_("A", n, nrhs, &c_b6, &c_b6, &b[b_offset], ldb);
862
0
  return;
863
0
    }
864
865
0
    slascl_("G", &c__0, &c__0, &orgnrm, &c_b11, n, &c__1, &d__[1], n, info);
866
0
    slascl_("G", &c__0, &c__0, &orgnrm, &c_b11, &nm1, &c__1, &e[1], &nm1, 
867
0
      info);
868
869
/*     If N is smaller than the minimum divide size SMLSIZ, then solve */
870
/*     the problem with another solver. */
871
872
0
    if (*n <= *smlsiz) {
873
0
  nwork = *n * *n + 1;
874
0
  slaset_("A", n, n, &c_b6, &c_b11, &work[1], n);
875
0
  slasdq_("U", &c__0, n, n, &c__0, nrhs, &d__[1], &e[1], &work[1], n, &
876
0
    work[1], n, &b[b_offset], ldb, &work[nwork], info);
877
0
  if (*info != 0) {
878
0
      return;
879
0
  }
880
0
  tol = rcnd * (r__1 = d__[isamax_(n, &d__[1], &c__1)], abs(r__1));
881
0
  i__1 = *n;
882
0
  for (i__ = 1; i__ <= i__1; ++i__) {
883
0
      if (d__[i__] <= tol) {
884
0
    slaset_("A", &c__1, nrhs, &c_b6, &c_b6, &b[i__ + b_dim1], ldb);
885
0
      } else {
886
0
    slascl_("G", &c__0, &c__0, &d__[i__], &c_b11, &c__1, nrhs, &b[
887
0
      i__ + b_dim1], ldb, info);
888
0
    ++(*rank);
889
0
      }
890
/* L40: */
891
0
  }
892
0
  sgemm_("T", "N", n, nrhs, n, &c_b11, &work[1], n, &b[b_offset], ldb, &
893
0
    c_b6, &work[nwork], n);
894
0
  slacpy_("A", n, nrhs, &work[nwork], n, &b[b_offset], ldb);
895
896
/*        Unscale. */
897
898
0
  slascl_("G", &c__0, &c__0, &c_b11, &orgnrm, n, &c__1, &d__[1], n, 
899
0
    info);
900
0
  slasrt_("D", n, &d__[1], info);
901
0
  slascl_("G", &c__0, &c__0, &orgnrm, &c_b11, n, nrhs, &b[b_offset], 
902
0
    ldb, info);
903
904
0
  return;
905
0
    }
906
907
/*     Book-keeping and setting up some constants. */
908
909
0
    nlvl = (integer) (log((real) (*n) / (real) (*smlsiz + 1)) / log(2.f)) + 1;
910
911
0
    smlszp = *smlsiz + 1;
912
913
0
    u = 1;
914
0
    vt = *smlsiz * *n + 1;
915
0
    difl = vt + smlszp * *n;
916
0
    difr = difl + nlvl * *n;
917
0
    z__ = difr + (nlvl * *n << 1);
918
0
    c__ = z__ + nlvl * *n;
919
0
    s = c__ + *n;
920
0
    poles = s + *n;
921
0
    givnum = poles + (nlvl << 1) * *n;
922
0
    bx = givnum + (nlvl << 1) * *n;
923
0
    nwork = bx + *n * *nrhs;
924
925
0
    sizei = *n + 1;
926
0
    k = sizei + *n;
927
0
    givptr = k + *n;
928
0
    perm = givptr + *n;
929
0
    givcol = perm + nlvl * *n;
930
0
    iwk = givcol + (nlvl * *n << 1);
931
932
0
    st = 1;
933
0
    sqre = 0;
934
0
    icmpq1 = 1;
935
0
    icmpq2 = 0;
936
0
    nsub = 0;
937
938
0
    i__1 = *n;
939
0
    for (i__ = 1; i__ <= i__1; ++i__) {
940
0
  if ((r__1 = d__[i__], abs(r__1)) < eps) {
941
0
      d__[i__] = r_sign(&eps, &d__[i__]);
942
0
  }
943
/* L50: */
944
0
    }
945
946
0
    i__1 = nm1;
947
0
    for (i__ = 1; i__ <= i__1; ++i__) {
948
0
  if ((r__1 = e[i__], abs(r__1)) < eps || i__ == nm1) {
949
0
      ++nsub;
950
0
      iwork[nsub] = st;
951
952
/*           Subproblem found. First determine its size and then */
953
/*           apply divide and conquer on it. */
954
955
0
      if (i__ < nm1) {
956
957
/*              A subproblem with E(I) small for I < NM1. */
958
959
0
    nsize = i__ - st + 1;
960
0
    iwork[sizei + nsub - 1] = nsize;
961
0
      } else if ((r__1 = e[i__], abs(r__1)) >= eps) {
962
963
/*              A subproblem with E(NM1) not too small but I = NM1. */
964
965
0
    nsize = *n - st + 1;
966
0
    iwork[sizei + nsub - 1] = nsize;
967
0
      } else {
968
969
/*              A subproblem with E(NM1) small. This implies an */
970
/*              1-by-1 subproblem at D(N), which is not solved */
971
/*              explicitly. */
972
973
0
    nsize = i__ - st + 1;
974
0
    iwork[sizei + nsub - 1] = nsize;
975
0
    ++nsub;
976
0
    iwork[nsub] = *n;
977
0
    iwork[sizei + nsub - 1] = 1;
978
0
    scopy_(nrhs, &b[*n + b_dim1], ldb, &work[bx + nm1], n);
979
0
      }
980
0
      st1 = st - 1;
981
0
      if (nsize == 1) {
982
983
/*              This is a 1-by-1 subproblem and is not solved */
984
/*              explicitly. */
985
986
0
    scopy_(nrhs, &b[st + b_dim1], ldb, &work[bx + st1], n);
987
0
      } else if (nsize <= *smlsiz) {
988
989
/*              This is a small subproblem and is solved by SLASDQ. */
990
991
0
    slaset_("A", &nsize, &nsize, &c_b6, &c_b11, &work[vt + st1], 
992
0
      n);
993
0
    slasdq_("U", &c__0, &nsize, &nsize, &c__0, nrhs, &d__[st], &e[
994
0
      st], &work[vt + st1], n, &work[nwork], n, &b[st + 
995
0
      b_dim1], ldb, &work[nwork], info);
996
0
    if (*info != 0) {
997
0
        return;
998
0
    }
999
0
    slacpy_("A", &nsize, nrhs, &b[st + b_dim1], ldb, &work[bx + 
1000
0
      st1], n);
1001
0
      } else {
1002
1003
/*              A large problem. Solve it using divide and conquer. */
1004
1005
0
    slasda_(&icmpq1, smlsiz, &nsize, &sqre, &d__[st], &e[st], &
1006
0
      work[u + st1], n, &work[vt + st1], &iwork[k + st1], &
1007
0
      work[difl + st1], &work[difr + st1], &work[z__ + st1],
1008
0
       &work[poles + st1], &iwork[givptr + st1], &iwork[
1009
0
      givcol + st1], n, &iwork[perm + st1], &work[givnum + 
1010
0
      st1], &work[c__ + st1], &work[s + st1], &work[nwork], 
1011
0
      &iwork[iwk], info);
1012
0
    if (*info != 0) {
1013
0
        return;
1014
0
    }
1015
0
    bxst = bx + st1;
1016
0
    slalsa_(&icmpq2, smlsiz, &nsize, nrhs, &b[st + b_dim1], ldb, &
1017
0
      work[bxst], n, &work[u + st1], n, &work[vt + st1], &
1018
0
      iwork[k + st1], &work[difl + st1], &work[difr + st1], 
1019
0
      &work[z__ + st1], &work[poles + st1], &iwork[givptr + 
1020
0
      st1], &iwork[givcol + st1], n, &iwork[perm + st1], &
1021
0
      work[givnum + st1], &work[c__ + st1], &work[s + st1], 
1022
0
      &work[nwork], &iwork[iwk], info);
1023
0
    if (*info != 0) {
1024
0
        return;
1025
0
    }
1026
0
      }
1027
0
      st = i__ + 1;
1028
0
  }
1029
/* L60: */
1030
0
    }
1031
1032
/*     Apply the singular values and treat the tiny ones as zero. */
1033
1034
0
    tol = rcnd * (r__1 = d__[isamax_(n, &d__[1], &c__1)], abs(r__1));
1035
1036
0
    i__1 = *n;
1037
0
    for (i__ = 1; i__ <= i__1; ++i__) {
1038
1039
/*        Some of the elements in D can be negative because 1-by-1 */
1040
/*        subproblems were not solved explicitly. */
1041
1042
0
  if ((r__1 = d__[i__], abs(r__1)) <= tol) {
1043
0
      slaset_("A", &c__1, nrhs, &c_b6, &c_b6, &work[bx + i__ - 1], n);
1044
0
  } else {
1045
0
      ++(*rank);
1046
0
      slascl_("G", &c__0, &c__0, &d__[i__], &c_b11, &c__1, nrhs, &work[
1047
0
        bx + i__ - 1], n, info);
1048
0
  }
1049
0
  d__[i__] = (r__1 = d__[i__], abs(r__1));
1050
/* L70: */
1051
0
    }
1052
1053
/*     Now apply back the right singular vectors. */
1054
1055
0
    icmpq2 = 1;
1056
0
    i__1 = nsub;
1057
0
    for (i__ = 1; i__ <= i__1; ++i__) {
1058
0
  st = iwork[i__];
1059
0
  st1 = st - 1;
1060
0
  nsize = iwork[sizei + i__ - 1];
1061
0
  bxst = bx + st1;
1062
0
  if (nsize == 1) {
1063
0
      scopy_(nrhs, &work[bxst], n, &b[st + b_dim1], ldb);
1064
0
  } else if (nsize <= *smlsiz) {
1065
0
      sgemm_("T", "N", &nsize, nrhs, &nsize, &c_b11, &work[vt + st1], n,
1066
0
         &work[bxst], n, &c_b6, &b[st + b_dim1], ldb);
1067
0
  } else {
1068
0
      slalsa_(&icmpq2, smlsiz, &nsize, nrhs, &work[bxst], n, &b[st + 
1069
0
        b_dim1], ldb, &work[u + st1], n, &work[vt + st1], &iwork[
1070
0
        k + st1], &work[difl + st1], &work[difr + st1], &work[z__ 
1071
0
        + st1], &work[poles + st1], &iwork[givptr + st1], &iwork[
1072
0
        givcol + st1], n, &iwork[perm + st1], &work[givnum + st1],
1073
0
         &work[c__ + st1], &work[s + st1], &work[nwork], &iwork[
1074
0
        iwk], info);
1075
0
      if (*info != 0) {
1076
0
    return;
1077
0
      }
1078
0
  }
1079
/* L80: */
1080
0
    }
1081
1082
/*     Unscale and sort the singular values. */
1083
1084
0
    slascl_("G", &c__0, &c__0, &c_b11, &orgnrm, n, &c__1, &d__[1], n, info);
1085
0
    slasrt_("D", n, &d__[1], info);
1086
0
    slascl_("G", &c__0, &c__0, &orgnrm, &c_b11, n, nrhs, &b[b_offset], ldb, 
1087
0
      info);
1088
1089
0
    return;
1090
1091
/*     End of SLALSD */
1092
1093
0
} /* slalsd_ */
1094