C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / SRC / sgsvj0.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 integer c__1 = 1;
516 static integer c__0 = 0;
517 static real c_b42 = 1.f;
518
519 /* > \brief \b SGSVJ0 pre-processor for the routine sgesvj. */
520
521 /*  =========== DOCUMENTATION =========== */
522
523 /* Online html documentation available at */
524 /*            http://www.netlib.org/lapack/explore-html/ */
525
526 /* > \htmlonly */
527 /* > Download SGSVJ0 + dependencies */
528 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgsvj0.
529 f"> */
530 /* > [TGZ]</a> */
531 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgsvj0.
532 f"> */
533 /* > [ZIP]</a> */
534 /* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgsvj0.
535 f"> */
536 /* > [TXT]</a> */
537 /* > \endhtmlonly */
538
539 /*  Definition: */
540 /*  =========== */
541
542 /*       SUBROUTINE SGSVJ0( JOBV, M, N, A, LDA, D, SVA, MV, V, LDV, EPS, */
543 /*                          SFMIN, TOL, NSWEEP, WORK, LWORK, INFO ) */
544
545 /*       INTEGER            INFO, LDA, LDV, LWORK, M, MV, N, NSWEEP */
546 /*       REAL               EPS, SFMIN, TOL */
547 /*       CHARACTER*1        JOBV */
548 /*       REAL               A( LDA, * ), SVA( N ), D( N ), V( LDV, * ), */
549 /*      $                   WORK( LWORK ) */
550
551
552 /* > \par Purpose: */
553 /*  ============= */
554 /* > */
555 /* > \verbatim */
556 /* > */
557 /* > SGSVJ0 is called from SGESVJ as a pre-processor and that is its main */
558 /* > purpose. It applies Jacobi rotations in the same way as SGESVJ does, but */
559 /* > it does not check convergence (stopping criterion). Few tuning */
560 /* > parameters (marked by [TP]) are available for the implementer. */
561 /* > \endverbatim */
562
563 /*  Arguments: */
564 /*  ========== */
565
566 /* > \param[in] JOBV */
567 /* > \verbatim */
568 /* >          JOBV is CHARACTER*1 */
569 /* >          Specifies whether the output from this procedure is used */
570 /* >          to compute the matrix V: */
571 /* >          = 'V': the product of the Jacobi rotations is accumulated */
572 /* >                 by postmulyiplying the N-by-N array V. */
573 /* >                (See the description of V.) */
574 /* >          = 'A': the product of the Jacobi rotations is accumulated */
575 /* >                 by postmulyiplying the MV-by-N array V. */
576 /* >                (See the descriptions of MV and V.) */
577 /* >          = 'N': the Jacobi rotations are not accumulated. */
578 /* > \endverbatim */
579 /* > */
580 /* > \param[in] M */
581 /* > \verbatim */
582 /* >          M is INTEGER */
583 /* >          The number of rows of the input matrix A.  M >= 0. */
584 /* > \endverbatim */
585 /* > */
586 /* > \param[in] N */
587 /* > \verbatim */
588 /* >          N is INTEGER */
589 /* >          The number of columns of the input matrix A. */
590 /* >          M >= N >= 0. */
591 /* > \endverbatim */
592 /* > */
593 /* > \param[in,out] A */
594 /* > \verbatim */
595 /* >          A is REAL array, dimension (LDA,N) */
596 /* >          On entry, M-by-N matrix A, such that A*diag(D) represents */
597 /* >          the input matrix. */
598 /* >          On exit, */
599 /* >          A_onexit * D_onexit represents the input matrix A*diag(D) */
600 /* >          post-multiplied by a sequence of Jacobi rotations, where the */
601 /* >          rotation threshold and the total number of sweeps are given in */
602 /* >          TOL and NSWEEP, respectively. */
603 /* >          (See the descriptions of D, TOL and NSWEEP.) */
604 /* > \endverbatim */
605 /* > */
606 /* > \param[in] LDA */
607 /* > \verbatim */
608 /* >          LDA is INTEGER */
609 /* >          The leading dimension of the array A.  LDA >= f2cmax(1,M). */
610 /* > \endverbatim */
611 /* > */
612 /* > \param[in,out] D */
613 /* > \verbatim */
614 /* >          D is REAL array, dimension (N) */
615 /* >          The array D accumulates the scaling factors from the fast scaled */
616 /* >          Jacobi rotations. */
617 /* >          On entry, A*diag(D) represents the input matrix. */
618 /* >          On exit, A_onexit*diag(D_onexit) represents the input matrix */
619 /* >          post-multiplied by a sequence of Jacobi rotations, where the */
620 /* >          rotation threshold and the total number of sweeps are given in */
621 /* >          TOL and NSWEEP, respectively. */
622 /* >          (See the descriptions of A, TOL and NSWEEP.) */
623 /* > \endverbatim */
624 /* > */
625 /* > \param[in,out] SVA */
626 /* > \verbatim */
627 /* >          SVA is REAL array, dimension (N) */
628 /* >          On entry, SVA contains the Euclidean norms of the columns of */
629 /* >          the matrix A*diag(D). */
630 /* >          On exit, SVA contains the Euclidean norms of the columns of */
631 /* >          the matrix onexit*diag(D_onexit). */
632 /* > \endverbatim */
633 /* > */
634 /* > \param[in] MV */
635 /* > \verbatim */
636 /* >          MV is INTEGER */
637 /* >          If JOBV = 'A', then MV rows of V are post-multipled by a */
638 /* >                           sequence of Jacobi rotations. */
639 /* >          If JOBV = 'N',   then MV is not referenced. */
640 /* > \endverbatim */
641 /* > */
642 /* > \param[in,out] V */
643 /* > \verbatim */
644 /* >          V is REAL array, dimension (LDV,N) */
645 /* >          If JOBV = 'V' then N rows of V are post-multipled by a */
646 /* >                           sequence of Jacobi rotations. */
647 /* >          If JOBV = 'A' then MV rows of V are post-multipled by a */
648 /* >                           sequence of Jacobi rotations. */
649 /* >          If JOBV = 'N',   then V is not referenced. */
650 /* > \endverbatim */
651 /* > */
652 /* > \param[in] LDV */
653 /* > \verbatim */
654 /* >          LDV is INTEGER */
655 /* >          The leading dimension of the array V,  LDV >= 1. */
656 /* >          If JOBV = 'V', LDV >= N. */
657 /* >          If JOBV = 'A', LDV >= MV. */
658 /* > \endverbatim */
659 /* > */
660 /* > \param[in] EPS */
661 /* > \verbatim */
662 /* >          EPS is REAL */
663 /* >          EPS = SLAMCH('Epsilon') */
664 /* > \endverbatim */
665 /* > */
666 /* > \param[in] SFMIN */
667 /* > \verbatim */
668 /* >          SFMIN is REAL */
669 /* >          SFMIN = SLAMCH('Safe Minimum') */
670 /* > \endverbatim */
671 /* > */
672 /* > \param[in] TOL */
673 /* > \verbatim */
674 /* >          TOL is REAL */
675 /* >          TOL is the threshold for Jacobi rotations. For a pair */
676 /* >          A(:,p), A(:,q) of pivot columns, the Jacobi rotation is */
677 /* >          applied only if ABS(COS(angle(A(:,p),A(:,q)))) > TOL. */
678 /* > \endverbatim */
679 /* > */
680 /* > \param[in] NSWEEP */
681 /* > \verbatim */
682 /* >          NSWEEP is INTEGER */
683 /* >          NSWEEP is the number of sweeps of Jacobi rotations to be */
684 /* >          performed. */
685 /* > \endverbatim */
686 /* > */
687 /* > \param[out] WORK */
688 /* > \verbatim */
689 /* >          WORK is REAL array, dimension (LWORK) */
690 /* > \endverbatim */
691 /* > */
692 /* > \param[in] LWORK */
693 /* > \verbatim */
694 /* >          LWORK is INTEGER */
695 /* >          LWORK is the dimension of WORK. LWORK >= M. */
696 /* > \endverbatim */
697 /* > */
698 /* > \param[out] INFO */
699 /* > \verbatim */
700 /* >          INFO is INTEGER */
701 /* >          = 0:  successful exit. */
702 /* >          < 0:  if INFO = -i, then the i-th argument had an illegal value */
703 /* > \endverbatim */
704
705 /*  Authors: */
706 /*  ======== */
707
708 /* > \author Univ. of Tennessee */
709 /* > \author Univ. of California Berkeley */
710 /* > \author Univ. of Colorado Denver */
711 /* > \author NAG Ltd. */
712
713 /* > \date November 2017 */
714
715 /* > \ingroup realOTHERcomputational */
716
717 /* > \par Further Details: */
718 /*  ===================== */
719 /* > */
720 /* > SGSVJ0 is used just to enable SGESVJ to call a simplified version of */
721 /* > itself to work on a submatrix of the original matrix. */
722 /* > */
723 /* > \par Contributors: */
724 /*  ================== */
725 /* > */
726 /* > Zlatko Drmac (Zagreb, Croatia) and Kresimir Veselic (Hagen, Germany) */
727 /* > */
728 /* > \par Bugs, Examples and Comments: */
729 /*  ================================= */
730 /* > */
731 /* > Please report all bugs and send interesting test examples and comments to */
732 /* > drmac@math.hr. Thank you. */
733
734 /*  ===================================================================== */
735 /* Subroutine */ int sgsvj0_(char *jobv, integer *m, integer *n, real *a, 
736         integer *lda, real *d__, real *sva, integer *mv, real *v, integer *
737         ldv, real *eps, real *sfmin, real *tol, integer *nsweep, real *work, 
738         integer *lwork, integer *info)
739 {
740     /* System generated locals */
741     integer a_dim1, a_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4, i__5, 
742             i__6;
743     real r__1, r__2;
744
745     /* Local variables */
746     real aapp, aapq, aaqq;
747     integer ierr;
748     real bigtheta;
749     extern real sdot_(integer *, real *, integer *, real *, integer *);
750     integer pskipped;
751     real aapp0, temp1;
752     extern real snrm2_(integer *, real *, integer *);
753     integer i__, p, q;
754     real t, apoaq, aqoap;
755     extern logical lsame_(char *, char *);
756     real theta, small, fastr[5];
757     logical applv, rsvec;
758     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
759             integer *);
760     logical rotok;
761     extern /* Subroutine */ int sswap_(integer *, real *, integer *, real *, 
762             integer *), saxpy_(integer *, real *, real *, integer *, real *, 
763             integer *), srotm_(integer *, real *, integer *, real *, integer *
764             , real *);
765     real rootsfmin, cs, sn;
766     extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
767     integer ijblsk, swband;
768     extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *, 
769             real *, integer *, integer *, real *, integer *, integer *);
770     extern integer isamax_(integer *, real *, integer *);
771     integer blskip;
772     real mxaapq, thsign;
773     extern /* Subroutine */ int slassq_(integer *, real *, integer *, real *, 
774             real *);
775     real mxsinj;
776     integer ir1, emptsw, notrot, iswrot, jbc;
777     real big;
778     integer kbl, lkahead, igl, ibr, jgl, nbl, mvl;
779     real rootbig, rooteps;
780     integer rowskip;
781     real roottol;
782
783
784 /*  -- LAPACK computational routine (version 3.8.0) -- */
785 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
786 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
787 /*     November 2017 */
788
789
790 /*  ===================================================================== */
791
792
793 /*     Test the input parameters. */
794
795     /* Parameter adjustments */
796     --sva;
797     --d__;
798     a_dim1 = *lda;
799     a_offset = 1 + a_dim1 * 1;
800     a -= a_offset;
801     v_dim1 = *ldv;
802     v_offset = 1 + v_dim1 * 1;
803     v -= v_offset;
804     --work;
805
806     /* Function Body */
807     applv = lsame_(jobv, "A");
808     rsvec = lsame_(jobv, "V");
809     if (! (rsvec || applv || lsame_(jobv, "N"))) {
810         *info = -1;
811     } else if (*m < 0) {
812         *info = -2;
813     } else if (*n < 0 || *n > *m) {
814         *info = -3;
815     } else if (*lda < *m) {
816         *info = -5;
817     } else if ((rsvec || applv) && *mv < 0) {
818         *info = -8;
819     } else if (rsvec && *ldv < *n || applv && *ldv < *mv) {
820         *info = -10;
821     } else if (*tol <= *eps) {
822         *info = -13;
823     } else if (*nsweep < 0) {
824         *info = -14;
825     } else if (*lwork < *m) {
826         *info = -16;
827     } else {
828         *info = 0;
829     }
830
831 /*     #:( */
832     if (*info != 0) {
833         i__1 = -(*info);
834         xerbla_("SGSVJ0", &i__1, (ftnlen)6);
835         return 0;
836     }
837
838     if (rsvec) {
839         mvl = *n;
840     } else if (applv) {
841         mvl = *mv;
842     }
843     rsvec = rsvec || applv;
844     rooteps = sqrt(*eps);
845     rootsfmin = sqrt(*sfmin);
846     small = *sfmin / *eps;
847     big = 1.f / *sfmin;
848     rootbig = 1.f / rootsfmin;
849     bigtheta = 1.f / rooteps;
850     roottol = sqrt(*tol);
851
852
853     emptsw = *n * (*n - 1) / 2;
854     notrot = 0;
855     fastr[0] = 0.f;
856
857
858     swband = 0;
859 /* [TP] SWBAND is a tuning parameter. It is meaningful and effective */
860 /*     if SGESVJ is used as a computational routine in the preconditioned */
861 /*     Jacobi SVD algorithm SGESVJ. For sweeps i=1:SWBAND the procedure */
862 /*     ...... */
863     kbl = f2cmin(8,*n);
864 /* [TP] KBL is a tuning parameter that defines the tile size in the */
865 /*     tiling of the p-q loops of pivot pairs. In general, an optimal */
866 /*     value of KBL depends on the matrix dimensions and on the */
867 /*     parameters of the computer's memory. */
868
869     nbl = *n / kbl;
870     if (nbl * kbl != *n) {
871         ++nbl;
872     }
873 /* Computing 2nd power */
874     i__1 = kbl;
875     blskip = i__1 * i__1 + 1;
876 /* [TP] BLKSKIP is a tuning parameter that depends on SWBAND and KBL. */
877     rowskip = f2cmin(5,kbl);
878 /* [TP] ROWSKIP is a tuning parameter. */
879     lkahead = 1;
880 /* [TP] LKAHEAD is a tuning parameter. */
881     swband = 0;
882     pskipped = 0;
883
884     i__1 = *nsweep;
885     for (i__ = 1; i__ <= i__1; ++i__) {
886
887         mxaapq = 0.f;
888         mxsinj = 0.f;
889         iswrot = 0;
890
891         notrot = 0;
892         pskipped = 0;
893
894         i__2 = nbl;
895         for (ibr = 1; ibr <= i__2; ++ibr) {
896             igl = (ibr - 1) * kbl + 1;
897
898 /* Computing MIN */
899             i__4 = lkahead, i__5 = nbl - ibr;
900             i__3 = f2cmin(i__4,i__5);
901             for (ir1 = 0; ir1 <= i__3; ++ir1) {
902
903                 igl += ir1 * kbl;
904
905 /* Computing MIN */
906                 i__5 = igl + kbl - 1, i__6 = *n - 1;
907                 i__4 = f2cmin(i__5,i__6);
908                 for (p = igl; p <= i__4; ++p) {
909                     i__5 = *n - p + 1;
910                     q = isamax_(&i__5, &sva[p], &c__1) + p - 1;
911                     if (p != q) {
912                         sswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 + 
913                                 1], &c__1);
914                         if (rsvec) {
915                             sswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * 
916                                     v_dim1 + 1], &c__1);
917                         }
918                         temp1 = sva[p];
919                         sva[p] = sva[q];
920                         sva[q] = temp1;
921                         temp1 = d__[p];
922                         d__[p] = d__[q];
923                         d__[q] = temp1;
924                     }
925
926                     if (ir1 == 0) {
927
928 /*        Column norms are periodically updated by explicit */
929 /*        norm computation. */
930 /*        Caveat: */
931 /*        Some BLAS implementations compute SNRM2(M,A(1,p),1) */
932 /*        as SQRT(SDOT(M,A(1,p),1,A(1,p),1)), which may result in */
933 /*        overflow for ||A(:,p)||_2 > SQRT(overflow_threshold), and */
934 /*        undeflow for ||A(:,p)||_2 < SQRT(underflow_threshold). */
935 /*        Hence, SNRM2 cannot be trusted, not even in the case when */
936 /*        the true norm is far from the under(over)flow boundaries. */
937 /*        If properly implemented SNRM2 is available, the IF-THEN-ELSE */
938 /*        below should read "AAPP = SNRM2( M, A(1,p), 1 ) * D(p)". */
939
940                         if (sva[p] < rootbig && sva[p] > rootsfmin) {
941                             sva[p] = snrm2_(m, &a[p * a_dim1 + 1], &c__1) * 
942                                     d__[p];
943                         } else {
944                             temp1 = 0.f;
945                             aapp = 1.f;
946                             slassq_(m, &a[p * a_dim1 + 1], &c__1, &temp1, &
947                                     aapp);
948                             sva[p] = temp1 * sqrt(aapp) * d__[p];
949                         }
950                         aapp = sva[p];
951                     } else {
952                         aapp = sva[p];
953                     }
954
955                     if (aapp > 0.f) {
956
957                         pskipped = 0;
958
959 /* Computing MIN */
960                         i__6 = igl + kbl - 1;
961                         i__5 = f2cmin(i__6,*n);
962                         for (q = p + 1; q <= i__5; ++q) {
963
964                             aaqq = sva[q];
965                             if (aaqq > 0.f) {
966
967                                 aapp0 = aapp;
968                                 if (aaqq >= 1.f) {
969                                     rotok = small * aapp <= aaqq;
970                                     if (aapp < big / aaqq) {
971                                         aapq = sdot_(m, &a[p * a_dim1 + 1], &
972                                                 c__1, &a[q * a_dim1 + 1], &
973                                                 c__1) * d__[p] * d__[q] / 
974                                                 aaqq / aapp;
975                                     } else {
976                                         scopy_(m, &a[p * a_dim1 + 1], &c__1, &
977                                                 work[1], &c__1);
978                                         slascl_("G", &c__0, &c__0, &aapp, &
979                                                 d__[p], m, &c__1, &work[1], 
980                                                 lda, &ierr);
981                                         aapq = sdot_(m, &work[1], &c__1, &a[q 
982                                                 * a_dim1 + 1], &c__1) * d__[q]
983                                                  / aaqq;
984                                     }
985                                 } else {
986                                     rotok = aapp <= aaqq / small;
987                                     if (aapp > small / aaqq) {
988                                         aapq = sdot_(m, &a[p * a_dim1 + 1], &
989                                                 c__1, &a[q * a_dim1 + 1], &
990                                                 c__1) * d__[p] * d__[q] / 
991                                                 aaqq / aapp;
992                                     } else {
993                                         scopy_(m, &a[q * a_dim1 + 1], &c__1, &
994                                                 work[1], &c__1);
995                                         slascl_("G", &c__0, &c__0, &aaqq, &
996                                                 d__[q], m, &c__1, &work[1], 
997                                                 lda, &ierr);
998                                         aapq = sdot_(m, &work[1], &c__1, &a[p 
999                                                 * a_dim1 + 1], &c__1) * d__[p]
1000                                                  / aapp;
1001                                     }
1002                                 }
1003
1004 /* Computing MAX */
1005                                 r__1 = mxaapq, r__2 = abs(aapq);
1006                                 mxaapq = f2cmax(r__1,r__2);
1007
1008 /*        TO rotate or NOT to rotate, THAT is the question ... */
1009
1010                                 if (abs(aapq) > *tol) {
1011
1012 /*           ROTATED = ROTATED + ONE */
1013
1014                                     if (ir1 == 0) {
1015                                         notrot = 0;
1016                                         pskipped = 0;
1017                                         ++iswrot;
1018                                     }
1019
1020                                     if (rotok) {
1021
1022                                         aqoap = aaqq / aapp;
1023                                         apoaq = aapp / aaqq;
1024                                         theta = (r__1 = aqoap - apoaq, abs(
1025                                                 r__1)) * -.5f / aapq;
1026
1027                                         if (abs(theta) > bigtheta) {
1028
1029                                             t = .5f / theta;
1030                                             fastr[2] = t * d__[p] / d__[q];
1031                                             fastr[3] = -t * d__[q] / d__[p];
1032                                             srotm_(m, &a[p * a_dim1 + 1], &
1033                                                     c__1, &a[q * a_dim1 + 1], 
1034                                                     &c__1, fastr);
1035                                             if (rsvec) {
1036                           srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * 
1037                                   v_dim1 + 1], &c__1, fastr);
1038                                             }
1039 /* Computing MAX */
1040                                             r__1 = 0.f, r__2 = t * apoaq * 
1041                                                     aapq + 1.f;
1042                                             sva[q] = aaqq * sqrt((f2cmax(r__1,
1043                                                     r__2)));
1044 /* Computing MAX */
1045                                             r__1 = 0.f, r__2 = 1.f - t * 
1046                                                     aqoap * aapq;
1047                                             aapp *= sqrt((f2cmax(r__1,r__2)));
1048 /* Computing MAX */
1049                                             r__1 = mxsinj, r__2 = abs(t);
1050                                             mxsinj = f2cmax(r__1,r__2);
1051
1052                                         } else {
1053
1054
1055                                             thsign = -r_sign(&c_b42, &aapq);
1056                                             t = 1.f / (theta + thsign * sqrt(
1057                                                     theta * theta + 1.f));
1058                                             cs = sqrt(1.f / (t * t + 1.f));
1059                                             sn = t * cs;
1060
1061 /* Computing MAX */
1062                                             r__1 = mxsinj, r__2 = abs(sn);
1063                                             mxsinj = f2cmax(r__1,r__2);
1064 /* Computing MAX */
1065                                             r__1 = 0.f, r__2 = t * apoaq * 
1066                                                     aapq + 1.f;
1067                                             sva[q] = aaqq * sqrt((f2cmax(r__1,
1068                                                     r__2)));
1069 /* Computing MAX */
1070                                             r__1 = 0.f, r__2 = 1.f - t * 
1071                                                     aqoap * aapq;
1072                                             aapp *= sqrt((f2cmax(r__1,r__2)));
1073
1074                                             apoaq = d__[p] / d__[q];
1075                                             aqoap = d__[q] / d__[p];
1076                                             if (d__[p] >= 1.f) {
1077                           if (d__[q] >= 1.f) {
1078                               fastr[2] = t * apoaq;
1079                               fastr[3] = -t * aqoap;
1080                               d__[p] *= cs;
1081                               d__[q] *= cs;
1082                               srotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q * 
1083                                       a_dim1 + 1], &c__1, fastr);
1084                               if (rsvec) {
1085                                   srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
1086                                           q * v_dim1 + 1], &c__1, fastr);
1087                               }
1088                           } else {
1089                               r__1 = -t * aqoap;
1090                               saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
1091                                       p * a_dim1 + 1], &c__1);
1092                               r__1 = cs * sn * apoaq;
1093                               saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
1094                                       q * a_dim1 + 1], &c__1);
1095                               d__[p] *= cs;
1096                               d__[q] /= cs;
1097                               if (rsvec) {
1098                                   r__1 = -t * aqoap;
1099                                   saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
1100                                           c__1, &v[p * v_dim1 + 1], &c__1);
1101                                   r__1 = cs * sn * apoaq;
1102                                   saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
1103                                           c__1, &v[q * v_dim1 + 1], &c__1);
1104                               }
1105                           }
1106                                             } else {
1107                           if (d__[q] >= 1.f) {
1108                               r__1 = t * apoaq;
1109                               saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
1110                                       q * a_dim1 + 1], &c__1);
1111                               r__1 = -cs * sn * aqoap;
1112                               saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
1113                                       p * a_dim1 + 1], &c__1);
1114                               d__[p] /= cs;
1115                               d__[q] *= cs;
1116                               if (rsvec) {
1117                                   r__1 = t * apoaq;
1118                                   saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
1119                                           c__1, &v[q * v_dim1 + 1], &c__1);
1120                                   r__1 = -cs * sn * aqoap;
1121                                   saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
1122                                           c__1, &v[p * v_dim1 + 1], &c__1);
1123                               }
1124                           } else {
1125                               if (d__[p] >= d__[q]) {
1126                                   r__1 = -t * aqoap;
1127                                   saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, 
1128                                           &a[p * a_dim1 + 1], &c__1);
1129                                   r__1 = cs * sn * apoaq;
1130                                   saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, 
1131                                           &a[q * a_dim1 + 1], &c__1);
1132                                   d__[p] *= cs;
1133                                   d__[q] /= cs;
1134                                   if (rsvec) {
1135                                       r__1 = -t * aqoap;
1136                                       saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], 
1137                                               &c__1, &v[p * v_dim1 + 1], &
1138                                               c__1);
1139                                       r__1 = cs * sn * apoaq;
1140                                       saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], 
1141                                               &c__1, &v[q * v_dim1 + 1], &
1142                                               c__1);
1143                                   }
1144                               } else {
1145                                   r__1 = t * apoaq;
1146                                   saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, 
1147                                           &a[q * a_dim1 + 1], &c__1);
1148                                   r__1 = -cs * sn * aqoap;
1149                                   saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, 
1150                                           &a[p * a_dim1 + 1], &c__1);
1151                                   d__[p] /= cs;
1152                                   d__[q] *= cs;
1153                                   if (rsvec) {
1154                                       r__1 = t * apoaq;
1155                                       saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], 
1156                                               &c__1, &v[q * v_dim1 + 1], &
1157                                               c__1);
1158                                       r__1 = -cs * sn * aqoap;
1159                                       saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], 
1160                                               &c__1, &v[p * v_dim1 + 1], &
1161                                               c__1);
1162                                   }
1163                               }
1164                           }
1165                                             }
1166                                         }
1167
1168                                     } else {
1169                                         scopy_(m, &a[p * a_dim1 + 1], &c__1, &
1170                                                 work[1], &c__1);
1171                                         slascl_("G", &c__0, &c__0, &aapp, &
1172                                                 c_b42, m, &c__1, &work[1], 
1173                                                 lda, &ierr);
1174                                         slascl_("G", &c__0, &c__0, &aaqq, &
1175                                                 c_b42, m, &c__1, &a[q * 
1176                                                 a_dim1 + 1], lda, &ierr);
1177                                         temp1 = -aapq * d__[p] / d__[q];
1178                                         saxpy_(m, &temp1, &work[1], &c__1, &a[
1179                                                 q * a_dim1 + 1], &c__1);
1180                                         slascl_("G", &c__0, &c__0, &c_b42, &
1181                                                 aaqq, m, &c__1, &a[q * a_dim1 
1182                                                 + 1], lda, &ierr);
1183 /* Computing MAX */
1184                                         r__1 = 0.f, r__2 = 1.f - aapq * aapq;
1185                                         sva[q] = aaqq * sqrt((f2cmax(r__1,r__2)))
1186                                                 ;
1187                                         mxsinj = f2cmax(mxsinj,*sfmin);
1188                                     }
1189 /*           END IF ROTOK THEN ... ELSE */
1190
1191 /*           In the case of cancellation in updating SVA(q), SVA(p) */
1192 /*           recompute SVA(q), SVA(p). */
1193 /* Computing 2nd power */
1194                                     r__1 = sva[q] / aaqq;
1195                                     if (r__1 * r__1 <= rooteps) {
1196                                         if (aaqq < rootbig && aaqq > 
1197                                                 rootsfmin) {
1198                                             sva[q] = snrm2_(m, &a[q * a_dim1 
1199                                                     + 1], &c__1) * d__[q];
1200                                         } else {
1201                                             t = 0.f;
1202                                             aaqq = 1.f;
1203                                             slassq_(m, &a[q * a_dim1 + 1], &
1204                                                     c__1, &t, &aaqq);
1205                                             sva[q] = t * sqrt(aaqq) * d__[q];
1206                                         }
1207                                     }
1208                                     if (aapp / aapp0 <= rooteps) {
1209                                         if (aapp < rootbig && aapp > 
1210                                                 rootsfmin) {
1211                                             aapp = snrm2_(m, &a[p * a_dim1 + 
1212                                                     1], &c__1) * d__[p];
1213                                         } else {
1214                                             t = 0.f;
1215                                             aapp = 1.f;
1216                                             slassq_(m, &a[p * a_dim1 + 1], &
1217                                                     c__1, &t, &aapp);
1218                                             aapp = t * sqrt(aapp) * d__[p];
1219                                         }
1220                                         sva[p] = aapp;
1221                                     }
1222
1223                                 } else {
1224 /*        A(:,p) and A(:,q) already numerically orthogonal */
1225                                     if (ir1 == 0) {
1226                                         ++notrot;
1227                                     }
1228                                     ++pskipped;
1229                                 }
1230                             } else {
1231 /*        A(:,q) is zero column */
1232                                 if (ir1 == 0) {
1233                                     ++notrot;
1234                                 }
1235                                 ++pskipped;
1236                             }
1237
1238                             if (i__ <= swband && pskipped > rowskip) {
1239                                 if (ir1 == 0) {
1240                                     aapp = -aapp;
1241                                 }
1242                                 notrot = 0;
1243                                 goto L2103;
1244                             }
1245
1246 /* L2002: */
1247                         }
1248 /*     END q-LOOP */
1249
1250 L2103:
1251 /*     bailed out of q-loop */
1252                         sva[p] = aapp;
1253                     } else {
1254                         sva[p] = aapp;
1255                         if (ir1 == 0 && aapp == 0.f) {
1256 /* Computing MIN */
1257                             i__5 = igl + kbl - 1;
1258                             notrot = notrot + f2cmin(i__5,*n) - p;
1259                         }
1260                     }
1261
1262 /* L2001: */
1263                 }
1264 /*     end of the p-loop */
1265 /*     end of doing the block ( ibr, ibr ) */
1266 /* L1002: */
1267             }
1268 /*     end of ir1-loop */
1269
1270 /* ........................................................ */
1271 /* ... go to the off diagonal blocks */
1272
1273             igl = (ibr - 1) * kbl + 1;
1274
1275             i__3 = nbl;
1276             for (jbc = ibr + 1; jbc <= i__3; ++jbc) {
1277
1278                 jgl = (jbc - 1) * kbl + 1;
1279
1280 /*        doing the block at ( ibr, jbc ) */
1281
1282                 ijblsk = 0;
1283 /* Computing MIN */
1284                 i__5 = igl + kbl - 1;
1285                 i__4 = f2cmin(i__5,*n);
1286                 for (p = igl; p <= i__4; ++p) {
1287
1288                     aapp = sva[p];
1289
1290                     if (aapp > 0.f) {
1291
1292                         pskipped = 0;
1293
1294 /* Computing MIN */
1295                         i__6 = jgl + kbl - 1;
1296                         i__5 = f2cmin(i__6,*n);
1297                         for (q = jgl; q <= i__5; ++q) {
1298
1299                             aaqq = sva[q];
1300
1301                             if (aaqq > 0.f) {
1302                                 aapp0 = aapp;
1303
1304
1305
1306                                 if (aaqq >= 1.f) {
1307                                     if (aapp >= aaqq) {
1308                                         rotok = small * aapp <= aaqq;
1309                                     } else {
1310                                         rotok = small * aaqq <= aapp;
1311                                     }
1312                                     if (aapp < big / aaqq) {
1313                                         aapq = sdot_(m, &a[p * a_dim1 + 1], &
1314                                                 c__1, &a[q * a_dim1 + 1], &
1315                                                 c__1) * d__[p] * d__[q] / 
1316                                                 aaqq / aapp;
1317                                     } else {
1318                                         scopy_(m, &a[p * a_dim1 + 1], &c__1, &
1319                                                 work[1], &c__1);
1320                                         slascl_("G", &c__0, &c__0, &aapp, &
1321                                                 d__[p], m, &c__1, &work[1], 
1322                                                 lda, &ierr);
1323                                         aapq = sdot_(m, &work[1], &c__1, &a[q 
1324                                                 * a_dim1 + 1], &c__1) * d__[q]
1325                                                  / aaqq;
1326                                     }
1327                                 } else {
1328                                     if (aapp >= aaqq) {
1329                                         rotok = aapp <= aaqq / small;
1330                                     } else {
1331                                         rotok = aaqq <= aapp / small;
1332                                     }
1333                                     if (aapp > small / aaqq) {
1334                                         aapq = sdot_(m, &a[p * a_dim1 + 1], &
1335                                                 c__1, &a[q * a_dim1 + 1], &
1336                                                 c__1) * d__[p] * d__[q] / 
1337                                                 aaqq / aapp;
1338                                     } else {
1339                                         scopy_(m, &a[q * a_dim1 + 1], &c__1, &
1340                                                 work[1], &c__1);
1341                                         slascl_("G", &c__0, &c__0, &aaqq, &
1342                                                 d__[q], m, &c__1, &work[1], 
1343                                                 lda, &ierr);
1344                                         aapq = sdot_(m, &work[1], &c__1, &a[p 
1345                                                 * a_dim1 + 1], &c__1) * d__[p]
1346                                                  / aapp;
1347                                     }
1348                                 }
1349
1350 /* Computing MAX */
1351                                 r__1 = mxaapq, r__2 = abs(aapq);
1352                                 mxaapq = f2cmax(r__1,r__2);
1353
1354 /*        TO rotate or NOT to rotate, THAT is the question ... */
1355
1356                                 if (abs(aapq) > *tol) {
1357                                     notrot = 0;
1358 /*           ROTATED  = ROTATED + 1 */
1359                                     pskipped = 0;
1360                                     ++iswrot;
1361
1362                                     if (rotok) {
1363
1364                                         aqoap = aaqq / aapp;
1365                                         apoaq = aapp / aaqq;
1366                                         theta = (r__1 = aqoap - apoaq, abs(
1367                                                 r__1)) * -.5f / aapq;
1368                                         if (aaqq > aapp0) {
1369                                             theta = -theta;
1370                                         }
1371
1372                                         if (abs(theta) > bigtheta) {
1373                                             t = .5f / theta;
1374                                             fastr[2] = t * d__[p] / d__[q];
1375                                             fastr[3] = -t * d__[q] / d__[p];
1376                                             srotm_(m, &a[p * a_dim1 + 1], &
1377                                                     c__1, &a[q * a_dim1 + 1], 
1378                                                     &c__1, fastr);
1379                                             if (rsvec) {
1380                           srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * 
1381                                   v_dim1 + 1], &c__1, fastr);
1382                                             }
1383 /* Computing MAX */
1384                                             r__1 = 0.f, r__2 = t * apoaq * 
1385                                                     aapq + 1.f;
1386                                             sva[q] = aaqq * sqrt((f2cmax(r__1,
1387                                                     r__2)));
1388 /* Computing MAX */
1389                                             r__1 = 0.f, r__2 = 1.f - t * 
1390                                                     aqoap * aapq;
1391                                             aapp *= sqrt((f2cmax(r__1,r__2)));
1392 /* Computing MAX */
1393                                             r__1 = mxsinj, r__2 = abs(t);
1394                                             mxsinj = f2cmax(r__1,r__2);
1395                                         } else {
1396
1397
1398                                             thsign = -r_sign(&c_b42, &aapq);
1399                                             if (aaqq > aapp0) {
1400                           thsign = -thsign;
1401                                             }
1402                                             t = 1.f / (theta + thsign * sqrt(
1403                                                     theta * theta + 1.f));
1404                                             cs = sqrt(1.f / (t * t + 1.f));
1405                                             sn = t * cs;
1406 /* Computing MAX */
1407                                             r__1 = mxsinj, r__2 = abs(sn);
1408                                             mxsinj = f2cmax(r__1,r__2);
1409 /* Computing MAX */
1410                                             r__1 = 0.f, r__2 = t * apoaq * 
1411                                                     aapq + 1.f;
1412                                             sva[q] = aaqq * sqrt((f2cmax(r__1,
1413                                                     r__2)));
1414 /* Computing MAX */
1415                                             r__1 = 0.f, r__2 = 1.f - t * 
1416                                                     aqoap * aapq;
1417                                             aapp *= sqrt((f2cmax(r__1,r__2)));
1418
1419                                             apoaq = d__[p] / d__[q];
1420                                             aqoap = d__[q] / d__[p];
1421                                             if (d__[p] >= 1.f) {
1422
1423                           if (d__[q] >= 1.f) {
1424                               fastr[2] = t * apoaq;
1425                               fastr[3] = -t * aqoap;
1426                               d__[p] *= cs;
1427                               d__[q] *= cs;
1428                               srotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q * 
1429                                       a_dim1 + 1], &c__1, fastr);
1430                               if (rsvec) {
1431                                   srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
1432                                           q * v_dim1 + 1], &c__1, fastr);
1433                               }
1434                           } else {
1435                               r__1 = -t * aqoap;
1436                               saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
1437                                       p * a_dim1 + 1], &c__1);
1438                               r__1 = cs * sn * apoaq;
1439                               saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
1440                                       q * a_dim1 + 1], &c__1);
1441                               if (rsvec) {
1442                                   r__1 = -t * aqoap;
1443                                   saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
1444                                           c__1, &v[p * v_dim1 + 1], &c__1);
1445                                   r__1 = cs * sn * apoaq;
1446                                   saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
1447                                           c__1, &v[q * v_dim1 + 1], &c__1);
1448                               }
1449                               d__[p] *= cs;
1450                               d__[q] /= cs;
1451                           }
1452                                             } else {
1453                           if (d__[q] >= 1.f) {
1454                               r__1 = t * apoaq;
1455                               saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
1456                                       q * a_dim1 + 1], &c__1);
1457                               r__1 = -cs * sn * aqoap;
1458                               saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
1459                                       p * a_dim1 + 1], &c__1);
1460                               if (rsvec) {
1461                                   r__1 = t * apoaq;
1462                                   saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
1463                                           c__1, &v[q * v_dim1 + 1], &c__1);
1464                                   r__1 = -cs * sn * aqoap;
1465                                   saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
1466                                           c__1, &v[p * v_dim1 + 1], &c__1);
1467                               }
1468                               d__[p] /= cs;
1469                               d__[q] *= cs;
1470                           } else {
1471                               if (d__[p] >= d__[q]) {
1472                                   r__1 = -t * aqoap;
1473                                   saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, 
1474                                           &a[p * a_dim1 + 1], &c__1);
1475                                   r__1 = cs * sn * apoaq;
1476                                   saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, 
1477                                           &a[q * a_dim1 + 1], &c__1);
1478                                   d__[p] *= cs;
1479                                   d__[q] /= cs;
1480                                   if (rsvec) {
1481                                       r__1 = -t * aqoap;
1482                                       saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], 
1483                                               &c__1, &v[p * v_dim1 + 1], &
1484                                               c__1);
1485                                       r__1 = cs * sn * apoaq;
1486                                       saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], 
1487                                               &c__1, &v[q * v_dim1 + 1], &
1488                                               c__1);
1489                                   }
1490                               } else {
1491                                   r__1 = t * apoaq;
1492                                   saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, 
1493                                           &a[q * a_dim1 + 1], &c__1);
1494                                   r__1 = -cs * sn * aqoap;
1495                                   saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, 
1496                                           &a[p * a_dim1 + 1], &c__1);
1497                                   d__[p] /= cs;
1498                                   d__[q] *= cs;
1499                                   if (rsvec) {
1500                                       r__1 = t * apoaq;
1501                                       saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], 
1502                                               &c__1, &v[q * v_dim1 + 1], &
1503                                               c__1);
1504                                       r__1 = -cs * sn * aqoap;
1505                                       saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], 
1506                                               &c__1, &v[p * v_dim1 + 1], &
1507                                               c__1);
1508                                   }
1509                               }
1510                           }
1511                                             }
1512                                         }
1513
1514                                     } else {
1515                                         if (aapp > aaqq) {
1516                                             scopy_(m, &a[p * a_dim1 + 1], &
1517                                                     c__1, &work[1], &c__1);
1518                                             slascl_("G", &c__0, &c__0, &aapp, 
1519                                                     &c_b42, m, &c__1, &work[1]
1520                                                     , lda, &ierr);
1521                                             slascl_("G", &c__0, &c__0, &aaqq, 
1522                                                     &c_b42, m, &c__1, &a[q * 
1523                                                     a_dim1 + 1], lda, &ierr);
1524                                             temp1 = -aapq * d__[p] / d__[q];
1525                                             saxpy_(m, &temp1, &work[1], &c__1,
1526                                                      &a[q * a_dim1 + 1], &
1527                                                     c__1);
1528                                             slascl_("G", &c__0, &c__0, &c_b42,
1529                                                      &aaqq, m, &c__1, &a[q * 
1530                                                     a_dim1 + 1], lda, &ierr);
1531 /* Computing MAX */
1532                                             r__1 = 0.f, r__2 = 1.f - aapq * 
1533                                                     aapq;
1534                                             sva[q] = aaqq * sqrt((f2cmax(r__1,
1535                                                     r__2)));
1536                                             mxsinj = f2cmax(mxsinj,*sfmin);
1537                                         } else {
1538                                             scopy_(m, &a[q * a_dim1 + 1], &
1539                                                     c__1, &work[1], &c__1);
1540                                             slascl_("G", &c__0, &c__0, &aaqq, 
1541                                                     &c_b42, m, &c__1, &work[1]
1542                                                     , lda, &ierr);
1543                                             slascl_("G", &c__0, &c__0, &aapp, 
1544                                                     &c_b42, m, &c__1, &a[p * 
1545                                                     a_dim1 + 1], lda, &ierr);
1546                                             temp1 = -aapq * d__[q] / d__[p];
1547                                             saxpy_(m, &temp1, &work[1], &c__1,
1548                                                      &a[p * a_dim1 + 1], &
1549                                                     c__1);
1550                                             slascl_("G", &c__0, &c__0, &c_b42,
1551                                                      &aapp, m, &c__1, &a[p * 
1552                                                     a_dim1 + 1], lda, &ierr);
1553 /* Computing MAX */
1554                                             r__1 = 0.f, r__2 = 1.f - aapq * 
1555                                                     aapq;
1556                                             sva[p] = aapp * sqrt((f2cmax(r__1,
1557                                                     r__2)));
1558                                             mxsinj = f2cmax(mxsinj,*sfmin);
1559                                         }
1560                                     }
1561 /*           END IF ROTOK THEN ... ELSE */
1562
1563 /*           In the case of cancellation in updating SVA(q) */
1564 /* Computing 2nd power */
1565                                     r__1 = sva[q] / aaqq;
1566                                     if (r__1 * r__1 <= rooteps) {
1567                                         if (aaqq < rootbig && aaqq > 
1568                                                 rootsfmin) {
1569                                             sva[q] = snrm2_(m, &a[q * a_dim1 
1570                                                     + 1], &c__1) * d__[q];
1571                                         } else {
1572                                             t = 0.f;
1573                                             aaqq = 1.f;
1574                                             slassq_(m, &a[q * a_dim1 + 1], &
1575                                                     c__1, &t, &aaqq);
1576                                             sva[q] = t * sqrt(aaqq) * d__[q];
1577                                         }
1578                                     }
1579 /* Computing 2nd power */
1580                                     r__1 = aapp / aapp0;
1581                                     if (r__1 * r__1 <= rooteps) {
1582                                         if (aapp < rootbig && aapp > 
1583                                                 rootsfmin) {
1584                                             aapp = snrm2_(m, &a[p * a_dim1 + 
1585                                                     1], &c__1) * d__[p];
1586                                         } else {
1587                                             t = 0.f;
1588                                             aapp = 1.f;
1589                                             slassq_(m, &a[p * a_dim1 + 1], &
1590                                                     c__1, &t, &aapp);
1591                                             aapp = t * sqrt(aapp) * d__[p];
1592                                         }
1593                                         sva[p] = aapp;
1594                                     }
1595 /*              end of OK rotation */
1596                                 } else {
1597                                     ++notrot;
1598                                     ++pskipped;
1599                                     ++ijblsk;
1600                                 }
1601                             } else {
1602                                 ++notrot;
1603                                 ++pskipped;
1604                                 ++ijblsk;
1605                             }
1606
1607                             if (i__ <= swband && ijblsk >= blskip) {
1608                                 sva[p] = aapp;
1609                                 notrot = 0;
1610                                 goto L2011;
1611                             }
1612                             if (i__ <= swband && pskipped > rowskip) {
1613                                 aapp = -aapp;
1614                                 notrot = 0;
1615                                 goto L2203;
1616                             }
1617
1618 /* L2200: */
1619                         }
1620 /*        end of the q-loop */
1621 L2203:
1622
1623                         sva[p] = aapp;
1624
1625                     } else {
1626                         if (aapp == 0.f) {
1627 /* Computing MIN */
1628                             i__5 = jgl + kbl - 1;
1629                             notrot = notrot + f2cmin(i__5,*n) - jgl + 1;
1630                         }
1631                         if (aapp < 0.f) {
1632                             notrot = 0;
1633                         }
1634                     }
1635 /* L2100: */
1636                 }
1637 /*     end of the p-loop */
1638 /* L2010: */
1639             }
1640 /*     end of the jbc-loop */
1641 L2011:
1642 /* 2011 bailed out of the jbc-loop */
1643 /* Computing MIN */
1644             i__4 = igl + kbl - 1;
1645             i__3 = f2cmin(i__4,*n);
1646             for (p = igl; p <= i__3; ++p) {
1647                 sva[p] = (r__1 = sva[p], abs(r__1));
1648 /* L2012: */
1649             }
1650
1651 /* L2000: */
1652         }
1653 /* 2000 :: end of the ibr-loop */
1654
1655         if (sva[*n] < rootbig && sva[*n] > rootsfmin) {
1656             sva[*n] = snrm2_(m, &a[*n * a_dim1 + 1], &c__1) * d__[*n];
1657         } else {
1658             t = 0.f;
1659             aapp = 1.f;
1660             slassq_(m, &a[*n * a_dim1 + 1], &c__1, &t, &aapp);
1661             sva[*n] = t * sqrt(aapp) * d__[*n];
1662         }
1663
1664 /*     Additional steering devices */
1665
1666         if (i__ < swband && (mxaapq <= roottol || iswrot <= *n)) {
1667             swband = i__;
1668         }
1669
1670         if (i__ > swband + 1 && mxaapq < (real) (*n) * *tol && (real) (*n) * 
1671                 mxaapq * mxsinj < *tol) {
1672             goto L1994;
1673         }
1674
1675         if (notrot >= emptsw) {
1676             goto L1994;
1677         }
1678 /* L1993: */
1679     }
1680 /*     end i=1:NSWEEP loop */
1681 /* #:) Reaching this point means that the procedure has completed the given */
1682 /*     number of iterations. */
1683     *info = *nsweep - 1;
1684     goto L1995;
1685 L1994:
1686 /* #:) Reaching this point means that during the i-th sweep all pivots were */
1687 /*     below the given tolerance, causing early exit. */
1688
1689     *info = 0;
1690 /* #:) INFO = 0 confirms successful iterations. */
1691 L1995:
1692
1693 /*     Sort the vector D. */
1694     i__1 = *n - 1;
1695     for (p = 1; p <= i__1; ++p) {
1696         i__2 = *n - p + 1;
1697         q = isamax_(&i__2, &sva[p], &c__1) + p - 1;
1698         if (p != q) {
1699             temp1 = sva[p];
1700             sva[p] = sva[q];
1701             sva[q] = temp1;
1702             temp1 = d__[p];
1703             d__[p] = d__[q];
1704             d__[q] = temp1;
1705             sswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 + 1], &c__1);
1706             if (rsvec) {
1707                 sswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * v_dim1 + 1], &
1708                         c__1);
1709             }
1710         }
1711 /* L5991: */
1712     }
1713
1714     return 0;
1715 } /* sgsvj0_ */
1716