C_LAPACK: Fixes to make it compile with MSVC (#3605)
[platform/upstream/openblas.git] / lapack-netlib / TESTING / MATGEN / clatme.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 complex c_b1 = {0.f,0.f};
516 static complex c_b2 = {1.f,0.f};
517 static integer c__1 = 1;
518 static integer c__0 = 0;
519 static integer c__5 = 5;
520
521 /* > \brief \b CLATME */
522
523 /*  =========== DOCUMENTATION =========== */
524
525 /* Online html documentation available at */
526 /*            http://www.netlib.org/lapack/explore-html/ */
527
528 /*  Definition: */
529 /*  =========== */
530
531 /*       SUBROUTINE CLATME( N, DIST, ISEED, D, MODE, COND, DMAX, */
532 /*         RSIGN, */
533 /*                          UPPER, SIM, DS, MODES, CONDS, KL, KU, ANORM, */
534 /*         A, */
535 /*                          LDA, WORK, INFO ) */
536
537 /*       CHARACTER          DIST, RSIGN, SIM, UPPER */
538 /*       INTEGER            INFO, KL, KU, LDA, MODE, MODES, N */
539 /*       REAL               ANORM, COND, CONDS */
540 /*       COMPLEX            DMAX */
541 /*       INTEGER            ISEED( 4 ) */
542 /*       REAL               DS( * ) */
543 /*       COMPLEX            A( LDA, * ), D( * ), WORK( * ) */
544
545
546 /* > \par Purpose: */
547 /*  ============= */
548 /* > */
549 /* > \verbatim */
550 /* > */
551 /* >    CLATME generates random non-symmetric square matrices with */
552 /* >    specified eigenvalues for testing LAPACK programs. */
553 /* > */
554 /* >    CLATME operates by applying the following sequence of */
555 /* >    operations: */
556 /* > */
557 /* >    1. Set the diagonal to D, where D may be input or */
558 /* >         computed according to MODE, COND, DMAX, and RSIGN */
559 /* >         as described below. */
560 /* > */
561 /* >    2. If UPPER='T', the upper triangle of A is set to random values */
562 /* >         out of distribution DIST. */
563 /* > */
564 /* >    3. If SIM='T', A is multiplied on the left by a random matrix */
565 /* >         X, whose singular values are specified by DS, MODES, and */
566 /* >         CONDS, and on the right by X inverse. */
567 /* > */
568 /* >    4. If KL < N-1, the lower bandwidth is reduced to KL using */
569 /* >         Householder transformations.  If KU < N-1, the upper */
570 /* >         bandwidth is reduced to KU. */
571 /* > */
572 /* >    5. If ANORM is not negative, the matrix is scaled to have */
573 /* >         maximum-element-norm ANORM. */
574 /* > */
575 /* >    (Note: since the matrix cannot be reduced beyond Hessenberg form, */
576 /* >     no packing options are available.) */
577 /* > \endverbatim */
578
579 /*  Arguments: */
580 /*  ========== */
581
582 /* > \param[in] N */
583 /* > \verbatim */
584 /* >          N is INTEGER */
585 /* >           The number of columns (or rows) of A. Not modified. */
586 /* > \endverbatim */
587 /* > */
588 /* > \param[in] DIST */
589 /* > \verbatim */
590 /* >          DIST is CHARACTER*1 */
591 /* >           On entry, DIST specifies the type of distribution to be used */
592 /* >           to generate the random eigen-/singular values, and on the */
593 /* >           upper triangle (see UPPER). */
594 /* >           'U' => UNIFORM( 0, 1 )  ( 'U' for uniform ) */
595 /* >           'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
596 /* >           'N' => NORMAL( 0, 1 )   ( 'N' for normal ) */
597 /* >           'D' => uniform on the complex disc |z| < 1. */
598 /* >           Not modified. */
599 /* > \endverbatim */
600 /* > */
601 /* > \param[in,out] ISEED */
602 /* > \verbatim */
603 /* >          ISEED is INTEGER array, dimension ( 4 ) */
604 /* >           On entry ISEED specifies the seed of the random number */
605 /* >           generator. They should lie between 0 and 4095 inclusive, */
606 /* >           and ISEED(4) should be odd. The random number generator */
607 /* >           uses a linear congruential sequence limited to small */
608 /* >           integers, and so should produce machine independent */
609 /* >           random numbers. The values of ISEED are changed on */
610 /* >           exit, and can be used in the next call to CLATME */
611 /* >           to continue the same random number sequence. */
612 /* >           Changed on exit. */
613 /* > \endverbatim */
614 /* > */
615 /* > \param[in,out] D */
616 /* > \verbatim */
617 /* >          D is COMPLEX array, dimension ( N ) */
618 /* >           This array is used to specify the eigenvalues of A.  If */
619 /* >           MODE=0, then D is assumed to contain the eigenvalues */
620 /* >           otherwise they will be computed according to MODE, COND, */
621 /* >           DMAX, and RSIGN and placed in D. */
622 /* >           Modified if MODE is nonzero. */
623 /* > \endverbatim */
624 /* > */
625 /* > \param[in] MODE */
626 /* > \verbatim */
627 /* >          MODE is INTEGER */
628 /* >           On entry this describes how the eigenvalues are to */
629 /* >           be specified: */
630 /* >           MODE = 0 means use D as input */
631 /* >           MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
632 /* >           MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
633 /* >           MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
634 /* >           MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
635 /* >           MODE = 5 sets D to random numbers in the range */
636 /* >                    ( 1/COND , 1 ) such that their logarithms */
637 /* >                    are uniformly distributed. */
638 /* >           MODE = 6 set D to random numbers from same distribution */
639 /* >                    as the rest of the matrix. */
640 /* >           MODE < 0 has the same meaning as ABS(MODE), except that */
641 /* >              the order of the elements of D is reversed. */
642 /* >           Thus if MODE is between 1 and 4, D has entries ranging */
643 /* >              from 1 to 1/COND, if between -1 and -4, D has entries */
644 /* >              ranging from 1/COND to 1, */
645 /* >           Not modified. */
646 /* > \endverbatim */
647 /* > */
648 /* > \param[in] COND */
649 /* > \verbatim */
650 /* >          COND is REAL */
651 /* >           On entry, this is used as described under MODE above. */
652 /* >           If used, it must be >= 1. Not modified. */
653 /* > \endverbatim */
654 /* > */
655 /* > \param[in] DMAX */
656 /* > \verbatim */
657 /* >          DMAX is COMPLEX */
658 /* >           If MODE is neither -6, 0 nor 6, the contents of D, as */
659 /* >           computed according to MODE and COND, will be scaled by */
660 /* >           DMAX / f2cmax(abs(D(i))).  Note that DMAX need not be */
661 /* >           positive or real: if DMAX is negative or complex (or zero), */
662 /* >           D will be scaled by a negative or complex number (or zero). */
663 /* >           If RSIGN='F' then the largest (absolute) eigenvalue will be */
664 /* >           equal to DMAX. */
665 /* >           Not modified. */
666 /* > \endverbatim */
667 /* > */
668 /* > \param[in] RSIGN */
669 /* > \verbatim */
670 /* >          RSIGN is CHARACTER*1 */
671 /* >           If MODE is not 0, 6, or -6, and RSIGN='T', then the */
672 /* >           elements of D, as computed according to MODE and COND, will */
673 /* >           be multiplied by a random complex number from the unit */
674 /* >           circle |z| = 1.  If RSIGN='F', they will not be.  RSIGN may */
675 /* >           only have the values 'T' or 'F'. */
676 /* >           Not modified. */
677 /* > \endverbatim */
678 /* > */
679 /* > \param[in] UPPER */
680 /* > \verbatim */
681 /* >          UPPER is CHARACTER*1 */
682 /* >           If UPPER='T', then the elements of A above the diagonal */
683 /* >           will be set to random numbers out of DIST.  If UPPER='F', */
684 /* >           they will not.  UPPER may only have the values 'T' or 'F'. */
685 /* >           Not modified. */
686 /* > \endverbatim */
687 /* > */
688 /* > \param[in] SIM */
689 /* > \verbatim */
690 /* >          SIM is CHARACTER*1 */
691 /* >           If SIM='T', then A will be operated on by a "similarity */
692 /* >           transform", i.e., multiplied on the left by a matrix X and */
693 /* >           on the right by X inverse.  X = U S V, where U and V are */
694 /* >           random unitary matrices and S is a (diagonal) matrix of */
695 /* >           singular values specified by DS, MODES, and CONDS.  If */
696 /* >           SIM='F', then A will not be transformed. */
697 /* >           Not modified. */
698 /* > \endverbatim */
699 /* > */
700 /* > \param[in,out] DS */
701 /* > \verbatim */
702 /* >          DS is REAL array, dimension ( N ) */
703 /* >           This array is used to specify the singular values of X, */
704 /* >           in the same way that D specifies the eigenvalues of A. */
705 /* >           If MODE=0, the DS contains the singular values, which */
706 /* >           may not be zero. */
707 /* >           Modified if MODE is nonzero. */
708 /* > \endverbatim */
709 /* > */
710 /* > \param[in] MODES */
711 /* > \verbatim */
712 /* >          MODES is INTEGER */
713 /* > \endverbatim */
714 /* > */
715 /* > \param[in] CONDS */
716 /* > \verbatim */
717 /* >          CONDS is REAL */
718 /* >           Similar to MODE and COND, but for specifying the diagonal */
719 /* >           of S.  MODES=-6 and +6 are not allowed (since they would */
720 /* >           result in randomly ill-conditioned eigenvalues.) */
721 /* > \endverbatim */
722 /* > */
723 /* > \param[in] KL */
724 /* > \verbatim */
725 /* >          KL is INTEGER */
726 /* >           This specifies the lower bandwidth of the  matrix.  KL=1 */
727 /* >           specifies upper Hessenberg form.  If KL is at least N-1, */
728 /* >           then A will have full lower bandwidth. */
729 /* >           Not modified. */
730 /* > \endverbatim */
731 /* > */
732 /* > \param[in] KU */
733 /* > \verbatim */
734 /* >          KU is INTEGER */
735 /* >           This specifies the upper bandwidth of the  matrix.  KU=1 */
736 /* >           specifies lower Hessenberg form.  If KU is at least N-1, */
737 /* >           then A will have full upper bandwidth; if KU and KL */
738 /* >           are both at least N-1, then A will be dense.  Only one of */
739 /* >           KU and KL may be less than N-1. */
740 /* >           Not modified. */
741 /* > \endverbatim */
742 /* > */
743 /* > \param[in] ANORM */
744 /* > \verbatim */
745 /* >          ANORM is REAL */
746 /* >           If ANORM is not negative, then A will be scaled by a non- */
747 /* >           negative real number to make the maximum-element-norm of A */
748 /* >           to be ANORM. */
749 /* >           Not modified. */
750 /* > \endverbatim */
751 /* > */
752 /* > \param[out] A */
753 /* > \verbatim */
754 /* >          A is COMPLEX array, dimension ( LDA, N ) */
755 /* >           On exit A is the desired test matrix. */
756 /* >           Modified. */
757 /* > \endverbatim */
758 /* > */
759 /* > \param[in] LDA */
760 /* > \verbatim */
761 /* >          LDA is INTEGER */
762 /* >           LDA specifies the first dimension of A as declared in the */
763 /* >           calling program.  LDA must be at least M. */
764 /* >           Not modified. */
765 /* > \endverbatim */
766 /* > */
767 /* > \param[out] WORK */
768 /* > \verbatim */
769 /* >          WORK is COMPLEX array, dimension ( 3*N ) */
770 /* >           Workspace. */
771 /* >           Modified. */
772 /* > \endverbatim */
773 /* > */
774 /* > \param[out] INFO */
775 /* > \verbatim */
776 /* >          INFO is INTEGER */
777 /* >           Error code.  On exit, INFO will be set to one of the */
778 /* >           following values: */
779 /* >             0 => normal return */
780 /* >            -1 => N negative */
781 /* >            -2 => DIST illegal string */
782 /* >            -5 => MODE not in range -6 to 6 */
783 /* >            -6 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
784 /* >            -9 => RSIGN is not 'T' or 'F' */
785 /* >           -10 => UPPER is not 'T' or 'F' */
786 /* >           -11 => SIM   is not 'T' or 'F' */
787 /* >           -12 => MODES=0 and DS has a zero singular value. */
788 /* >           -13 => MODES is not in the range -5 to 5. */
789 /* >           -14 => MODES is nonzero and CONDS is less than 1. */
790 /* >           -15 => KL is less than 1. */
791 /* >           -16 => KU is less than 1, or KL and KU are both less than */
792 /* >                  N-1. */
793 /* >           -19 => LDA is less than M. */
794 /* >            1  => Error return from CLATM1 (computing D) */
795 /* >            2  => Cannot scale to DMAX (f2cmax. eigenvalue is 0) */
796 /* >            3  => Error return from SLATM1 (computing DS) */
797 /* >            4  => Error return from CLARGE */
798 /* >            5  => Zero singular value from SLATM1. */
799 /* > \endverbatim */
800
801 /*  Authors: */
802 /*  ======== */
803
804 /* > \author Univ. of Tennessee */
805 /* > \author Univ. of California Berkeley */
806 /* > \author Univ. of Colorado Denver */
807 /* > \author NAG Ltd. */
808
809 /* > \date December 2016 */
810
811 /* > \ingroup complex_matgen */
812
813 /*  ===================================================================== */
814 /* Subroutine */ int clatme_(integer *n, char *dist, integer *iseed, complex *
815         d__, integer *mode, real *cond, complex *dmax__, char *rsign, char *
816         upper, char *sim, real *ds, integer *modes, real *conds, integer *kl, 
817         integer *ku, real *anorm, complex *a, integer *lda, complex *work, 
818         integer *info)
819 {
820     /* System generated locals */
821     integer a_dim1, a_offset, i__1, i__2;
822     real r__1, r__2;
823     complex q__1, q__2;
824
825     /* Local variables */
826     logical bads;
827     integer isim;
828     real temp;
829     integer i__, j;
830     extern /* Subroutine */ int cgerc_(integer *, integer *, complex *, 
831             complex *, integer *, complex *, integer *, complex *, integer *);
832     complex alpha;
833     extern /* Subroutine */ int cscal_(integer *, complex *, complex *, 
834             integer *);
835     extern logical lsame_(char *, char *);
836     extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex *
837             , complex *, integer *, complex *, integer *, complex *, complex *
838             , integer *);
839     integer iinfo;
840     real tempa[1];
841     integer icols, idist;
842     extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, 
843             complex *, integer *);
844     integer irows;
845     extern /* Subroutine */ int clatm1_(integer *, real *, integer *, integer 
846             *, integer *, complex *, integer *, integer *), slatm1_(integer *,
847              real *, integer *, integer *, integer *, real *, integer *, 
848             integer *);
849     integer ic, jc;
850     extern real clange_(char *, integer *, integer *, complex *, integer *, 
851             real *);
852     integer ir;
853     extern /* Subroutine */ int clarge_(integer *, complex *, integer *, 
854             integer *, complex *, integer *), clarfg_(integer *, complex *, 
855             complex *, integer *, complex *), clacgv_(integer *, complex *, 
856             integer *);
857     //extern /* Complex */ VOID clarnd_(complex *, integer *, integer *);
858     extern complex clarnd_(integer *, integer *);
859     real ralpha;
860     extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer 
861             *), claset_(char *, integer *, integer *, complex *, complex *, 
862             complex *, integer *), xerbla_(char *, integer *),
863              clarnv_(integer *, integer *, integer *, complex *);
864     integer irsign, iupper;
865     complex xnorms;
866     integer jcr;
867     complex tau;
868
869
870 /*  -- LAPACK computational routine (version 3.7.0) -- */
871 /*  -- LAPACK is a software package provided by Univ. of Tennessee,    -- */
872 /*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
873 /*     December 2016 */
874
875
876 /*  ===================================================================== */
877
878
879 /*     1)      Decode and Test the input parameters. */
880 /*             Initialize flags & seed. */
881
882     /* Parameter adjustments */
883     --iseed;
884     --d__;
885     --ds;
886     a_dim1 = *lda;
887     a_offset = 1 + a_dim1 * 1;
888     a -= a_offset;
889     --work;
890
891     /* Function Body */
892     *info = 0;
893
894 /*     Quick return if possible */
895
896     if (*n == 0) {
897         return 0;
898     }
899
900 /*     Decode DIST */
901
902     if (lsame_(dist, "U")) {
903         idist = 1;
904     } else if (lsame_(dist, "S")) {
905         idist = 2;
906     } else if (lsame_(dist, "N")) {
907         idist = 3;
908     } else if (lsame_(dist, "D")) {
909         idist = 4;
910     } else {
911         idist = -1;
912     }
913
914 /*     Decode RSIGN */
915
916     if (lsame_(rsign, "T")) {
917         irsign = 1;
918     } else if (lsame_(rsign, "F")) {
919         irsign = 0;
920     } else {
921         irsign = -1;
922     }
923
924 /*     Decode UPPER */
925
926     if (lsame_(upper, "T")) {
927         iupper = 1;
928     } else if (lsame_(upper, "F")) {
929         iupper = 0;
930     } else {
931         iupper = -1;
932     }
933
934 /*     Decode SIM */
935
936     if (lsame_(sim, "T")) {
937         isim = 1;
938     } else if (lsame_(sim, "F")) {
939         isim = 0;
940     } else {
941         isim = -1;
942     }
943
944 /*     Check DS, if MODES=0 and ISIM=1 */
945
946     bads = FALSE_;
947     if (*modes == 0 && isim == 1) {
948         i__1 = *n;
949         for (j = 1; j <= i__1; ++j) {
950             if (ds[j] == 0.f) {
951                 bads = TRUE_;
952             }
953 /* L10: */
954         }
955     }
956
957 /*     Set INFO if an error */
958
959     if (*n < 0) {
960         *info = -1;
961     } else if (idist == -1) {
962         *info = -2;
963     } else if (abs(*mode) > 6) {
964         *info = -5;
965     } else if (*mode != 0 && abs(*mode) != 6 && *cond < 1.f) {
966         *info = -6;
967     } else if (irsign == -1) {
968         *info = -9;
969     } else if (iupper == -1) {
970         *info = -10;
971     } else if (isim == -1) {
972         *info = -11;
973     } else if (bads) {
974         *info = -12;
975     } else if (isim == 1 && abs(*modes) > 5) {
976         *info = -13;
977     } else if (isim == 1 && *modes != 0 && *conds < 1.f) {
978         *info = -14;
979     } else if (*kl < 1) {
980         *info = -15;
981     } else if (*ku < 1 || *ku < *n - 1 && *kl < *n - 1) {
982         *info = -16;
983     } else if (*lda < f2cmax(1,*n)) {
984         *info = -19;
985     }
986
987     if (*info != 0) {
988         i__1 = -(*info);
989         xerbla_("CLATME", &i__1);
990         return 0;
991     }
992
993 /*     Initialize random number generator */
994
995     for (i__ = 1; i__ <= 4; ++i__) {
996         iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
997 /* L20: */
998     }
999
1000     if (iseed[4] % 2 != 1) {
1001         ++iseed[4];
1002     }
1003
1004 /*     2)      Set up diagonal of A */
1005
1006 /*             Compute D according to COND and MODE */
1007
1008     clatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], n, &iinfo);
1009     if (iinfo != 0) {
1010         *info = 1;
1011         return 0;
1012     }
1013     if (*mode != 0 && abs(*mode) != 6) {
1014
1015 /*        Scale by DMAX */
1016
1017         temp = c_abs(&d__[1]);
1018         i__1 = *n;
1019         for (i__ = 2; i__ <= i__1; ++i__) {
1020 /* Computing MAX */
1021             r__1 = temp, r__2 = c_abs(&d__[i__]);
1022             temp = f2cmax(r__1,r__2);
1023 /* L30: */
1024         }
1025
1026         if (temp > 0.f) {
1027             q__1.r = dmax__->r / temp, q__1.i = dmax__->i / temp;
1028             alpha.r = q__1.r, alpha.i = q__1.i;
1029         } else {
1030             *info = 2;
1031             return 0;
1032         }
1033
1034         cscal_(n, &alpha, &d__[1], &c__1);
1035
1036     }
1037
1038     claset_("Full", n, n, &c_b1, &c_b1, &a[a_offset], lda);
1039     i__1 = *lda + 1;
1040     ccopy_(n, &d__[1], &c__1, &a[a_offset], &i__1);
1041
1042 /*     3)      If UPPER='T', set upper triangle of A to random numbers. */
1043
1044     if (iupper != 0) {
1045         i__1 = *n;
1046         for (jc = 2; jc <= i__1; ++jc) {
1047             i__2 = jc - 1;
1048             clarnv_(&idist, &iseed[1], &i__2, &a[jc * a_dim1 + 1]);
1049 /* L40: */
1050         }
1051     }
1052
1053 /*     4)      If SIM='T', apply similarity transformation. */
1054
1055 /*                                -1 */
1056 /*             Transform is  X A X  , where X = U S V, thus */
1057
1058 /*             it is  U S V A V' (1/S) U' */
1059
1060     if (isim != 0) {
1061
1062 /*        Compute S (singular values of the eigenvector matrix) */
1063 /*        according to CONDS and MODES */
1064
1065         slatm1_(modes, conds, &c__0, &c__0, &iseed[1], &ds[1], n, &iinfo);
1066         if (iinfo != 0) {
1067             *info = 3;
1068             return 0;
1069         }
1070
1071 /*        Multiply by V and V' */
1072
1073         clarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1074         if (iinfo != 0) {
1075             *info = 4;
1076             return 0;
1077         }
1078
1079 /*        Multiply by S and (1/S) */
1080
1081         i__1 = *n;
1082         for (j = 1; j <= i__1; ++j) {
1083             csscal_(n, &ds[j], &a[j + a_dim1], lda);
1084             if (ds[j] != 0.f) {
1085                 r__1 = 1.f / ds[j];
1086                 csscal_(n, &r__1, &a[j * a_dim1 + 1], &c__1);
1087             } else {
1088                 *info = 5;
1089                 return 0;
1090             }
1091 /* L50: */
1092         }
1093
1094 /*        Multiply by U and U' */
1095
1096         clarge_(n, &a[a_offset], lda, &iseed[1], &work[1], &iinfo);
1097         if (iinfo != 0) {
1098             *info = 4;
1099             return 0;
1100         }
1101     }
1102
1103 /*     5)      Reduce the bandwidth. */
1104
1105     if (*kl < *n - 1) {
1106
1107 /*        Reduce bandwidth -- kill column */
1108
1109         i__1 = *n - 1;
1110         for (jcr = *kl + 1; jcr <= i__1; ++jcr) {
1111             ic = jcr - *kl;
1112             irows = *n + 1 - jcr;
1113             icols = *n + *kl - jcr;
1114
1115             ccopy_(&irows, &a[jcr + ic * a_dim1], &c__1, &work[1], &c__1);
1116             xnorms.r = work[1].r, xnorms.i = work[1].i;
1117             clarfg_(&irows, &xnorms, &work[2], &c__1, &tau);
1118             r_cnjg(&q__1, &tau);
1119             tau.r = q__1.r, tau.i = q__1.i;
1120             work[1].r = 1.f, work[1].i = 0.f;
1121             //clarnd_(&q__1, &c__5, &iseed[1]);
1122             q__1=clarnd_(&c__5, &iseed[1]);
1123             alpha.r = q__1.r, alpha.i = q__1.i;
1124
1125             cgemv_("C", &irows, &icols, &c_b2, &a[jcr + (ic + 1) * a_dim1], 
1126                     lda, &work[1], &c__1, &c_b1, &work[irows + 1], &c__1);
1127             q__1.r = -tau.r, q__1.i = -tau.i;
1128             cgerc_(&irows, &icols, &q__1, &work[1], &c__1, &work[irows + 1], &
1129                     c__1, &a[jcr + (ic + 1) * a_dim1], lda);
1130
1131             cgemv_("N", n, &irows, &c_b2, &a[jcr * a_dim1 + 1], lda, &work[1],
1132                      &c__1, &c_b1, &work[irows + 1], &c__1);
1133             r_cnjg(&q__2, &tau);
1134             q__1.r = -q__2.r, q__1.i = -q__2.i;
1135             cgerc_(n, &irows, &q__1, &work[irows + 1], &c__1, &work[1], &c__1,
1136                      &a[jcr * a_dim1 + 1], lda);
1137
1138             i__2 = jcr + ic * a_dim1;
1139             a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
1140             i__2 = irows - 1;
1141             claset_("Full", &i__2, &c__1, &c_b1, &c_b1, &a[jcr + 1 + ic * 
1142                     a_dim1], lda);
1143
1144             i__2 = icols + 1;
1145             cscal_(&i__2, &alpha, &a[jcr + ic * a_dim1], lda);
1146             r_cnjg(&q__1, &alpha);
1147             cscal_(n, &q__1, &a[jcr * a_dim1 + 1], &c__1);
1148 /* L60: */
1149         }
1150     } else if (*ku < *n - 1) {
1151
1152 /*        Reduce upper bandwidth -- kill a row at a time. */
1153
1154         i__1 = *n - 1;
1155         for (jcr = *ku + 1; jcr <= i__1; ++jcr) {
1156             ir = jcr - *ku;
1157             irows = *n + *ku - jcr;
1158             icols = *n + 1 - jcr;
1159
1160             ccopy_(&icols, &a[ir + jcr * a_dim1], lda, &work[1], &c__1);
1161             xnorms.r = work[1].r, xnorms.i = work[1].i;
1162             clarfg_(&icols, &xnorms, &work[2], &c__1, &tau);
1163             r_cnjg(&q__1, &tau);
1164             tau.r = q__1.r, tau.i = q__1.i;
1165             work[1].r = 1.f, work[1].i = 0.f;
1166             i__2 = icols - 1;
1167             clacgv_(&i__2, &work[2], &c__1);
1168             //clarnd_(&q__1, &c__5, &iseed[1]);
1169             q__1=clarnd_(&c__5, &iseed[1]);
1170             alpha.r = q__1.r, alpha.i = q__1.i;
1171
1172             cgemv_("N", &irows, &icols, &c_b2, &a[ir + 1 + jcr * a_dim1], lda,
1173                      &work[1], &c__1, &c_b1, &work[icols + 1], &c__1);
1174             q__1.r = -tau.r, q__1.i = -tau.i;
1175             cgerc_(&irows, &icols, &q__1, &work[icols + 1], &c__1, &work[1], &
1176                     c__1, &a[ir + 1 + jcr * a_dim1], lda);
1177
1178             cgemv_("C", &icols, n, &c_b2, &a[jcr + a_dim1], lda, &work[1], &
1179                     c__1, &c_b1, &work[icols + 1], &c__1);
1180             r_cnjg(&q__2, &tau);
1181             q__1.r = -q__2.r, q__1.i = -q__2.i;
1182             cgerc_(&icols, n, &q__1, &work[1], &c__1, &work[icols + 1], &c__1,
1183                      &a[jcr + a_dim1], lda);
1184
1185             i__2 = ir + jcr * a_dim1;
1186             a[i__2].r = xnorms.r, a[i__2].i = xnorms.i;
1187             i__2 = icols - 1;
1188             claset_("Full", &c__1, &i__2, &c_b1, &c_b1, &a[ir + (jcr + 1) * 
1189                     a_dim1], lda);
1190
1191             i__2 = irows + 1;
1192             cscal_(&i__2, &alpha, &a[ir + jcr * a_dim1], &c__1);
1193             r_cnjg(&q__1, &alpha);
1194             cscal_(n, &q__1, &a[jcr + a_dim1], lda);
1195 /* L70: */
1196         }
1197     }
1198
1199 /*     Scale the matrix to have norm ANORM */
1200
1201     if (*anorm >= 0.f) {
1202         temp = clange_("M", n, n, &a[a_offset], lda, tempa);
1203         if (temp > 0.f) {
1204             ralpha = *anorm / temp;
1205             i__1 = *n;
1206             for (j = 1; j <= i__1; ++j) {
1207                 csscal_(n, &ralpha, &a[j * a_dim1 + 1], &c__1);
1208 /* L80: */
1209             }
1210         }
1211     }
1212
1213     return 0;
1214
1215 /*     End of CLATME */
1216
1217 } /* clatme_ */
1218