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.

slatmr.c 50 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644
  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 int logical;
  52. typedef short int shortlogical;
  53. typedef char logical1;
  54. typedef char integer1;
  55. #define TRUE_ (1)
  56. #define FALSE_ (0)
  57. /* Extern is for use with -E */
  58. #ifndef Extern
  59. #define Extern extern
  60. #endif
  61. /* I/O stuff */
  62. typedef int flag;
  63. typedef int ftnlen;
  64. typedef int ftnint;
  65. /*external read, write*/
  66. typedef struct
  67. { flag cierr;
  68. ftnint ciunit;
  69. flag ciend;
  70. char *cifmt;
  71. ftnint cirec;
  72. } cilist;
  73. /*internal read, write*/
  74. typedef struct
  75. { flag icierr;
  76. char *iciunit;
  77. flag iciend;
  78. char *icifmt;
  79. ftnint icirlen;
  80. ftnint icirnum;
  81. } icilist;
  82. /*open*/
  83. typedef struct
  84. { flag oerr;
  85. ftnint ounit;
  86. char *ofnm;
  87. ftnlen ofnmlen;
  88. char *osta;
  89. char *oacc;
  90. char *ofm;
  91. ftnint orl;
  92. char *oblnk;
  93. } olist;
  94. /*close*/
  95. typedef struct
  96. { flag cerr;
  97. ftnint cunit;
  98. char *csta;
  99. } cllist;
  100. /*rewind, backspace, endfile*/
  101. typedef struct
  102. { flag aerr;
  103. ftnint aunit;
  104. } alist;
  105. /* inquire */
  106. typedef struct
  107. { flag inerr;
  108. ftnint inunit;
  109. char *infile;
  110. ftnlen infilen;
  111. ftnint *inex; /*parameters in standard's order*/
  112. ftnint *inopen;
  113. ftnint *innum;
  114. ftnint *innamed;
  115. char *inname;
  116. ftnlen innamlen;
  117. char *inacc;
  118. ftnlen inacclen;
  119. char *inseq;
  120. ftnlen inseqlen;
  121. char *indir;
  122. ftnlen indirlen;
  123. char *infmt;
  124. ftnlen infmtlen;
  125. char *inform;
  126. ftnint informlen;
  127. char *inunf;
  128. ftnlen inunflen;
  129. ftnint *inrecl;
  130. ftnint *innrec;
  131. char *inblank;
  132. ftnlen inblanklen;
  133. } inlist;
  134. #define VOID void
  135. union Multitype { /* for multiple entry points */
  136. integer1 g;
  137. shortint h;
  138. integer i;
  139. /* longint j; */
  140. real r;
  141. doublereal d;
  142. complex c;
  143. doublecomplex z;
  144. };
  145. typedef union Multitype Multitype;
  146. struct Vardesc { /* for Namelist */
  147. char *name;
  148. char *addr;
  149. ftnlen *dims;
  150. int type;
  151. };
  152. typedef struct Vardesc Vardesc;
  153. struct Namelist {
  154. char *name;
  155. Vardesc **vars;
  156. int nvars;
  157. };
  158. typedef struct Namelist Namelist;
  159. #define abs(x) ((x) >= 0 ? (x) : -(x))
  160. #define dabs(x) (fabs(x))
  161. #define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
  162. #define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
  163. #define dmin(a,b) (f2cmin(a,b))
  164. #define dmax(a,b) (f2cmax(a,b))
  165. #define bit_test(a,b) ((a) >> (b) & 1)
  166. #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
  167. #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
  168. #define abort_() { sig_die("Fortran abort routine called", 1); }
  169. #define c_abs(z) (cabsf(Cf(z)))
  170. #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
  171. #ifdef _MSC_VER
  172. #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]);}
  173. #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]);}
  174. #else
  175. #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
  176. #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
  177. #endif
  178. #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
  179. #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
  180. #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
  181. //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
  182. #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
  183. #define d_abs(x) (fabs(*(x)))
  184. #define d_acos(x) (acos(*(x)))
  185. #define d_asin(x) (asin(*(x)))
  186. #define d_atan(x) (atan(*(x)))
  187. #define d_atn2(x, y) (atan2(*(x),*(y)))
  188. #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
  189. #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
  190. #define d_cos(x) (cos(*(x)))
  191. #define d_cosh(x) (cosh(*(x)))
  192. #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
  193. #define d_exp(x) (exp(*(x)))
  194. #define d_imag(z) (cimag(Cd(z)))
  195. #define r_imag(z) (cimagf(Cf(z)))
  196. #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  197. #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
  198. #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  199. #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
  200. #define d_log(x) (log(*(x)))
  201. #define d_mod(x, y) (fmod(*(x), *(y)))
  202. #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
  203. #define d_nint(x) u_nint(*(x))
  204. #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
  205. #define d_sign(a,b) u_sign(*(a),*(b))
  206. #define r_sign(a,b) u_sign(*(a),*(b))
  207. #define d_sin(x) (sin(*(x)))
  208. #define d_sinh(x) (sinh(*(x)))
  209. #define d_sqrt(x) (sqrt(*(x)))
  210. #define d_tan(x) (tan(*(x)))
  211. #define d_tanh(x) (tanh(*(x)))
  212. #define i_abs(x) abs(*(x))
  213. #define i_dnnt(x) ((integer)u_nint(*(x)))
  214. #define i_len(s, n) (n)
  215. #define i_nint(x) ((integer)u_nint(*(x)))
  216. #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
  217. #define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
  218. #define pow_si(B,E) spow_ui(*(B),*(E))
  219. #define pow_ri(B,E) spow_ui(*(B),*(E))
  220. #define pow_di(B,E) dpow_ui(*(B),*(E))
  221. #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
  222. #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
  223. #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
  224. #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++ = ' '; }
  225. #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
  226. #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]; }
  227. #define sig_die(s, kill) { exit(1); }
  228. #define s_stop(s, n) {exit(0);}
  229. #define z_abs(z) (cabs(Cd(z)))
  230. #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
  231. #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
  232. #define myexit_() break;
  233. #define mycycle() continue;
  234. #define myceiling(w) {ceil(w)}
  235. #define myhuge(w) {HUGE_VAL}
  236. //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
  237. #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
  238. /* procedure parameter types for -A and -C++ */
  239. #define F2C_proc_par_types 1
  240. /* Table of constant values */
  241. static integer c__0 = 0;
  242. static integer c__1 = 1;
  243. /* > \brief \b SLATMR */
  244. /* =========== DOCUMENTATION =========== */
  245. /* Online html documentation available at */
  246. /* http://www.netlib.org/lapack/explore-html/ */
  247. /* Definition: */
  248. /* =========== */
  249. /* SUBROUTINE SLATMR( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
  250. /* RSIGN, GRADE, DL, MODEL, CONDL, DR, MODER, */
  251. /* CONDR, PIVTNG, IPIVOT, KL, KU, SPARSE, ANORM, */
  252. /* PACK, A, LDA, IWORK, INFO ) */
  253. /* CHARACTER DIST, GRADE, PACK, PIVTNG, RSIGN, SYM */
  254. /* INTEGER INFO, KL, KU, LDA, M, MODE, MODEL, MODER, N */
  255. /* REAL ANORM, COND, CONDL, CONDR, DMAX, SPARSE */
  256. /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
  257. /* REAL A( LDA, * ), D( * ), DL( * ), DR( * ) */
  258. /* > \par Purpose: */
  259. /* ============= */
  260. /* > */
  261. /* > \verbatim */
  262. /* > */
  263. /* > SLATMR generates random matrices of various types for testing */
  264. /* > LAPACK programs. */
  265. /* > */
  266. /* > SLATMR operates by applying the following sequence of */
  267. /* > operations: */
  268. /* > */
  269. /* > Generate a matrix A with random entries of distribution DIST */
  270. /* > which is symmetric if SYM='S', and nonsymmetric */
  271. /* > if SYM='N'. */
  272. /* > */
  273. /* > Set the diagonal to D, where D may be input or */
  274. /* > computed according to MODE, COND, DMAX and RSIGN */
  275. /* > as described below. */
  276. /* > */
  277. /* > Grade the matrix, if desired, from the left and/or right */
  278. /* > as specified by GRADE. The inputs DL, MODEL, CONDL, DR, */
  279. /* > MODER and CONDR also determine the grading as described */
  280. /* > below. */
  281. /* > */
  282. /* > Permute, if desired, the rows and/or columns as specified by */
  283. /* > PIVTNG and IPIVOT. */
  284. /* > */
  285. /* > Set random entries to zero, if desired, to get a random sparse */
  286. /* > matrix as specified by SPARSE. */
  287. /* > */
  288. /* > Make A a band matrix, if desired, by zeroing out the matrix */
  289. /* > outside a band of lower bandwidth KL and upper bandwidth KU. */
  290. /* > */
  291. /* > Scale A, if desired, to have maximum entry ANORM. */
  292. /* > */
  293. /* > Pack the matrix if desired. Options specified by PACK are: */
  294. /* > no packing */
  295. /* > zero out upper half (if symmetric) */
  296. /* > zero out lower half (if symmetric) */
  297. /* > store the upper half columnwise (if symmetric or */
  298. /* > square upper triangular) */
  299. /* > store the lower half columnwise (if symmetric or */
  300. /* > square lower triangular) */
  301. /* > same as upper half rowwise if symmetric */
  302. /* > store the lower triangle in banded format (if symmetric) */
  303. /* > store the upper triangle in banded format (if symmetric) */
  304. /* > store the entire matrix in banded format */
  305. /* > */
  306. /* > Note: If two calls to SLATMR differ only in the PACK parameter, */
  307. /* > they will generate mathematically equivalent matrices. */
  308. /* > */
  309. /* > If two calls to SLATMR both have full bandwidth (KL = M-1 */
  310. /* > and KU = N-1), and differ only in the PIVTNG and PACK */
  311. /* > parameters, then the matrices generated will differ only */
  312. /* > in the order of the rows and/or columns, and otherwise */
  313. /* > contain the same data. This consistency cannot be and */
  314. /* > is not maintained with less than full bandwidth. */
  315. /* > \endverbatim */
  316. /* Arguments: */
  317. /* ========== */
  318. /* > \param[in] M */
  319. /* > \verbatim */
  320. /* > M is INTEGER */
  321. /* > Number of rows of A. Not modified. */
  322. /* > \endverbatim */
  323. /* > */
  324. /* > \param[in] N */
  325. /* > \verbatim */
  326. /* > N is INTEGER */
  327. /* > Number of columns of A. Not modified. */
  328. /* > \endverbatim */
  329. /* > */
  330. /* > \param[in] DIST */
  331. /* > \verbatim */
  332. /* > DIST is CHARACTER*1 */
  333. /* > On entry, DIST specifies the type of distribution to be used */
  334. /* > to generate a random matrix . */
  335. /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
  336. /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
  337. /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
  338. /* > Not modified. */
  339. /* > \endverbatim */
  340. /* > */
  341. /* > \param[in,out] ISEED */
  342. /* > \verbatim */
  343. /* > ISEED is INTEGER array, dimension (4) */
  344. /* > On entry ISEED specifies the seed of the random number */
  345. /* > generator. They should lie between 0 and 4095 inclusive, */
  346. /* > and ISEED(4) should be odd. The random number generator */
  347. /* > uses a linear congruential sequence limited to small */
  348. /* > integers, and so should produce machine independent */
  349. /* > random numbers. The values of ISEED are changed on */
  350. /* > exit, and can be used in the next call to SLATMR */
  351. /* > to continue the same random number sequence. */
  352. /* > Changed on exit. */
  353. /* > \endverbatim */
  354. /* > */
  355. /* > \param[in] SYM */
  356. /* > \verbatim */
  357. /* > SYM is CHARACTER*1 */
  358. /* > If SYM='S' or 'H', generated matrix is symmetric. */
  359. /* > If SYM='N', generated matrix is nonsymmetric. */
  360. /* > Not modified. */
  361. /* > \endverbatim */
  362. /* > */
  363. /* > \param[in] D */
  364. /* > \verbatim */
  365. /* > D is REAL array, dimension (f2cmin(M,N)) */
  366. /* > On entry this array specifies the diagonal entries */
  367. /* > of the diagonal of A. D may either be specified */
  368. /* > on entry, or set according to MODE and COND as described */
  369. /* > below. May be changed on exit if MODE is nonzero. */
  370. /* > \endverbatim */
  371. /* > */
  372. /* > \param[in] MODE */
  373. /* > \verbatim */
  374. /* > MODE is INTEGER */
  375. /* > On entry describes how D is to be used: */
  376. /* > MODE = 0 means use D as input */
  377. /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
  378. /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
  379. /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
  380. /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
  381. /* > MODE = 5 sets D to random numbers in the range */
  382. /* > ( 1/COND , 1 ) such that their logarithms */
  383. /* > are uniformly distributed. */
  384. /* > MODE = 6 set D to random numbers from same distribution */
  385. /* > as the rest of the matrix. */
  386. /* > MODE < 0 has the same meaning as ABS(MODE), except that */
  387. /* > the order of the elements of D is reversed. */
  388. /* > Thus if MODE is positive, D has entries ranging from */
  389. /* > 1 to 1/COND, if negative, from 1/COND to 1, */
  390. /* > Not modified. */
  391. /* > \endverbatim */
  392. /* > */
  393. /* > \param[in] COND */
  394. /* > \verbatim */
  395. /* > COND is REAL */
  396. /* > On entry, used as described under MODE above. */
  397. /* > If used, it must be >= 1. Not modified. */
  398. /* > \endverbatim */
  399. /* > */
  400. /* > \param[in] DMAX */
  401. /* > \verbatim */
  402. /* > DMAX is REAL */
  403. /* > If MODE neither -6, 0 nor 6, the diagonal is scaled by */
  404. /* > DMAX / f2cmax(abs(D(i))), so that maximum absolute entry */
  405. /* > of diagonal is abs(DMAX). If DMAX is negative (or zero), */
  406. /* > diagonal will be scaled by a negative number (or zero). */
  407. /* > \endverbatim */
  408. /* > */
  409. /* > \param[in] RSIGN */
  410. /* > \verbatim */
  411. /* > RSIGN is CHARACTER*1 */
  412. /* > If MODE neither -6, 0 nor 6, specifies sign of diagonal */
  413. /* > as follows: */
  414. /* > 'T' => diagonal entries are multiplied by 1 or -1 */
  415. /* > with probability .5 */
  416. /* > 'F' => diagonal unchanged */
  417. /* > Not modified. */
  418. /* > \endverbatim */
  419. /* > */
  420. /* > \param[in] GRADE */
  421. /* > \verbatim */
  422. /* > GRADE is CHARACTER*1 */
  423. /* > Specifies grading of matrix as follows: */
  424. /* > 'N' => no grading */
  425. /* > 'L' => matrix premultiplied by diag( DL ) */
  426. /* > (only if matrix nonsymmetric) */
  427. /* > 'R' => matrix postmultiplied by diag( DR ) */
  428. /* > (only if matrix nonsymmetric) */
  429. /* > 'B' => matrix premultiplied by diag( DL ) and */
  430. /* > postmultiplied by diag( DR ) */
  431. /* > (only if matrix nonsymmetric) */
  432. /* > 'S' or 'H' => matrix premultiplied by diag( DL ) and */
  433. /* > postmultiplied by diag( DL ) */
  434. /* > ('S' for symmetric, or 'H' for Hermitian) */
  435. /* > 'E' => matrix premultiplied by diag( DL ) and */
  436. /* > postmultiplied by inv( diag( DL ) ) */
  437. /* > ( 'E' for eigenvalue invariance) */
  438. /* > (only if matrix nonsymmetric) */
  439. /* > Note: if GRADE='E', then M must equal N. */
  440. /* > Not modified. */
  441. /* > \endverbatim */
  442. /* > */
  443. /* > \param[in,out] DL */
  444. /* > \verbatim */
  445. /* > DL is REAL array, dimension (M) */
  446. /* > If MODEL=0, then on entry this array specifies the diagonal */
  447. /* > entries of a diagonal matrix used as described under GRADE */
  448. /* > above. If MODEL is not zero, then DL will be set according */
  449. /* > to MODEL and CONDL, analogous to the way D is set according */
  450. /* > to MODE and COND (except there is no DMAX parameter for DL). */
  451. /* > If GRADE='E', then DL cannot have zero entries. */
  452. /* > Not referenced if GRADE = 'N' or 'R'. Changed on exit. */
  453. /* > \endverbatim */
  454. /* > */
  455. /* > \param[in] MODEL */
  456. /* > \verbatim */
  457. /* > MODEL is INTEGER */
  458. /* > This specifies how the diagonal array DL is to be computed, */
  459. /* > just as MODE specifies how D is to be computed. */
  460. /* > Not modified. */
  461. /* > \endverbatim */
  462. /* > */
  463. /* > \param[in] CONDL */
  464. /* > \verbatim */
  465. /* > CONDL is REAL */
  466. /* > When MODEL is not zero, this specifies the condition number */
  467. /* > of the computed DL. Not modified. */
  468. /* > \endverbatim */
  469. /* > */
  470. /* > \param[in,out] DR */
  471. /* > \verbatim */
  472. /* > DR is REAL array, dimension (N) */
  473. /* > If MODER=0, then on entry this array specifies the diagonal */
  474. /* > entries of a diagonal matrix used as described under GRADE */
  475. /* > above. If MODER is not zero, then DR will be set according */
  476. /* > to MODER and CONDR, analogous to the way D is set according */
  477. /* > to MODE and COND (except there is no DMAX parameter for DR). */
  478. /* > Not referenced if GRADE = 'N', 'L', 'H', 'S' or 'E'. */
  479. /* > Changed on exit. */
  480. /* > \endverbatim */
  481. /* > */
  482. /* > \param[in] MODER */
  483. /* > \verbatim */
  484. /* > MODER is INTEGER */
  485. /* > This specifies how the diagonal array DR is to be computed, */
  486. /* > just as MODE specifies how D is to be computed. */
  487. /* > Not modified. */
  488. /* > \endverbatim */
  489. /* > */
  490. /* > \param[in] CONDR */
  491. /* > \verbatim */
  492. /* > CONDR is REAL */
  493. /* > When MODER is not zero, this specifies the condition number */
  494. /* > of the computed DR. Not modified. */
  495. /* > \endverbatim */
  496. /* > */
  497. /* > \param[in] PIVTNG */
  498. /* > \verbatim */
  499. /* > PIVTNG is CHARACTER*1 */
  500. /* > On entry specifies pivoting permutations as follows: */
  501. /* > 'N' or ' ' => none. */
  502. /* > 'L' => left or row pivoting (matrix must be nonsymmetric). */
  503. /* > 'R' => right or column pivoting (matrix must be */
  504. /* > nonsymmetric). */
  505. /* > 'B' or 'F' => both or full pivoting, i.e., on both sides. */
  506. /* > In this case, M must equal N */
  507. /* > */
  508. /* > If two calls to SLATMR both have full bandwidth (KL = M-1 */
  509. /* > and KU = N-1), and differ only in the PIVTNG and PACK */
  510. /* > parameters, then the matrices generated will differ only */
  511. /* > in the order of the rows and/or columns, and otherwise */
  512. /* > contain the same data. This consistency cannot be */
  513. /* > maintained with less than full bandwidth. */
  514. /* > \endverbatim */
  515. /* > */
  516. /* > \param[in] IPIVOT */
  517. /* > \verbatim */
  518. /* > IPIVOT is INTEGER array, dimension (N or M) */
  519. /* > This array specifies the permutation used. After the */
  520. /* > basic matrix is generated, the rows, columns, or both */
  521. /* > are permuted. If, say, row pivoting is selected, SLATMR */
  522. /* > starts with the *last* row and interchanges the M-th and */
  523. /* > IPIVOT(M)-th rows, then moves to the next-to-last row, */
  524. /* > interchanging the (M-1)-th and the IPIVOT(M-1)-th rows, */
  525. /* > and so on. In terms of "2-cycles", the permutation is */
  526. /* > (1 IPIVOT(1)) (2 IPIVOT(2)) ... (M IPIVOT(M)) */
  527. /* > where the rightmost cycle is applied first. This is the */
  528. /* > *inverse* of the effect of pivoting in LINPACK. The idea */
  529. /* > is that factoring (with pivoting) an identity matrix */
  530. /* > which has been inverse-pivoted in this way should */
  531. /* > result in a pivot vector identical to IPIVOT. */
  532. /* > Not referenced if PIVTNG = 'N'. Not modified. */
  533. /* > \endverbatim */
  534. /* > */
  535. /* > \param[in] KL */
  536. /* > \verbatim */
  537. /* > KL is INTEGER */
  538. /* > On entry specifies the lower bandwidth of the matrix. For */
  539. /* > example, KL=0 implies upper triangular, KL=1 implies upper */
  540. /* > Hessenberg, and KL at least M-1 implies the matrix is not */
  541. /* > banded. Must equal KU if matrix is symmetric. */
  542. /* > Not modified. */
  543. /* > \endverbatim */
  544. /* > */
  545. /* > \param[in] KU */
  546. /* > \verbatim */
  547. /* > KU is INTEGER */
  548. /* > On entry specifies the upper bandwidth of the matrix. For */
  549. /* > example, KU=0 implies lower triangular, KU=1 implies lower */
  550. /* > Hessenberg, and KU at least N-1 implies the matrix is not */
  551. /* > banded. Must equal KL if matrix is symmetric. */
  552. /* > Not modified. */
  553. /* > \endverbatim */
  554. /* > */
  555. /* > \param[in] SPARSE */
  556. /* > \verbatim */
  557. /* > SPARSE is REAL */
  558. /* > On entry specifies the sparsity of the matrix if a sparse */
  559. /* > matrix is to be generated. SPARSE should lie between */
  560. /* > 0 and 1. To generate a sparse matrix, for each matrix entry */
  561. /* > a uniform ( 0, 1 ) random number x is generated and */
  562. /* > compared to SPARSE; if x is larger the matrix entry */
  563. /* > is unchanged and if x is smaller the entry is set */
  564. /* > to zero. Thus on the average a fraction SPARSE of the */
  565. /* > entries will be set to zero. */
  566. /* > Not modified. */
  567. /* > \endverbatim */
  568. /* > */
  569. /* > \param[in] ANORM */
  570. /* > \verbatim */
  571. /* > ANORM is REAL */
  572. /* > On entry specifies maximum entry of output matrix */
  573. /* > (output matrix will by multiplied by a constant so that */
  574. /* > its largest absolute entry equal ANORM) */
  575. /* > if ANORM is nonnegative. If ANORM is negative no scaling */
  576. /* > is done. Not modified. */
  577. /* > \endverbatim */
  578. /* > */
  579. /* > \param[in] PACK */
  580. /* > \verbatim */
  581. /* > PACK is CHARACTER*1 */
  582. /* > On entry specifies packing of matrix as follows: */
  583. /* > 'N' => no packing */
  584. /* > 'U' => zero out all subdiagonal entries (if symmetric) */
  585. /* > 'L' => zero out all superdiagonal entries (if symmetric) */
  586. /* > 'C' => store the upper triangle columnwise */
  587. /* > (only if matrix symmetric or square upper triangular) */
  588. /* > 'R' => store the lower triangle columnwise */
  589. /* > (only if matrix symmetric or square lower triangular) */
  590. /* > (same as upper half rowwise if symmetric) */
  591. /* > 'B' => store the lower triangle in band storage scheme */
  592. /* > (only if matrix symmetric) */
  593. /* > 'Q' => store the upper triangle in band storage scheme */
  594. /* > (only if matrix symmetric) */
  595. /* > 'Z' => store the entire matrix in band storage scheme */
  596. /* > (pivoting can be provided for by using this */
  597. /* > option to store A in the trailing rows of */
  598. /* > the allocated storage) */
  599. /* > */
  600. /* > Using these options, the various LAPACK packed and banded */
  601. /* > storage schemes can be obtained: */
  602. /* > GB - use 'Z' */
  603. /* > PB, SB or TB - use 'B' or 'Q' */
  604. /* > PP, SP or TP - use 'C' or 'R' */
  605. /* > */
  606. /* > If two calls to SLATMR differ only in the PACK parameter, */
  607. /* > they will generate mathematically equivalent matrices. */
  608. /* > Not modified. */
  609. /* > \endverbatim */
  610. /* > */
  611. /* > \param[in,out] A */
  612. /* > \verbatim */
  613. /* > A is REAL array, dimension (LDA,N) */
  614. /* > On exit A is the desired test matrix. Only those */
  615. /* > entries of A which are significant on output */
  616. /* > will be referenced (even if A is in packed or band */
  617. /* > storage format). The 'unoccupied corners' of A in */
  618. /* > band format will be zeroed out. */
  619. /* > \endverbatim */
  620. /* > */
  621. /* > \param[in] LDA */
  622. /* > \verbatim */
  623. /* > LDA is INTEGER */
  624. /* > on entry LDA specifies the first dimension of A as */
  625. /* > declared in the calling program. */
  626. /* > If PACK='N', 'U' or 'L', LDA must be at least f2cmax ( 1, M ). */
  627. /* > If PACK='C' or 'R', LDA must be at least 1. */
  628. /* > If PACK='B', or 'Q', LDA must be MIN ( KU+1, N ) */
  629. /* > If PACK='Z', LDA must be at least KUU+KLL+1, where */
  630. /* > KUU = MIN ( KU, N-1 ) and KLL = MIN ( KL, M-1 ) */
  631. /* > Not modified. */
  632. /* > \endverbatim */
  633. /* > */
  634. /* > \param[out] IWORK */
  635. /* > \verbatim */
  636. /* > IWORK is INTEGER array, dimension ( N or M) */
  637. /* > Workspace. Not referenced if PIVTNG = 'N'. Changed on exit. */
  638. /* > \endverbatim */
  639. /* > */
  640. /* > \param[out] INFO */
  641. /* > \verbatim */
  642. /* > INFO is INTEGER */
  643. /* > Error parameter on exit: */
  644. /* > 0 => normal return */
  645. /* > -1 => M negative or unequal to N and SYM='S' or 'H' */
  646. /* > -2 => N negative */
  647. /* > -3 => DIST illegal string */
  648. /* > -5 => SYM illegal string */
  649. /* > -7 => MODE not in range -6 to 6 */
  650. /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
  651. /* > -10 => MODE neither -6, 0 nor 6 and RSIGN illegal string */
  652. /* > -11 => GRADE illegal string, or GRADE='E' and */
  653. /* > M not equal to N, or GRADE='L', 'R', 'B' or 'E' and */
  654. /* > SYM = 'S' or 'H' */
  655. /* > -12 => GRADE = 'E' and DL contains zero */
  656. /* > -13 => MODEL not in range -6 to 6 and GRADE= 'L', 'B', 'H', */
  657. /* > 'S' or 'E' */
  658. /* > -14 => CONDL less than 1.0, GRADE='L', 'B', 'H', 'S' or 'E', */
  659. /* > and MODEL neither -6, 0 nor 6 */
  660. /* > -16 => MODER not in range -6 to 6 and GRADE= 'R' or 'B' */
  661. /* > -17 => CONDR less than 1.0, GRADE='R' or 'B', and */
  662. /* > MODER neither -6, 0 nor 6 */
  663. /* > -18 => PIVTNG illegal string, or PIVTNG='B' or 'F' and */
  664. /* > M not equal to N, or PIVTNG='L' or 'R' and SYM='S' */
  665. /* > or 'H' */
  666. /* > -19 => IPIVOT contains out of range number and */
  667. /* > PIVTNG not equal to 'N' */
  668. /* > -20 => KL negative */
  669. /* > -21 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
  670. /* > -22 => SPARSE not in range 0. to 1. */
  671. /* > -24 => PACK illegal string, or PACK='U', 'L', 'B' or 'Q' */
  672. /* > and SYM='N', or PACK='C' and SYM='N' and either KL */
  673. /* > not equal to 0 or N not equal to M, or PACK='R' and */
  674. /* > SYM='N', and either KU not equal to 0 or N not equal */
  675. /* > to M */
  676. /* > -26 => LDA too small */
  677. /* > 1 => Error return from SLATM1 (computing D) */
  678. /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
  679. /* > 3 => Error return from SLATM1 (computing DL) */
  680. /* > 4 => Error return from SLATM1 (computing DR) */
  681. /* > 5 => ANORM is positive, but matrix constructed prior to */
  682. /* > attempting to scale it to have norm ANORM, is zero */
  683. /* > \endverbatim */
  684. /* Authors: */
  685. /* ======== */
  686. /* > \author Univ. of Tennessee */
  687. /* > \author Univ. of California Berkeley */
  688. /* > \author Univ. of Colorado Denver */
  689. /* > \author NAG Ltd. */
  690. /* > \date December 2016 */
  691. /* > \ingroup real_matgen */
  692. /* ===================================================================== */
  693. /* Subroutine */ void slatmr_(integer *m, integer *n, char *dist, integer *
  694. iseed, char *sym, real *d__, integer *mode, real *cond, real *dmax__,
  695. char *rsign, char *grade, real *dl, integer *model, real *condl, real
  696. *dr, integer *moder, real *condr, char *pivtng, integer *ipivot,
  697. integer *kl, integer *ku, real *sparse, real *anorm, char *pack, real
  698. *a, integer *lda, integer *iwork, integer *info)
  699. {
  700. /* System generated locals */
  701. integer a_dim1, a_offset, i__1, i__2;
  702. real r__1, r__2, r__3;
  703. /* Local variables */
  704. integer isub, jsub;
  705. real temp;
  706. integer isym, i__, j, k;
  707. real alpha;
  708. integer ipack;
  709. extern logical lsame_(char *, char *);
  710. real tempa[1];
  711. extern /* Subroutine */ void sscal_(integer *, real *, real *, integer *);
  712. integer iisub, idist, jjsub, mnmin;
  713. logical dzero;
  714. integer mnsub;
  715. real onorm;
  716. integer mxsub, npvts;
  717. extern /* Subroutine */ void slatm1_(integer *, real *, integer *, integer
  718. *, integer *, real *, integer *, integer *);
  719. extern real slatm2_(integer *, integer *, integer *, integer *, integer *,
  720. integer *, integer *, integer *, real *, integer *, real *, real
  721. *, integer *, integer *, real *), slatm3_(integer *, integer *,
  722. integer *, integer *, integer *, integer *, integer *, integer *,
  723. integer *, integer *, real *, integer *, real *, real *, integer *
  724. , integer *, real *);
  725. integer igrade;
  726. extern real slangb_(char *, integer *, integer *, integer *, real *,
  727. integer *, real *), slange_(char *, integer *, integer *,
  728. real *, integer *, real *);
  729. logical fulbnd;
  730. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  731. logical badpvt;
  732. extern real slansb_(char *, char *, integer *, integer *, real *, integer
  733. *, real *);
  734. integer irsign;
  735. extern real slansp_(char *, char *, integer *, real *, real *);
  736. integer ipvtng;
  737. extern real slansy_(char *, char *, integer *, real *, integer *, real *);
  738. integer kll, kuu;
  739. /* -- LAPACK computational routine (version 3.7.0) -- */
  740. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  741. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  742. /* December 2016 */
  743. /* ===================================================================== */
  744. /* 1) Decode and Test the input parameters. */
  745. /* Initialize flags & seed. */
  746. /* Parameter adjustments */
  747. --iseed;
  748. --d__;
  749. --dl;
  750. --dr;
  751. --ipivot;
  752. a_dim1 = *lda;
  753. a_offset = 1 + a_dim1 * 1;
  754. a -= a_offset;
  755. --iwork;
  756. /* Function Body */
  757. *info = 0;
  758. /* Quick return if possible */
  759. if (*m == 0 || *n == 0) {
  760. return;
  761. }
  762. /* Decode DIST */
  763. if (lsame_(dist, "U")) {
  764. idist = 1;
  765. } else if (lsame_(dist, "S")) {
  766. idist = 2;
  767. } else if (lsame_(dist, "N")) {
  768. idist = 3;
  769. } else {
  770. idist = -1;
  771. }
  772. /* Decode SYM */
  773. if (lsame_(sym, "S")) {
  774. isym = 0;
  775. } else if (lsame_(sym, "N")) {
  776. isym = 1;
  777. } else if (lsame_(sym, "H")) {
  778. isym = 0;
  779. } else {
  780. isym = -1;
  781. }
  782. /* Decode RSIGN */
  783. if (lsame_(rsign, "F")) {
  784. irsign = 0;
  785. } else if (lsame_(rsign, "T")) {
  786. irsign = 1;
  787. } else {
  788. irsign = -1;
  789. }
  790. /* Decode PIVTNG */
  791. if (lsame_(pivtng, "N")) {
  792. ipvtng = 0;
  793. } else if (lsame_(pivtng, " ")) {
  794. ipvtng = 0;
  795. } else if (lsame_(pivtng, "L")) {
  796. ipvtng = 1;
  797. npvts = *m;
  798. } else if (lsame_(pivtng, "R")) {
  799. ipvtng = 2;
  800. npvts = *n;
  801. } else if (lsame_(pivtng, "B")) {
  802. ipvtng = 3;
  803. npvts = f2cmin(*n,*m);
  804. } else if (lsame_(pivtng, "F")) {
  805. ipvtng = 3;
  806. npvts = f2cmin(*n,*m);
  807. } else {
  808. ipvtng = -1;
  809. }
  810. /* Decode GRADE */
  811. if (lsame_(grade, "N")) {
  812. igrade = 0;
  813. } else if (lsame_(grade, "L")) {
  814. igrade = 1;
  815. } else if (lsame_(grade, "R")) {
  816. igrade = 2;
  817. } else if (lsame_(grade, "B")) {
  818. igrade = 3;
  819. } else if (lsame_(grade, "E")) {
  820. igrade = 4;
  821. } else if (lsame_(grade, "H") || lsame_(grade,
  822. "S")) {
  823. igrade = 5;
  824. } else {
  825. igrade = -1;
  826. }
  827. /* Decode PACK */
  828. if (lsame_(pack, "N")) {
  829. ipack = 0;
  830. } else if (lsame_(pack, "U")) {
  831. ipack = 1;
  832. } else if (lsame_(pack, "L")) {
  833. ipack = 2;
  834. } else if (lsame_(pack, "C")) {
  835. ipack = 3;
  836. } else if (lsame_(pack, "R")) {
  837. ipack = 4;
  838. } else if (lsame_(pack, "B")) {
  839. ipack = 5;
  840. } else if (lsame_(pack, "Q")) {
  841. ipack = 6;
  842. } else if (lsame_(pack, "Z")) {
  843. ipack = 7;
  844. } else {
  845. ipack = -1;
  846. }
  847. /* Set certain internal parameters */
  848. mnmin = f2cmin(*m,*n);
  849. /* Computing MIN */
  850. i__1 = *kl, i__2 = *m - 1;
  851. kll = f2cmin(i__1,i__2);
  852. /* Computing MIN */
  853. i__1 = *ku, i__2 = *n - 1;
  854. kuu = f2cmin(i__1,i__2);
  855. /* If inv(DL) is used, check to see if DL has a zero entry. */
  856. dzero = FALSE_;
  857. if (igrade == 4 && *model == 0) {
  858. i__1 = *m;
  859. for (i__ = 1; i__ <= i__1; ++i__) {
  860. if (dl[i__] == 0.f) {
  861. dzero = TRUE_;
  862. }
  863. /* L10: */
  864. }
  865. }
  866. /* Check values in IPIVOT */
  867. badpvt = FALSE_;
  868. if (ipvtng > 0) {
  869. i__1 = npvts;
  870. for (j = 1; j <= i__1; ++j) {
  871. if (ipivot[j] <= 0 || ipivot[j] > npvts) {
  872. badpvt = TRUE_;
  873. }
  874. /* L20: */
  875. }
  876. }
  877. /* Set INFO if an error */
  878. if (*m < 0) {
  879. *info = -1;
  880. } else if (*m != *n && isym == 0) {
  881. *info = -1;
  882. } else if (*n < 0) {
  883. *info = -2;
  884. } else if (idist == -1) {
  885. *info = -3;
  886. } else if (isym == -1) {
  887. *info = -5;
  888. } else if (*mode < -6 || *mode > 6) {
  889. *info = -7;
  890. } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.f) {
  891. *info = -8;
  892. } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
  893. *info = -10;
  894. } else if (igrade == -1 || igrade == 4 && *m != *n || igrade >= 1 &&
  895. igrade <= 4 && isym == 0) {
  896. *info = -11;
  897. } else if (igrade == 4 && dzero) {
  898. *info = -12;
  899. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  900. *model < -6 || *model > 6)) {
  901. *info = -13;
  902. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  903. *model != -6 && *model != 0 && *model != 6) && *condl < 1.f) {
  904. *info = -14;
  905. } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
  906. *info = -16;
  907. } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
  908. *moder != 6) && *condr < 1.f) {
  909. *info = -17;
  910. } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
  911. ipvtng == 2) && isym == 0) {
  912. *info = -18;
  913. } else if (ipvtng != 0 && badpvt) {
  914. *info = -19;
  915. } else if (*kl < 0) {
  916. *info = -20;
  917. } else if (*ku < 0 || isym == 0 && *kl != *ku) {
  918. *info = -21;
  919. } else if (*sparse < 0.f || *sparse > 1.f) {
  920. *info = -22;
  921. } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
  922. ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
  923. || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
  924. {
  925. *info = -24;
  926. } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
  927. (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
  928. 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
  929. *info = -26;
  930. }
  931. if (*info != 0) {
  932. i__1 = -(*info);
  933. xerbla_("SLATMR", &i__1, 6);
  934. return;
  935. }
  936. /* Decide if we can pivot consistently */
  937. fulbnd = FALSE_;
  938. if (kuu == *n - 1 && kll == *m - 1) {
  939. fulbnd = TRUE_;
  940. }
  941. /* Initialize random number generator */
  942. for (i__ = 1; i__ <= 4; ++i__) {
  943. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  944. /* L30: */
  945. }
  946. iseed[4] = (iseed[4] / 2 << 1) + 1;
  947. /* 2) Set up D, DL, and DR, if indicated. */
  948. /* Compute D according to COND and MODE */
  949. slatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
  950. if (*info != 0) {
  951. *info = 1;
  952. return;
  953. }
  954. if (*mode != 0 && *mode != -6 && *mode != 6) {
  955. /* Scale by DMAX */
  956. temp = abs(d__[1]);
  957. i__1 = mnmin;
  958. for (i__ = 2; i__ <= i__1; ++i__) {
  959. /* Computing MAX */
  960. r__2 = temp, r__3 = (r__1 = d__[i__], abs(r__1));
  961. temp = f2cmax(r__2,r__3);
  962. /* L40: */
  963. }
  964. if (temp == 0.f && *dmax__ != 0.f) {
  965. *info = 2;
  966. return;
  967. }
  968. if (temp != 0.f) {
  969. alpha = *dmax__ / temp;
  970. } else {
  971. alpha = 1.f;
  972. }
  973. i__1 = mnmin;
  974. for (i__ = 1; i__ <= i__1; ++i__) {
  975. d__[i__] = alpha * d__[i__];
  976. /* L50: */
  977. }
  978. }
  979. /* Compute DL if grading set */
  980. if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) {
  981. slatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
  982. if (*info != 0) {
  983. *info = 3;
  984. return;
  985. }
  986. }
  987. /* Compute DR if grading set */
  988. if (igrade == 2 || igrade == 3) {
  989. slatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
  990. if (*info != 0) {
  991. *info = 4;
  992. return;
  993. }
  994. }
  995. /* 3) Generate IWORK if pivoting */
  996. if (ipvtng > 0) {
  997. i__1 = npvts;
  998. for (i__ = 1; i__ <= i__1; ++i__) {
  999. iwork[i__] = i__;
  1000. /* L60: */
  1001. }
  1002. if (fulbnd) {
  1003. i__1 = npvts;
  1004. for (i__ = 1; i__ <= i__1; ++i__) {
  1005. k = ipivot[i__];
  1006. j = iwork[i__];
  1007. iwork[i__] = iwork[k];
  1008. iwork[k] = j;
  1009. /* L70: */
  1010. }
  1011. } else {
  1012. for (i__ = npvts; i__ >= 1; --i__) {
  1013. k = ipivot[i__];
  1014. j = iwork[i__];
  1015. iwork[i__] = iwork[k];
  1016. iwork[k] = j;
  1017. /* L80: */
  1018. }
  1019. }
  1020. }
  1021. /* 4) Generate matrices for each kind of PACKing */
  1022. /* Always sweep matrix columnwise (if symmetric, upper */
  1023. /* half only) so that matrix generated does not depend */
  1024. /* on PACK */
  1025. if (fulbnd) {
  1026. /* Use SLATM3 so matrices generated with differing PIVOTing only */
  1027. /* differ only in the order of their rows and/or columns. */
  1028. if (ipack == 0) {
  1029. if (isym == 0) {
  1030. i__1 = *n;
  1031. for (j = 1; j <= i__1; ++j) {
  1032. i__2 = j;
  1033. for (i__ = 1; i__ <= i__2; ++i__) {
  1034. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1035. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1036. dr[1], &ipvtng, &iwork[1], sparse);
  1037. a[isub + jsub * a_dim1] = temp;
  1038. a[jsub + isub * a_dim1] = temp;
  1039. /* L90: */
  1040. }
  1041. /* L100: */
  1042. }
  1043. } else if (isym == 1) {
  1044. i__1 = *n;
  1045. for (j = 1; j <= i__1; ++j) {
  1046. i__2 = *m;
  1047. for (i__ = 1; i__ <= i__2; ++i__) {
  1048. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1049. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1050. dr[1], &ipvtng, &iwork[1], sparse);
  1051. a[isub + jsub * a_dim1] = temp;
  1052. /* L110: */
  1053. }
  1054. /* L120: */
  1055. }
  1056. }
  1057. } else if (ipack == 1) {
  1058. i__1 = *n;
  1059. for (j = 1; j <= i__1; ++j) {
  1060. i__2 = j;
  1061. for (i__ = 1; i__ <= i__2; ++i__) {
  1062. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1063. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1064. , &ipvtng, &iwork[1], sparse);
  1065. mnsub = f2cmin(isub,jsub);
  1066. mxsub = f2cmax(isub,jsub);
  1067. a[mnsub + mxsub * a_dim1] = temp;
  1068. if (mnsub != mxsub) {
  1069. a[mxsub + mnsub * a_dim1] = 0.f;
  1070. }
  1071. /* L130: */
  1072. }
  1073. /* L140: */
  1074. }
  1075. } else if (ipack == 2) {
  1076. i__1 = *n;
  1077. for (j = 1; j <= i__1; ++j) {
  1078. i__2 = j;
  1079. for (i__ = 1; i__ <= i__2; ++i__) {
  1080. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1081. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1082. , &ipvtng, &iwork[1], sparse);
  1083. mnsub = f2cmin(isub,jsub);
  1084. mxsub = f2cmax(isub,jsub);
  1085. a[mxsub + mnsub * a_dim1] = temp;
  1086. if (mnsub != mxsub) {
  1087. a[mnsub + mxsub * a_dim1] = 0.f;
  1088. }
  1089. /* L150: */
  1090. }
  1091. /* L160: */
  1092. }
  1093. } else if (ipack == 3) {
  1094. i__1 = *n;
  1095. for (j = 1; j <= i__1; ++j) {
  1096. i__2 = j;
  1097. for (i__ = 1; i__ <= i__2; ++i__) {
  1098. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1099. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1100. , &ipvtng, &iwork[1], sparse);
  1101. /* Compute K = location of (ISUB,JSUB) entry in packed */
  1102. /* array */
  1103. mnsub = f2cmin(isub,jsub);
  1104. mxsub = f2cmax(isub,jsub);
  1105. k = mxsub * (mxsub - 1) / 2 + mnsub;
  1106. /* Convert K to (IISUB,JJSUB) location */
  1107. jjsub = (k - 1) / *lda + 1;
  1108. iisub = k - *lda * (jjsub - 1);
  1109. a[iisub + jjsub * a_dim1] = temp;
  1110. /* L170: */
  1111. }
  1112. /* L180: */
  1113. }
  1114. } else if (ipack == 4) {
  1115. i__1 = *n;
  1116. for (j = 1; j <= i__1; ++j) {
  1117. i__2 = j;
  1118. for (i__ = 1; i__ <= i__2; ++i__) {
  1119. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1120. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1121. , &ipvtng, &iwork[1], sparse);
  1122. /* Compute K = location of (I,J) entry in packed array */
  1123. mnsub = f2cmin(isub,jsub);
  1124. mxsub = f2cmax(isub,jsub);
  1125. if (mnsub == 1) {
  1126. k = mxsub;
  1127. } else {
  1128. k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
  1129. mnsub + 2) / 2 + mxsub - mnsub + 1;
  1130. }
  1131. /* Convert K to (IISUB,JJSUB) location */
  1132. jjsub = (k - 1) / *lda + 1;
  1133. iisub = k - *lda * (jjsub - 1);
  1134. a[iisub + jjsub * a_dim1] = temp;
  1135. /* L190: */
  1136. }
  1137. /* L200: */
  1138. }
  1139. } else if (ipack == 5) {
  1140. i__1 = *n;
  1141. for (j = 1; j <= i__1; ++j) {
  1142. i__2 = j;
  1143. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1144. if (i__ < 1) {
  1145. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.f;
  1146. } else {
  1147. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1148. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1149. dr[1], &ipvtng, &iwork[1], sparse);
  1150. mnsub = f2cmin(isub,jsub);
  1151. mxsub = f2cmax(isub,jsub);
  1152. a[mxsub - mnsub + 1 + mnsub * a_dim1] = temp;
  1153. }
  1154. /* L210: */
  1155. }
  1156. /* L220: */
  1157. }
  1158. } else if (ipack == 6) {
  1159. i__1 = *n;
  1160. for (j = 1; j <= i__1; ++j) {
  1161. i__2 = j;
  1162. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1163. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1164. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1165. , &ipvtng, &iwork[1], sparse);
  1166. mnsub = f2cmin(isub,jsub);
  1167. mxsub = f2cmax(isub,jsub);
  1168. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1169. /* L230: */
  1170. }
  1171. /* L240: */
  1172. }
  1173. } else if (ipack == 7) {
  1174. if (isym == 0) {
  1175. i__1 = *n;
  1176. for (j = 1; j <= i__1; ++j) {
  1177. i__2 = j;
  1178. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1179. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1180. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1181. dr[1], &ipvtng, &iwork[1], sparse);
  1182. mnsub = f2cmin(isub,jsub);
  1183. mxsub = f2cmax(isub,jsub);
  1184. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1185. if (i__ < 1) {
  1186. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.f;
  1187. }
  1188. if (i__ >= 1 && mnsub != mxsub) {
  1189. a[mxsub - mnsub + 1 + kuu + mnsub * a_dim1] =
  1190. temp;
  1191. }
  1192. /* L250: */
  1193. }
  1194. /* L260: */
  1195. }
  1196. } else if (isym == 1) {
  1197. i__1 = *n;
  1198. for (j = 1; j <= i__1; ++j) {
  1199. i__2 = j + kll;
  1200. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1201. temp = slatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1202. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1203. dr[1], &ipvtng, &iwork[1], sparse);
  1204. a[isub - jsub + kuu + 1 + jsub * a_dim1] = temp;
  1205. /* L270: */
  1206. }
  1207. /* L280: */
  1208. }
  1209. }
  1210. }
  1211. } else {
  1212. /* Use SLATM2 */
  1213. if (ipack == 0) {
  1214. if (isym == 0) {
  1215. i__1 = *n;
  1216. for (j = 1; j <= i__1; ++j) {
  1217. i__2 = j;
  1218. for (i__ = 1; i__ <= i__2; ++i__) {
  1219. a[i__ + j * a_dim1] = slatm2_(m, n, &i__, &j, kl, ku,
  1220. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1221. dr[1], &ipvtng, &iwork[1], sparse);
  1222. a[j + i__ * a_dim1] = a[i__ + j * a_dim1];
  1223. /* L290: */
  1224. }
  1225. /* L300: */
  1226. }
  1227. } else if (isym == 1) {
  1228. i__1 = *n;
  1229. for (j = 1; j <= i__1; ++j) {
  1230. i__2 = *m;
  1231. for (i__ = 1; i__ <= i__2; ++i__) {
  1232. a[i__ + j * a_dim1] = slatm2_(m, n, &i__, &j, kl, ku,
  1233. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1234. dr[1], &ipvtng, &iwork[1], sparse);
  1235. /* L310: */
  1236. }
  1237. /* L320: */
  1238. }
  1239. }
  1240. } else if (ipack == 1) {
  1241. i__1 = *n;
  1242. for (j = 1; j <= i__1; ++j) {
  1243. i__2 = j;
  1244. for (i__ = 1; i__ <= i__2; ++i__) {
  1245. a[i__ + j * a_dim1] = slatm2_(m, n, &i__, &j, kl, ku, &
  1246. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1247. , &ipvtng, &iwork[1], sparse);
  1248. if (i__ != j) {
  1249. a[j + i__ * a_dim1] = 0.f;
  1250. }
  1251. /* L330: */
  1252. }
  1253. /* L340: */
  1254. }
  1255. } else if (ipack == 2) {
  1256. i__1 = *n;
  1257. for (j = 1; j <= i__1; ++j) {
  1258. i__2 = j;
  1259. for (i__ = 1; i__ <= i__2; ++i__) {
  1260. a[j + i__ * a_dim1] = slatm2_(m, n, &i__, &j, kl, ku, &
  1261. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1262. , &ipvtng, &iwork[1], sparse);
  1263. if (i__ != j) {
  1264. a[i__ + j * a_dim1] = 0.f;
  1265. }
  1266. /* L350: */
  1267. }
  1268. /* L360: */
  1269. }
  1270. } else if (ipack == 3) {
  1271. isub = 0;
  1272. jsub = 1;
  1273. i__1 = *n;
  1274. for (j = 1; j <= i__1; ++j) {
  1275. i__2 = j;
  1276. for (i__ = 1; i__ <= i__2; ++i__) {
  1277. ++isub;
  1278. if (isub > *lda) {
  1279. isub = 1;
  1280. ++jsub;
  1281. }
  1282. a[isub + jsub * a_dim1] = slatm2_(m, n, &i__, &j, kl, ku,
  1283. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[
  1284. 1], &ipvtng, &iwork[1], sparse);
  1285. /* L370: */
  1286. }
  1287. /* L380: */
  1288. }
  1289. } else if (ipack == 4) {
  1290. if (isym == 0) {
  1291. i__1 = *n;
  1292. for (j = 1; j <= i__1; ++j) {
  1293. i__2 = j;
  1294. for (i__ = 1; i__ <= i__2; ++i__) {
  1295. /* Compute K = location of (I,J) entry in packed array */
  1296. if (i__ == 1) {
  1297. k = j;
  1298. } else {
  1299. k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
  1300. i__ + 2) / 2 + j - i__ + 1;
  1301. }
  1302. /* Convert K to (ISUB,JSUB) location */
  1303. jsub = (k - 1) / *lda + 1;
  1304. isub = k - *lda * (jsub - 1);
  1305. a[isub + jsub * a_dim1] = slatm2_(m, n, &i__, &j, kl,
  1306. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1307. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1308. /* L390: */
  1309. }
  1310. /* L400: */
  1311. }
  1312. } else {
  1313. isub = 0;
  1314. jsub = 1;
  1315. i__1 = *n;
  1316. for (j = 1; j <= i__1; ++j) {
  1317. i__2 = *m;
  1318. for (i__ = j; i__ <= i__2; ++i__) {
  1319. ++isub;
  1320. if (isub > *lda) {
  1321. isub = 1;
  1322. ++jsub;
  1323. }
  1324. a[isub + jsub * a_dim1] = slatm2_(m, n, &i__, &j, kl,
  1325. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1326. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1327. /* L410: */
  1328. }
  1329. /* L420: */
  1330. }
  1331. }
  1332. } else if (ipack == 5) {
  1333. i__1 = *n;
  1334. for (j = 1; j <= i__1; ++j) {
  1335. i__2 = j;
  1336. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1337. if (i__ < 1) {
  1338. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.f;
  1339. } else {
  1340. a[j - i__ + 1 + i__ * a_dim1] = slatm2_(m, n, &i__, &
  1341. j, kl, ku, &idist, &iseed[1], &d__[1], &
  1342. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1343. sparse);
  1344. }
  1345. /* L430: */
  1346. }
  1347. /* L440: */
  1348. }
  1349. } else if (ipack == 6) {
  1350. i__1 = *n;
  1351. for (j = 1; j <= i__1; ++j) {
  1352. i__2 = j;
  1353. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1354. a[i__ - j + kuu + 1 + j * a_dim1] = slatm2_(m, n, &i__, &
  1355. j, kl, ku, &idist, &iseed[1], &d__[1], &igrade, &
  1356. dl[1], &dr[1], &ipvtng, &iwork[1], sparse);
  1357. /* L450: */
  1358. }
  1359. /* L460: */
  1360. }
  1361. } else if (ipack == 7) {
  1362. if (isym == 0) {
  1363. i__1 = *n;
  1364. for (j = 1; j <= i__1; ++j) {
  1365. i__2 = j;
  1366. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1367. a[i__ - j + kuu + 1 + j * a_dim1] = slatm2_(m, n, &
  1368. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1369. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1370. sparse);
  1371. if (i__ < 1) {
  1372. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.f;
  1373. }
  1374. if (i__ >= 1 && i__ != j) {
  1375. a[j - i__ + 1 + kuu + i__ * a_dim1] = a[i__ - j +
  1376. kuu + 1 + j * a_dim1];
  1377. }
  1378. /* L470: */
  1379. }
  1380. /* L480: */
  1381. }
  1382. } else if (isym == 1) {
  1383. i__1 = *n;
  1384. for (j = 1; j <= i__1; ++j) {
  1385. i__2 = j + kll;
  1386. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1387. a[i__ - j + kuu + 1 + j * a_dim1] = slatm2_(m, n, &
  1388. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1389. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1390. sparse);
  1391. /* L490: */
  1392. }
  1393. /* L500: */
  1394. }
  1395. }
  1396. }
  1397. }
  1398. /* 5) Scaling the norm */
  1399. if (ipack == 0) {
  1400. onorm = slange_("M", m, n, &a[a_offset], lda, tempa);
  1401. } else if (ipack == 1) {
  1402. onorm = slansy_("M", "U", n, &a[a_offset], lda, tempa);
  1403. } else if (ipack == 2) {
  1404. onorm = slansy_("M", "L", n, &a[a_offset], lda, tempa);
  1405. } else if (ipack == 3) {
  1406. onorm = slansp_("M", "U", n, &a[a_offset], tempa);
  1407. } else if (ipack == 4) {
  1408. onorm = slansp_("M", "L", n, &a[a_offset], tempa);
  1409. } else if (ipack == 5) {
  1410. onorm = slansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
  1411. } else if (ipack == 6) {
  1412. onorm = slansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
  1413. } else if (ipack == 7) {
  1414. onorm = slangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
  1415. }
  1416. if (*anorm >= 0.f) {
  1417. if (*anorm > 0.f && onorm == 0.f) {
  1418. /* Desired scaling impossible */
  1419. *info = 5;
  1420. return;
  1421. } else if (*anorm > 1.f && onorm < 1.f || *anorm < 1.f && onorm > 1.f)
  1422. {
  1423. /* Scale carefully to avoid over / underflow */
  1424. if (ipack <= 2) {
  1425. i__1 = *n;
  1426. for (j = 1; j <= i__1; ++j) {
  1427. r__1 = 1.f / onorm;
  1428. sscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
  1429. sscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
  1430. /* L510: */
  1431. }
  1432. } else if (ipack == 3 || ipack == 4) {
  1433. i__1 = *n * (*n + 1) / 2;
  1434. r__1 = 1.f / onorm;
  1435. sscal_(&i__1, &r__1, &a[a_offset], &c__1);
  1436. i__1 = *n * (*n + 1) / 2;
  1437. sscal_(&i__1, anorm, &a[a_offset], &c__1);
  1438. } else if (ipack >= 5) {
  1439. i__1 = *n;
  1440. for (j = 1; j <= i__1; ++j) {
  1441. i__2 = kll + kuu + 1;
  1442. r__1 = 1.f / onorm;
  1443. sscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
  1444. i__2 = kll + kuu + 1;
  1445. sscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
  1446. /* L520: */
  1447. }
  1448. }
  1449. } else {
  1450. /* Scale straightforwardly */
  1451. if (ipack <= 2) {
  1452. i__1 = *n;
  1453. for (j = 1; j <= i__1; ++j) {
  1454. r__1 = *anorm / onorm;
  1455. sscal_(m, &r__1, &a[j * a_dim1 + 1], &c__1);
  1456. /* L530: */
  1457. }
  1458. } else if (ipack == 3 || ipack == 4) {
  1459. i__1 = *n * (*n + 1) / 2;
  1460. r__1 = *anorm / onorm;
  1461. sscal_(&i__1, &r__1, &a[a_offset], &c__1);
  1462. } else if (ipack >= 5) {
  1463. i__1 = *n;
  1464. for (j = 1; j <= i__1; ++j) {
  1465. i__2 = kll + kuu + 1;
  1466. r__1 = *anorm / onorm;
  1467. sscal_(&i__2, &r__1, &a[j * a_dim1 + 1], &c__1);
  1468. /* L540: */
  1469. }
  1470. }
  1471. }
  1472. }
  1473. /* End of SLATMR */
  1474. return;
  1475. } /* slatmr_ */