You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

slaror.c 17 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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. #if defined(_WIN64)
  13. typedef long long BLASLONG;
  14. typedef unsigned long long BLASULONG;
  15. #else
  16. typedef long BLASLONG;
  17. typedef unsigned long BLASULONG;
  18. #endif
  19. #ifdef LAPACK_ILP64
  20. typedef BLASLONG blasint;
  21. #if defined(_WIN64)
  22. #define blasabs(x) llabs(x)
  23. #else
  24. #define blasabs(x) labs(x)
  25. #endif
  26. #else
  27. typedef int blasint;
  28. #define blasabs(x) abs(x)
  29. #endif
  30. typedef blasint integer;
  31. typedef unsigned int uinteger;
  32. typedef char *address;
  33. typedef short int shortint;
  34. typedef float real;
  35. typedef double doublereal;
  36. typedef struct { real r, i; } complex;
  37. typedef struct { doublereal r, i; } doublecomplex;
  38. #ifdef _MSC_VER
  39. static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
  40. static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
  41. static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
  42. static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
  43. #else
  44. static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
  45. static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
  46. static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
  47. static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
  48. #endif
  49. #define pCf(z) (*_pCf(z))
  50. #define pCd(z) (*_pCd(z))
  51. typedef blasint logical;
  52. typedef char logical1;
  53. typedef char integer1;
  54. #define TRUE_ (1)
  55. #define FALSE_ (0)
  56. /* Extern is for use with -E */
  57. #ifndef Extern
  58. #define Extern extern
  59. #endif
  60. /* I/O stuff */
  61. typedef int flag;
  62. typedef int ftnlen;
  63. typedef int ftnint;
  64. /*external read, write*/
  65. typedef struct
  66. { flag cierr;
  67. ftnint ciunit;
  68. flag ciend;
  69. char *cifmt;
  70. ftnint cirec;
  71. } cilist;
  72. /*internal read, write*/
  73. typedef struct
  74. { flag icierr;
  75. char *iciunit;
  76. flag iciend;
  77. char *icifmt;
  78. ftnint icirlen;
  79. ftnint icirnum;
  80. } icilist;
  81. /*open*/
  82. typedef struct
  83. { flag oerr;
  84. ftnint ounit;
  85. char *ofnm;
  86. ftnlen ofnmlen;
  87. char *osta;
  88. char *oacc;
  89. char *ofm;
  90. ftnint orl;
  91. char *oblnk;
  92. } olist;
  93. /*close*/
  94. typedef struct
  95. { flag cerr;
  96. ftnint cunit;
  97. char *csta;
  98. } cllist;
  99. /*rewind, backspace, endfile*/
  100. typedef struct
  101. { flag aerr;
  102. ftnint aunit;
  103. } alist;
  104. /* inquire */
  105. typedef struct
  106. { flag inerr;
  107. ftnint inunit;
  108. char *infile;
  109. ftnlen infilen;
  110. ftnint *inex; /*parameters in standard's order*/
  111. ftnint *inopen;
  112. ftnint *innum;
  113. ftnint *innamed;
  114. char *inname;
  115. ftnlen innamlen;
  116. char *inacc;
  117. ftnlen inacclen;
  118. char *inseq;
  119. ftnlen inseqlen;
  120. char *indir;
  121. ftnlen indirlen;
  122. char *infmt;
  123. ftnlen infmtlen;
  124. char *inform;
  125. ftnint informlen;
  126. char *inunf;
  127. ftnlen inunflen;
  128. ftnint *inrecl;
  129. ftnint *innrec;
  130. char *inblank;
  131. ftnlen inblanklen;
  132. } inlist;
  133. #define VOID void
  134. union Multitype { /* for multiple entry points */
  135. integer1 g;
  136. shortint h;
  137. integer i;
  138. /* longint j; */
  139. real r;
  140. doublereal d;
  141. complex c;
  142. doublecomplex z;
  143. };
  144. typedef union Multitype Multitype;
  145. struct Vardesc { /* for Namelist */
  146. char *name;
  147. char *addr;
  148. ftnlen *dims;
  149. int type;
  150. };
  151. typedef struct Vardesc Vardesc;
  152. struct Namelist {
  153. char *name;
  154. Vardesc **vars;
  155. int nvars;
  156. };
  157. typedef struct Namelist Namelist;
  158. #define abs(x) ((x) >= 0 ? (x) : -(x))
  159. #define dabs(x) (fabs(x))
  160. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  161. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  162. #define dmin(a,b) (f2cmin(a,b))
  163. #define dmax(a,b) (f2cmax(a,b))
  164. #define bit_test(a,b) ((a) >> (b) & 1)
  165. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  166. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  167. #define abort_() { sig_die("Fortran abort routine called", 1); }
  168. #define c_abs(z) (cabsf(Cf(z)))
  169. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  170. #ifdef _MSC_VER
  171. #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]);}
  172. #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]);}
  173. #else
  174. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  175. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  176. #endif
  177. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  178. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  179. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  180. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  181. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  182. #define d_abs(x) (fabs(*(x)))
  183. #define d_acos(x) (acos(*(x)))
  184. #define d_asin(x) (asin(*(x)))
  185. #define d_atan(x) (atan(*(x)))
  186. #define d_atn2(x, y) (atan2(*(x),*(y)))
  187. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  188. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  189. #define d_cos(x) (cos(*(x)))
  190. #define d_cosh(x) (cosh(*(x)))
  191. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  192. #define d_exp(x) (exp(*(x)))
  193. #define d_imag(z) (cimag(Cd(z)))
  194. #define r_imag(z) (cimagf(Cf(z)))
  195. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  196. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  198. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define d_log(x) (log(*(x)))
  200. #define d_mod(x, y) (fmod(*(x), *(y)))
  201. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  202. #define d_nint(x) u_nint(*(x))
  203. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  204. #define d_sign(a,b) u_sign(*(a),*(b))
  205. #define r_sign(a,b) u_sign(*(a),*(b))
  206. #define d_sin(x) (sin(*(x)))
  207. #define d_sinh(x) (sinh(*(x)))
  208. #define d_sqrt(x) (sqrt(*(x)))
  209. #define d_tan(x) (tan(*(x)))
  210. #define d_tanh(x) (tanh(*(x)))
  211. #define i_abs(x) abs(*(x))
  212. #define i_dnnt(x) ((integer)u_nint(*(x)))
  213. #define i_len(s, n) (n)
  214. #define i_nint(x) ((integer)u_nint(*(x)))
  215. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  216. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  217. #define pow_si(B,E) spow_ui(*(B),*(E))
  218. #define pow_ri(B,E) spow_ui(*(B),*(E))
  219. #define pow_di(B,E) dpow_ui(*(B),*(E))
  220. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  221. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  222. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  223. #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++ = ' '; }
  224. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  225. #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]; }
  226. #define sig_die(s, kill) { exit(1); }
  227. #define s_stop(s, n) {exit(0);}
  228. #define z_abs(z) (cabs(Cd(z)))
  229. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  230. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  231. #define myexit_() break;
  232. #define mycycle() continue;
  233. #define myceiling(w) {ceil(w)}
  234. #define myhuge(w) {HUGE_VAL}
  235. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  236. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  237. /* procedure parameter types for -A and -C++ */
  238. /* Table of constant values */
  239. static real c_b9 = 0.f;
  240. static real c_b10 = 1.f;
  241. static integer c__3 = 3;
  242. static integer c__1 = 1;
  243. /* > \brief \b SLAROR */
  244. /* =========== DOCUMENTATION =========== */
  245. /* Online html documentation available at */
  246. /* http://www.netlib.org/lapack/explore-html/ */
  247. /* Definition: */
  248. /* =========== */
  249. /* SUBROUTINE SLAROR( SIDE, INIT, M, N, A, LDA, ISEED, X, INFO ) */
  250. /* CHARACTER INIT, SIDE */
  251. /* INTEGER INFO, LDA, M, N */
  252. /* INTEGER ISEED( 4 ) */
  253. /* REAL A( LDA, * ), X( * ) */
  254. /* > \par Purpose: */
  255. /* ============= */
  256. /* > */
  257. /* > \verbatim */
  258. /* > */
  259. /* > SLAROR pre- or post-multiplies an M by N matrix A by a random */
  260. /* > orthogonal matrix U, overwriting A. A may optionally be initialized */
  261. /* > to the identity matrix before multiplying by U. U is generated using */
  262. /* > the method of G.W. Stewart (SIAM J. Numer. Anal. 17, 1980, 403-409). */
  263. /* > \endverbatim */
  264. /* Arguments: */
  265. /* ========== */
  266. /* > \param[in] SIDE */
  267. /* > \verbatim */
  268. /* > SIDE is CHARACTER*1 */
  269. /* > Specifies whether A is multiplied on the left or right by U. */
  270. /* > = 'L': Multiply A on the left (premultiply) by U */
  271. /* > = 'R': Multiply A on the right (postmultiply) by U' */
  272. /* > = 'C' or 'T': Multiply A on the left by U and the right */
  273. /* > by U' (Here, U' means U-transpose.) */
  274. /* > \endverbatim */
  275. /* > */
  276. /* > \param[in] INIT */
  277. /* > \verbatim */
  278. /* > INIT is CHARACTER*1 */
  279. /* > Specifies whether or not A should be initialized to the */
  280. /* > identity matrix. */
  281. /* > = 'I': Initialize A to (a section of) the identity matrix */
  282. /* > before applying U. */
  283. /* > = 'N': No initialization. Apply U to the input matrix A. */
  284. /* > */
  285. /* > INIT = 'I' may be used to generate square or rectangular */
  286. /* > orthogonal matrices: */
  287. /* > */
  288. /* > For M = N and SIDE = 'L' or 'R', the rows will be orthogonal */
  289. /* > to each other, as will the columns. */
  290. /* > */
  291. /* > If M < N, SIDE = 'R' produces a dense matrix whose rows are */
  292. /* > orthogonal and whose columns are not, while SIDE = 'L' */
  293. /* > produces a matrix whose rows are orthogonal, and whose first */
  294. /* > M columns are orthogonal, and whose remaining columns are */
  295. /* > zero. */
  296. /* > */
  297. /* > If M > N, SIDE = 'L' produces a dense matrix whose columns */
  298. /* > are orthogonal and whose rows are not, while SIDE = 'R' */
  299. /* > produces a matrix whose columns are orthogonal, and whose */
  300. /* > first M rows are orthogonal, and whose remaining rows are */
  301. /* > zero. */
  302. /* > \endverbatim */
  303. /* > */
  304. /* > \param[in] M */
  305. /* > \verbatim */
  306. /* > M is INTEGER */
  307. /* > The number of rows of A. */
  308. /* > \endverbatim */
  309. /* > */
  310. /* > \param[in] N */
  311. /* > \verbatim */
  312. /* > N is INTEGER */
  313. /* > The number of columns of A. */
  314. /* > \endverbatim */
  315. /* > */
  316. /* > \param[in,out] A */
  317. /* > \verbatim */
  318. /* > A is REAL array, dimension (LDA, N) */
  319. /* > On entry, the array A. */
  320. /* > On exit, overwritten by U A ( if SIDE = 'L' ), */
  321. /* > or by A U ( if SIDE = 'R' ), */
  322. /* > or by U A U' ( if SIDE = 'C' or 'T'). */
  323. /* > \endverbatim */
  324. /* > */
  325. /* > \param[in] LDA */
  326. /* > \verbatim */
  327. /* > LDA is INTEGER */
  328. /* > The leading dimension of the array A. LDA >= f2cmax(1,M). */
  329. /* > \endverbatim */
  330. /* > */
  331. /* > \param[in,out] ISEED */
  332. /* > \verbatim */
  333. /* > ISEED is INTEGER array, dimension (4) */
  334. /* > On entry ISEED specifies the seed of the random number */
  335. /* > generator. The array elements should be between 0 and 4095; */
  336. /* > if not they will be reduced mod 4096. Also, ISEED(4) must */
  337. /* > be odd. The random number generator uses a linear */
  338. /* > congruential sequence limited to small integers, and so */
  339. /* > should produce machine independent random numbers. The */
  340. /* > values of ISEED are changed on exit, and can be used in the */
  341. /* > next call to SLAROR to continue the same random number */
  342. /* > sequence. */
  343. /* > \endverbatim */
  344. /* > */
  345. /* > \param[out] X */
  346. /* > \verbatim */
  347. /* > X is REAL array, dimension (3*MAX( M, N )) */
  348. /* > Workspace of length */
  349. /* > 2*M + N if SIDE = 'L', */
  350. /* > 2*N + M if SIDE = 'R', */
  351. /* > 3*N if SIDE = 'C' or 'T'. */
  352. /* > \endverbatim */
  353. /* > */
  354. /* > \param[out] INFO */
  355. /* > \verbatim */
  356. /* > INFO is INTEGER */
  357. /* > An error flag. It is set to: */
  358. /* > = 0: normal return */
  359. /* > < 0: if INFO = -k, the k-th argument had an illegal value */
  360. /* > = 1: if the random numbers generated by SLARND are bad. */
  361. /* > \endverbatim */
  362. /* Authors: */
  363. /* ======== */
  364. /* > \author Univ. of Tennessee */
  365. /* > \author Univ. of California Berkeley */
  366. /* > \author Univ. of Colorado Denver */
  367. /* > \author NAG Ltd. */
  368. /* > \date December 2016 */
  369. /* > \ingroup real_matgen */
  370. /* ===================================================================== */
  371. /* Subroutine */ void slaror_(char *side, char *init, integer *m, integer *n,
  372. real *a, integer *lda, integer *iseed, real *x, integer *info)
  373. {
  374. /* System generated locals */
  375. integer a_dim1, a_offset, i__1, i__2;
  376. real r__1;
  377. /* Local variables */
  378. integer kbeg, jcol;
  379. extern /* Subroutine */ void sger_(integer *, integer *, real *, real *,
  380. integer *, real *, integer *, real *, integer *);
  381. integer irow;
  382. extern real snrm2_(integer *, real *, integer *);
  383. integer j;
  384. extern logical lsame_(char *, char *);
  385. extern /* Subroutine */ void sscal_(integer *, real *, real *, integer *),
  386. sgemv_(char *, integer *, integer *, real *, real *, integer *,
  387. real *, integer *, real *, real *, integer *);
  388. integer ixfrm, itype, nxfrm;
  389. real xnorm;
  390. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  391. real factor;
  392. extern real slarnd_(integer *, integer *);
  393. extern /* Subroutine */ void slaset_(char *, integer *, integer *, real *,
  394. real *, real *, integer *);
  395. real xnorms;
  396. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  397. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  398. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  399. /* December 2016 */
  400. /* ===================================================================== */
  401. /* Parameter adjustments */
  402. a_dim1 = *lda;
  403. a_offset = 1 + a_dim1 * 1;
  404. a -= a_offset;
  405. --iseed;
  406. --x;
  407. /* Function Body */
  408. *info = 0;
  409. if (*n == 0 || *m == 0) {
  410. return;
  411. }
  412. itype = 0;
  413. if (lsame_(side, "L")) {
  414. itype = 1;
  415. } else if (lsame_(side, "R")) {
  416. itype = 2;
  417. } else if (lsame_(side, "C") || lsame_(side, "T")) {
  418. itype = 3;
  419. }
  420. /* Check for argument errors. */
  421. if (itype == 0) {
  422. *info = -1;
  423. } else if (*m < 0) {
  424. *info = -3;
  425. } else if (*n < 0 || itype == 3 && *n != *m) {
  426. *info = -4;
  427. } else if (*lda < *m) {
  428. *info = -6;
  429. }
  430. if (*info != 0) {
  431. i__1 = -(*info);
  432. xerbla_("SLAROR", &i__1, 6);
  433. return;
  434. }
  435. if (itype == 1) {
  436. nxfrm = *m;
  437. } else {
  438. nxfrm = *n;
  439. }
  440. /* Initialize A to the identity matrix if desired */
  441. if (lsame_(init, "I")) {
  442. slaset_("Full", m, n, &c_b9, &c_b10, &a[a_offset], lda);
  443. }
  444. /* If no rotation possible, multiply by random +/-1 */
  445. /* Compute rotation by computing Householder transformations */
  446. /* H(2), H(3), ..., H(nhouse) */
  447. i__1 = nxfrm;
  448. for (j = 1; j <= i__1; ++j) {
  449. x[j] = 0.f;
  450. /* L10: */
  451. }
  452. i__1 = nxfrm;
  453. for (ixfrm = 2; ixfrm <= i__1; ++ixfrm) {
  454. kbeg = nxfrm - ixfrm + 1;
  455. /* Generate independent normal( 0, 1 ) random numbers */
  456. i__2 = nxfrm;
  457. for (j = kbeg; j <= i__2; ++j) {
  458. x[j] = slarnd_(&c__3, &iseed[1]);
  459. /* L20: */
  460. }
  461. /* Generate a Householder transformation from the random vector X */
  462. xnorm = snrm2_(&ixfrm, &x[kbeg], &c__1);
  463. xnorms = r_sign(&xnorm, &x[kbeg]);
  464. r__1 = -x[kbeg];
  465. x[kbeg + nxfrm] = r_sign(&c_b10, &r__1);
  466. factor = xnorms * (xnorms + x[kbeg]);
  467. if (abs(factor) < 1e-20f) {
  468. *info = 1;
  469. xerbla_("SLAROR", info, 6);
  470. return;
  471. } else {
  472. factor = 1.f / factor;
  473. }
  474. x[kbeg] += xnorms;
  475. /* Apply Householder transformation to A */
  476. if (itype == 1 || itype == 3) {
  477. /* Apply H(k) from the left. */
  478. sgemv_("T", &ixfrm, n, &c_b10, &a[kbeg + a_dim1], lda, &x[kbeg], &
  479. c__1, &c_b9, &x[(nxfrm << 1) + 1], &c__1);
  480. r__1 = -factor;
  481. sger_(&ixfrm, n, &r__1, &x[kbeg], &c__1, &x[(nxfrm << 1) + 1], &
  482. c__1, &a[kbeg + a_dim1], lda);
  483. }
  484. if (itype == 2 || itype == 3) {
  485. /* Apply H(k) from the right. */
  486. sgemv_("N", m, &ixfrm, &c_b10, &a[kbeg * a_dim1 + 1], lda, &x[
  487. kbeg], &c__1, &c_b9, &x[(nxfrm << 1) + 1], &c__1);
  488. r__1 = -factor;
  489. sger_(m, &ixfrm, &r__1, &x[(nxfrm << 1) + 1], &c__1, &x[kbeg], &
  490. c__1, &a[kbeg * a_dim1 + 1], lda);
  491. }
  492. /* L30: */
  493. }
  494. r__1 = slarnd_(&c__3, &iseed[1]);
  495. x[nxfrm * 2] = r_sign(&c_b10, &r__1);
  496. /* Scale the matrix A by D. */
  497. if (itype == 1 || itype == 3) {
  498. i__1 = *m;
  499. for (irow = 1; irow <= i__1; ++irow) {
  500. sscal_(n, &x[nxfrm + irow], &a[irow + a_dim1], lda);
  501. /* L40: */
  502. }
  503. }
  504. if (itype == 2 || itype == 3) {
  505. i__1 = *n;
  506. for (jcol = 1; jcol <= i__1; ++jcol) {
  507. sscal_(m, &x[nxfrm + jcol], &a[jcol * a_dim1 + 1], &c__1);
  508. /* L50: */
  509. }
  510. }
  511. return;
  512. /* End of SLAROR */
  513. } /* slaror_ */