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.

dlatmr.c 51 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 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 integer c__0 = 0;
  240. static integer c__1 = 1;
  241. /* > \brief \b DLATMR */
  242. /* =========== DOCUMENTATION =========== */
  243. /* Online html documentation available at */
  244. /* http://www.netlib.org/lapack/explore-html/ */
  245. /* Definition: */
  246. /* =========== */
  247. /* SUBROUTINE DLATMR( M, N, DIST, ISEED, SYM, D, MODE, COND, DMAX, */
  248. /* RSIGN, GRADE, DL, MODEL, CONDL, DR, MODER, */
  249. /* CONDR, PIVTNG, IPIVOT, KL, KU, SPARSE, ANORM, */
  250. /* PACK, A, LDA, IWORK, INFO ) */
  251. /* CHARACTER DIST, GRADE, PACK, PIVTNG, RSIGN, SYM */
  252. /* INTEGER INFO, KL, KU, LDA, M, MODE, MODEL, MODER, N */
  253. /* DOUBLE PRECISION ANORM, COND, CONDL, CONDR, DMAX, SPARSE */
  254. /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
  255. /* DOUBLE PRECISION A( LDA, * ), D( * ), DL( * ), DR( * ) */
  256. /* > \par Purpose: */
  257. /* ============= */
  258. /* > */
  259. /* > \verbatim */
  260. /* > */
  261. /* > DLATMR generates random matrices of various types for testing */
  262. /* > LAPACK programs. */
  263. /* > */
  264. /* > DLATMR operates by applying the following sequence of */
  265. /* > operations: */
  266. /* > */
  267. /* > Generate a matrix A with random entries of distribution DIST */
  268. /* > which is symmetric if SYM='S', and nonsymmetric */
  269. /* > if SYM='N'. */
  270. /* > */
  271. /* > Set the diagonal to D, where D may be input or */
  272. /* > computed according to MODE, COND, DMAX and RSIGN */
  273. /* > as described below. */
  274. /* > */
  275. /* > Grade the matrix, if desired, from the left and/or right */
  276. /* > as specified by GRADE. The inputs DL, MODEL, CONDL, DR, */
  277. /* > MODER and CONDR also determine the grading as described */
  278. /* > below. */
  279. /* > */
  280. /* > Permute, if desired, the rows and/or columns as specified by */
  281. /* > PIVTNG and IPIVOT. */
  282. /* > */
  283. /* > Set random entries to zero, if desired, to get a random sparse */
  284. /* > matrix as specified by SPARSE. */
  285. /* > */
  286. /* > Make A a band matrix, if desired, by zeroing out the matrix */
  287. /* > outside a band of lower bandwidth KL and upper bandwidth KU. */
  288. /* > */
  289. /* > Scale A, if desired, to have maximum entry ANORM. */
  290. /* > */
  291. /* > Pack the matrix if desired. Options specified by PACK are: */
  292. /* > no packing */
  293. /* > zero out upper half (if symmetric) */
  294. /* > zero out lower half (if symmetric) */
  295. /* > store the upper half columnwise (if symmetric or */
  296. /* > square upper triangular) */
  297. /* > store the lower half columnwise (if symmetric or */
  298. /* > square lower triangular) */
  299. /* > same as upper half rowwise if symmetric */
  300. /* > store the lower triangle in banded format (if symmetric) */
  301. /* > store the upper triangle in banded format (if symmetric) */
  302. /* > store the entire matrix in banded format */
  303. /* > */
  304. /* > Note: If two calls to DLATMR differ only in the PACK parameter, */
  305. /* > they will generate mathematically equivalent matrices. */
  306. /* > */
  307. /* > If two calls to DLATMR both have full bandwidth (KL = M-1 */
  308. /* > and KU = N-1), and differ only in the PIVTNG and PACK */
  309. /* > parameters, then the matrices generated will differ only */
  310. /* > in the order of the rows and/or columns, and otherwise */
  311. /* > contain the same data. This consistency cannot be and */
  312. /* > is not maintained with less than full bandwidth. */
  313. /* > \endverbatim */
  314. /* Arguments: */
  315. /* ========== */
  316. /* > \param[in] M */
  317. /* > \verbatim */
  318. /* > M is INTEGER */
  319. /* > Number of rows of A. Not modified. */
  320. /* > \endverbatim */
  321. /* > */
  322. /* > \param[in] N */
  323. /* > \verbatim */
  324. /* > N is INTEGER */
  325. /* > Number of columns of A. Not modified. */
  326. /* > \endverbatim */
  327. /* > */
  328. /* > \param[in] DIST */
  329. /* > \verbatim */
  330. /* > DIST is CHARACTER*1 */
  331. /* > On entry, DIST specifies the type of distribution to be used */
  332. /* > to generate a random matrix . */
  333. /* > 'U' => UNIFORM( 0, 1 ) ( 'U' for uniform ) */
  334. /* > 'S' => UNIFORM( -1, 1 ) ( 'S' for symmetric ) */
  335. /* > 'N' => NORMAL( 0, 1 ) ( 'N' for normal ) */
  336. /* > Not modified. */
  337. /* > \endverbatim */
  338. /* > */
  339. /* > \param[in,out] ISEED */
  340. /* > \verbatim */
  341. /* > ISEED is INTEGER array, dimension (4) */
  342. /* > On entry ISEED specifies the seed of the random number */
  343. /* > generator. They should lie between 0 and 4095 inclusive, */
  344. /* > and ISEED(4) should be odd. The random number generator */
  345. /* > uses a linear congruential sequence limited to small */
  346. /* > integers, and so should produce machine independent */
  347. /* > random numbers. The values of ISEED are changed on */
  348. /* > exit, and can be used in the next call to DLATMR */
  349. /* > to continue the same random number sequence. */
  350. /* > Changed on exit. */
  351. /* > \endverbatim */
  352. /* > */
  353. /* > \param[in] SYM */
  354. /* > \verbatim */
  355. /* > SYM is CHARACTER*1 */
  356. /* > If SYM='S' or 'H', generated matrix is symmetric. */
  357. /* > If SYM='N', generated matrix is nonsymmetric. */
  358. /* > Not modified. */
  359. /* > \endverbatim */
  360. /* > */
  361. /* > \param[in,out] D */
  362. /* > \verbatim */
  363. /* > D is DOUBLE PRECISION array, dimension (f2cmin(M,N)) */
  364. /* > On entry this array specifies the diagonal entries */
  365. /* > of the diagonal of A. D may either be specified */
  366. /* > on entry, or set according to MODE and COND as described */
  367. /* > below. May be changed on exit if MODE is nonzero. */
  368. /* > \endverbatim */
  369. /* > */
  370. /* > \param[in] MODE */
  371. /* > \verbatim */
  372. /* > MODE is INTEGER */
  373. /* > On entry describes how D is to be used: */
  374. /* > MODE = 0 means use D as input */
  375. /* > MODE = 1 sets D(1)=1 and D(2:N)=1.0/COND */
  376. /* > MODE = 2 sets D(1:N-1)=1 and D(N)=1.0/COND */
  377. /* > MODE = 3 sets D(I)=COND**(-(I-1)/(N-1)) */
  378. /* > MODE = 4 sets D(i)=1 - (i-1)/(N-1)*(1 - 1/COND) */
  379. /* > MODE = 5 sets D to random numbers in the range */
  380. /* > ( 1/COND , 1 ) such that their logarithms */
  381. /* > are uniformly distributed. */
  382. /* > MODE = 6 set D to random numbers from same distribution */
  383. /* > as the rest of the matrix. */
  384. /* > MODE < 0 has the same meaning as ABS(MODE), except that */
  385. /* > the order of the elements of D is reversed. */
  386. /* > Thus if MODE is positive, D has entries ranging from */
  387. /* > 1 to 1/COND, if negative, from 1/COND to 1, */
  388. /* > Not modified. */
  389. /* > \endverbatim */
  390. /* > */
  391. /* > \param[in] COND */
  392. /* > \verbatim */
  393. /* > COND is DOUBLE PRECISION */
  394. /* > On entry, used as described under MODE above. */
  395. /* > If used, it must be >= 1. Not modified. */
  396. /* > \endverbatim */
  397. /* > */
  398. /* > \param[in] DMAX */
  399. /* > \verbatim */
  400. /* > DMAX is DOUBLE PRECISION */
  401. /* > If MODE neither -6, 0 nor 6, the diagonal is scaled by */
  402. /* > DMAX / f2cmax(abs(D(i))), so that maximum absolute entry */
  403. /* > of diagonal is abs(DMAX). If DMAX is negative (or zero), */
  404. /* > diagonal will be scaled by a negative number (or zero). */
  405. /* > \endverbatim */
  406. /* > */
  407. /* > \param[in] RSIGN */
  408. /* > \verbatim */
  409. /* > RSIGN is CHARACTER*1 */
  410. /* > If MODE neither -6, 0 nor 6, specifies sign of diagonal */
  411. /* > as follows: */
  412. /* > 'T' => diagonal entries are multiplied by 1 or -1 */
  413. /* > with probability .5 */
  414. /* > 'F' => diagonal unchanged */
  415. /* > Not modified. */
  416. /* > \endverbatim */
  417. /* > */
  418. /* > \param[in] GRADE */
  419. /* > \verbatim */
  420. /* > GRADE is CHARACTER*1 */
  421. /* > Specifies grading of matrix as follows: */
  422. /* > 'N' => no grading */
  423. /* > 'L' => matrix premultiplied by diag( DL ) */
  424. /* > (only if matrix nonsymmetric) */
  425. /* > 'R' => matrix postmultiplied by diag( DR ) */
  426. /* > (only if matrix nonsymmetric) */
  427. /* > 'B' => matrix premultiplied by diag( DL ) and */
  428. /* > postmultiplied by diag( DR ) */
  429. /* > (only if matrix nonsymmetric) */
  430. /* > 'S' or 'H' => matrix premultiplied by diag( DL ) and */
  431. /* > postmultiplied by diag( DL ) */
  432. /* > ('S' for symmetric, or 'H' for Hermitian) */
  433. /* > 'E' => matrix premultiplied by diag( DL ) and */
  434. /* > postmultiplied by inv( diag( DL ) ) */
  435. /* > ( 'E' for eigenvalue invariance) */
  436. /* > (only if matrix nonsymmetric) */
  437. /* > Note: if GRADE='E', then M must equal N. */
  438. /* > Not modified. */
  439. /* > \endverbatim */
  440. /* > */
  441. /* > \param[in,out] DL */
  442. /* > \verbatim */
  443. /* > DL is DOUBLE PRECISION array, dimension (M) */
  444. /* > If MODEL=0, then on entry this array specifies the diagonal */
  445. /* > entries of a diagonal matrix used as described under GRADE */
  446. /* > above. If MODEL is not zero, then DL will be set according */
  447. /* > to MODEL and CONDL, analogous to the way D is set according */
  448. /* > to MODE and COND (except there is no DMAX parameter for DL). */
  449. /* > If GRADE='E', then DL cannot have zero entries. */
  450. /* > Not referenced if GRADE = 'N' or 'R'. Changed on exit. */
  451. /* > \endverbatim */
  452. /* > */
  453. /* > \param[in] MODEL */
  454. /* > \verbatim */
  455. /* > MODEL is INTEGER */
  456. /* > This specifies how the diagonal array DL is to be computed, */
  457. /* > just as MODE specifies how D is to be computed. */
  458. /* > Not modified. */
  459. /* > \endverbatim */
  460. /* > */
  461. /* > \param[in] CONDL */
  462. /* > \verbatim */
  463. /* > CONDL is DOUBLE PRECISION */
  464. /* > When MODEL is not zero, this specifies the condition number */
  465. /* > of the computed DL. Not modified. */
  466. /* > \endverbatim */
  467. /* > */
  468. /* > \param[in,out] DR */
  469. /* > \verbatim */
  470. /* > DR is DOUBLE PRECISION array, dimension (N) */
  471. /* > If MODER=0, then on entry this array specifies the diagonal */
  472. /* > entries of a diagonal matrix used as described under GRADE */
  473. /* > above. If MODER is not zero, then DR will be set according */
  474. /* > to MODER and CONDR, analogous to the way D is set according */
  475. /* > to MODE and COND (except there is no DMAX parameter for DR). */
  476. /* > Not referenced if GRADE = 'N', 'L', 'H', 'S' or 'E'. */
  477. /* > Changed on exit. */
  478. /* > \endverbatim */
  479. /* > */
  480. /* > \param[in] MODER */
  481. /* > \verbatim */
  482. /* > MODER is INTEGER */
  483. /* > This specifies how the diagonal array DR is to be computed, */
  484. /* > just as MODE specifies how D is to be computed. */
  485. /* > Not modified. */
  486. /* > \endverbatim */
  487. /* > */
  488. /* > \param[in] CONDR */
  489. /* > \verbatim */
  490. /* > CONDR is DOUBLE PRECISION */
  491. /* > When MODER is not zero, this specifies the condition number */
  492. /* > of the computed DR. Not modified. */
  493. /* > \endverbatim */
  494. /* > */
  495. /* > \param[in] PIVTNG */
  496. /* > \verbatim */
  497. /* > PIVTNG is CHARACTER*1 */
  498. /* > On entry specifies pivoting permutations as follows: */
  499. /* > 'N' or ' ' => none. */
  500. /* > 'L' => left or row pivoting (matrix must be nonsymmetric). */
  501. /* > 'R' => right or column pivoting (matrix must be */
  502. /* > nonsymmetric). */
  503. /* > 'B' or 'F' => both or full pivoting, i.e., on both sides. */
  504. /* > In this case, M must equal N */
  505. /* > */
  506. /* > If two calls to DLATMR both have full bandwidth (KL = M-1 */
  507. /* > and KU = N-1), and differ only in the PIVTNG and PACK */
  508. /* > parameters, then the matrices generated will differ only */
  509. /* > in the order of the rows and/or columns, and otherwise */
  510. /* > contain the same data. This consistency cannot be */
  511. /* > maintained with less than full bandwidth. */
  512. /* > \endverbatim */
  513. /* > */
  514. /* > \param[in] IPIVOT */
  515. /* > \verbatim */
  516. /* > IPIVOT is INTEGER array, dimension (N or M) */
  517. /* > This array specifies the permutation used. After the */
  518. /* > basic matrix is generated, the rows, columns, or both */
  519. /* > are permuted. If, say, row pivoting is selected, DLATMR */
  520. /* > starts with the *last* row and interchanges the M-th and */
  521. /* > IPIVOT(M)-th rows, then moves to the next-to-last row, */
  522. /* > interchanging the (M-1)-th and the IPIVOT(M-1)-th rows, */
  523. /* > and so on. In terms of "2-cycles", the permutation is */
  524. /* > (1 IPIVOT(1)) (2 IPIVOT(2)) ... (M IPIVOT(M)) */
  525. /* > where the rightmost cycle is applied first. This is the */
  526. /* > *inverse* of the effect of pivoting in LINPACK. The idea */
  527. /* > is that factoring (with pivoting) an identity matrix */
  528. /* > which has been inverse-pivoted in this way should */
  529. /* > result in a pivot vector identical to IPIVOT. */
  530. /* > Not referenced if PIVTNG = 'N'. Not modified. */
  531. /* > \endverbatim */
  532. /* > */
  533. /* > \param[in] KL */
  534. /* > \verbatim */
  535. /* > KL is INTEGER */
  536. /* > On entry specifies the lower bandwidth of the matrix. For */
  537. /* > example, KL=0 implies upper triangular, KL=1 implies upper */
  538. /* > Hessenberg, and KL at least M-1 implies the matrix is not */
  539. /* > banded. Must equal KU if matrix is symmetric. */
  540. /* > Not modified. */
  541. /* > \endverbatim */
  542. /* > */
  543. /* > \param[in] KU */
  544. /* > \verbatim */
  545. /* > KU is INTEGER */
  546. /* > On entry specifies the upper bandwidth of the matrix. For */
  547. /* > example, KU=0 implies lower triangular, KU=1 implies lower */
  548. /* > Hessenberg, and KU at least N-1 implies the matrix is not */
  549. /* > banded. Must equal KL if matrix is symmetric. */
  550. /* > Not modified. */
  551. /* > \endverbatim */
  552. /* > */
  553. /* > \param[in] SPARSE */
  554. /* > \verbatim */
  555. /* > SPARSE is DOUBLE PRECISION */
  556. /* > On entry specifies the sparsity of the matrix if a sparse */
  557. /* > matrix is to be generated. SPARSE should lie between */
  558. /* > 0 and 1. To generate a sparse matrix, for each matrix entry */
  559. /* > a uniform ( 0, 1 ) random number x is generated and */
  560. /* > compared to SPARSE; if x is larger the matrix entry */
  561. /* > is unchanged and if x is smaller the entry is set */
  562. /* > to zero. Thus on the average a fraction SPARSE of the */
  563. /* > entries will be set to zero. */
  564. /* > Not modified. */
  565. /* > \endverbatim */
  566. /* > */
  567. /* > \param[in] ANORM */
  568. /* > \verbatim */
  569. /* > ANORM is DOUBLE PRECISION */
  570. /* > On entry specifies maximum entry of output matrix */
  571. /* > (output matrix will by multiplied by a constant so that */
  572. /* > its largest absolute entry equal ANORM) */
  573. /* > if ANORM is nonnegative. If ANORM is negative no scaling */
  574. /* > is done. Not modified. */
  575. /* > \endverbatim */
  576. /* > */
  577. /* > \param[in] PACK */
  578. /* > \verbatim */
  579. /* > PACK is CHARACTER*1 */
  580. /* > On entry specifies packing of matrix as follows: */
  581. /* > 'N' => no packing */
  582. /* > 'U' => zero out all subdiagonal entries (if symmetric) */
  583. /* > 'L' => zero out all superdiagonal entries (if symmetric) */
  584. /* > 'C' => store the upper triangle columnwise */
  585. /* > (only if matrix symmetric or square upper triangular) */
  586. /* > 'R' => store the lower triangle columnwise */
  587. /* > (only if matrix symmetric or square lower triangular) */
  588. /* > (same as upper half rowwise if symmetric) */
  589. /* > 'B' => store the lower triangle in band storage scheme */
  590. /* > (only if matrix symmetric) */
  591. /* > 'Q' => store the upper triangle in band storage scheme */
  592. /* > (only if matrix symmetric) */
  593. /* > 'Z' => store the entire matrix in band storage scheme */
  594. /* > (pivoting can be provided for by using this */
  595. /* > option to store A in the trailing rows of */
  596. /* > the allocated storage) */
  597. /* > */
  598. /* > Using these options, the various LAPACK packed and banded */
  599. /* > storage schemes can be obtained: */
  600. /* > GB - use 'Z' */
  601. /* > PB, SB or TB - use 'B' or 'Q' */
  602. /* > PP, SP or TP - use 'C' or 'R' */
  603. /* > */
  604. /* > If two calls to DLATMR differ only in the PACK parameter, */
  605. /* > they will generate mathematically equivalent matrices. */
  606. /* > Not modified. */
  607. /* > \endverbatim */
  608. /* > */
  609. /* > \param[out] A */
  610. /* > \verbatim */
  611. /* > A is DOUBLE PRECISION array, dimension (LDA,N) */
  612. /* > On exit A is the desired test matrix. Only those */
  613. /* > entries of A which are significant on output */
  614. /* > will be referenced (even if A is in packed or band */
  615. /* > storage format). The 'unoccupied corners' of A in */
  616. /* > band format will be zeroed out. */
  617. /* > \endverbatim */
  618. /* > */
  619. /* > \param[in] LDA */
  620. /* > \verbatim */
  621. /* > LDA is INTEGER */
  622. /* > on entry LDA specifies the first dimension of A as */
  623. /* > declared in the calling program. */
  624. /* > If PACK='N', 'U' or 'L', LDA must be at least f2cmax ( 1, M ). */
  625. /* > If PACK='C' or 'R', LDA must be at least 1. */
  626. /* > If PACK='B', or 'Q', LDA must be MIN ( KU+1, N ) */
  627. /* > If PACK='Z', LDA must be at least KUU+KLL+1, where */
  628. /* > KUU = MIN ( KU, N-1 ) and KLL = MIN ( KL, M-1 ) */
  629. /* > Not modified. */
  630. /* > \endverbatim */
  631. /* > */
  632. /* > \param[out] IWORK */
  633. /* > \verbatim */
  634. /* > IWORK is INTEGER array, dimension ( N or M) */
  635. /* > Workspace. Not referenced if PIVTNG = 'N'. Changed on exit. */
  636. /* > \endverbatim */
  637. /* > */
  638. /* > \param[out] INFO */
  639. /* > \verbatim */
  640. /* > INFO is INTEGER */
  641. /* > Error parameter on exit: */
  642. /* > 0 => normal return */
  643. /* > -1 => M negative or unequal to N and SYM='S' or 'H' */
  644. /* > -2 => N negative */
  645. /* > -3 => DIST illegal string */
  646. /* > -5 => SYM illegal string */
  647. /* > -7 => MODE not in range -6 to 6 */
  648. /* > -8 => COND less than 1.0, and MODE neither -6, 0 nor 6 */
  649. /* > -10 => MODE neither -6, 0 nor 6 and RSIGN illegal string */
  650. /* > -11 => GRADE illegal string, or GRADE='E' and */
  651. /* > M not equal to N, or GRADE='L', 'R', 'B' or 'E' and */
  652. /* > SYM = 'S' or 'H' */
  653. /* > -12 => GRADE = 'E' and DL contains zero */
  654. /* > -13 => MODEL not in range -6 to 6 and GRADE= 'L', 'B', 'H', */
  655. /* > 'S' or 'E' */
  656. /* > -14 => CONDL less than 1.0, GRADE='L', 'B', 'H', 'S' or 'E', */
  657. /* > and MODEL neither -6, 0 nor 6 */
  658. /* > -16 => MODER not in range -6 to 6 and GRADE= 'R' or 'B' */
  659. /* > -17 => CONDR less than 1.0, GRADE='R' or 'B', and */
  660. /* > MODER neither -6, 0 nor 6 */
  661. /* > -18 => PIVTNG illegal string, or PIVTNG='B' or 'F' and */
  662. /* > M not equal to N, or PIVTNG='L' or 'R' and SYM='S' */
  663. /* > or 'H' */
  664. /* > -19 => IPIVOT contains out of range number and */
  665. /* > PIVTNG not equal to 'N' */
  666. /* > -20 => KL negative */
  667. /* > -21 => KU negative, or SYM='S' or 'H' and KU not equal to KL */
  668. /* > -22 => SPARSE not in range 0. to 1. */
  669. /* > -24 => PACK illegal string, or PACK='U', 'L', 'B' or 'Q' */
  670. /* > and SYM='N', or PACK='C' and SYM='N' and either KL */
  671. /* > not equal to 0 or N not equal to M, or PACK='R' and */
  672. /* > SYM='N', and either KU not equal to 0 or N not equal */
  673. /* > to M */
  674. /* > -26 => LDA too small */
  675. /* > 1 => Error return from DLATM1 (computing D) */
  676. /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
  677. /* > 3 => Error return from DLATM1 (computing DL) */
  678. /* > 4 => Error return from DLATM1 (computing DR) */
  679. /* > 5 => ANORM is positive, but matrix constructed prior to */
  680. /* > attempting to scale it to have norm ANORM, is zero */
  681. /* > \endverbatim */
  682. /* Authors: */
  683. /* ======== */
  684. /* > \author Univ. of Tennessee */
  685. /* > \author Univ. of California Berkeley */
  686. /* > \author Univ. of Colorado Denver */
  687. /* > \author NAG Ltd. */
  688. /* > \date December 2016 */
  689. /* > \ingroup double_matgen */
  690. /* ===================================================================== */
  691. /* Subroutine */ void dlatmr_(integer *m, integer *n, char *dist, integer *
  692. iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
  693. doublereal *dmax__, char *rsign, char *grade, doublereal *dl, integer
  694. *model, doublereal *condl, doublereal *dr, integer *moder, doublereal
  695. *condr, char *pivtng, integer *ipivot, integer *kl, integer *ku,
  696. doublereal *sparse, doublereal *anorm, char *pack, doublereal *a,
  697. integer *lda, integer *iwork, integer *info)
  698. {
  699. /* System generated locals */
  700. integer a_dim1, a_offset, i__1, i__2;
  701. doublereal d__1, d__2, d__3;
  702. /* Local variables */
  703. integer isub, jsub;
  704. doublereal temp;
  705. integer isym, i__, j, k;
  706. doublereal alpha;
  707. extern /* Subroutine */ void dscal_(integer *, doublereal *, doublereal *,
  708. integer *);
  709. integer ipack;
  710. extern logical lsame_(char *, char *);
  711. doublereal tempa[1];
  712. integer iisub, idist, jjsub, mnmin;
  713. logical dzero;
  714. integer mnsub;
  715. doublereal onorm;
  716. integer mxsub, npvts;
  717. extern /* Subroutine */ void dlatm1_(integer *, doublereal *, integer *,
  718. integer *, integer *, doublereal *, integer *, integer *);
  719. extern doublereal dlatm2_(integer *, integer *, integer *, integer *,
  720. integer *, integer *, integer *, integer *, doublereal *, integer
  721. *, doublereal *, doublereal *, integer *, integer *, doublereal *)
  722. , dlatm3_(integer *, integer *, integer *, integer *, integer *,
  723. integer *, integer *, integer *, integer *, integer *, doublereal
  724. *, integer *, doublereal *, doublereal *, integer *, integer *,
  725. doublereal *), dlangb_(char *, integer *, integer *, integer *,
  726. doublereal *, integer *, doublereal *), dlange_(char *,
  727. integer *, integer *, doublereal *, integer *, doublereal *);
  728. integer igrade;
  729. extern doublereal dlansb_(char *, char *, integer *, integer *,
  730. doublereal *, integer *, doublereal *);
  731. logical fulbnd;
  732. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  733. logical badpvt;
  734. extern doublereal dlansp_(char *, char *, integer *, doublereal *,
  735. doublereal *), dlansy_(char *, char *, integer *,
  736. doublereal *, integer *, doublereal *);
  737. integer irsign, ipvtng, kll, kuu;
  738. /* -- LAPACK computational routine (version 3.7.0) -- */
  739. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  740. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  741. /* December 2016 */
  742. /* ===================================================================== */
  743. /* 1) Decode and Test the input parameters. */
  744. /* Initialize flags & seed. */
  745. /* Parameter adjustments */
  746. --iseed;
  747. --d__;
  748. --dl;
  749. --dr;
  750. --ipivot;
  751. a_dim1 = *lda;
  752. a_offset = 1 + a_dim1 * 1;
  753. a -= a_offset;
  754. --iwork;
  755. /* Function Body */
  756. *info = 0;
  757. /* Quick return if possible */
  758. if (*m == 0 || *n == 0) {
  759. return;
  760. }
  761. /* Decode DIST */
  762. if (lsame_(dist, "U")) {
  763. idist = 1;
  764. } else if (lsame_(dist, "S")) {
  765. idist = 2;
  766. } else if (lsame_(dist, "N")) {
  767. idist = 3;
  768. } else {
  769. idist = -1;
  770. }
  771. /* Decode SYM */
  772. if (lsame_(sym, "S")) {
  773. isym = 0;
  774. } else if (lsame_(sym, "N")) {
  775. isym = 1;
  776. } else if (lsame_(sym, "H")) {
  777. isym = 0;
  778. } else {
  779. isym = -1;
  780. }
  781. /* Decode RSIGN */
  782. if (lsame_(rsign, "F")) {
  783. irsign = 0;
  784. } else if (lsame_(rsign, "T")) {
  785. irsign = 1;
  786. } else {
  787. irsign = -1;
  788. }
  789. /* Decode PIVTNG */
  790. if (lsame_(pivtng, "N")) {
  791. ipvtng = 0;
  792. } else if (lsame_(pivtng, " ")) {
  793. ipvtng = 0;
  794. } else if (lsame_(pivtng, "L")) {
  795. ipvtng = 1;
  796. npvts = *m;
  797. } else if (lsame_(pivtng, "R")) {
  798. ipvtng = 2;
  799. npvts = *n;
  800. } else if (lsame_(pivtng, "B")) {
  801. ipvtng = 3;
  802. npvts = f2cmin(*n,*m);
  803. } else if (lsame_(pivtng, "F")) {
  804. ipvtng = 3;
  805. npvts = f2cmin(*n,*m);
  806. } else {
  807. ipvtng = -1;
  808. }
  809. /* Decode GRADE */
  810. if (lsame_(grade, "N")) {
  811. igrade = 0;
  812. } else if (lsame_(grade, "L")) {
  813. igrade = 1;
  814. } else if (lsame_(grade, "R")) {
  815. igrade = 2;
  816. } else if (lsame_(grade, "B")) {
  817. igrade = 3;
  818. } else if (lsame_(grade, "E")) {
  819. igrade = 4;
  820. } else if (lsame_(grade, "H") || lsame_(grade,
  821. "S")) {
  822. igrade = 5;
  823. } else {
  824. igrade = -1;
  825. }
  826. /* Decode PACK */
  827. if (lsame_(pack, "N")) {
  828. ipack = 0;
  829. } else if (lsame_(pack, "U")) {
  830. ipack = 1;
  831. } else if (lsame_(pack, "L")) {
  832. ipack = 2;
  833. } else if (lsame_(pack, "C")) {
  834. ipack = 3;
  835. } else if (lsame_(pack, "R")) {
  836. ipack = 4;
  837. } else if (lsame_(pack, "B")) {
  838. ipack = 5;
  839. } else if (lsame_(pack, "Q")) {
  840. ipack = 6;
  841. } else if (lsame_(pack, "Z")) {
  842. ipack = 7;
  843. } else {
  844. ipack = -1;
  845. }
  846. /* Set certain internal parameters */
  847. mnmin = f2cmin(*m,*n);
  848. /* Computing MIN */
  849. i__1 = *kl, i__2 = *m - 1;
  850. kll = f2cmin(i__1,i__2);
  851. /* Computing MIN */
  852. i__1 = *ku, i__2 = *n - 1;
  853. kuu = f2cmin(i__1,i__2);
  854. /* If inv(DL) is used, check to see if DL has a zero entry. */
  855. dzero = FALSE_;
  856. if (igrade == 4 && *model == 0) {
  857. i__1 = *m;
  858. for (i__ = 1; i__ <= i__1; ++i__) {
  859. if (dl[i__] == 0.) {
  860. dzero = TRUE_;
  861. }
  862. /* L10: */
  863. }
  864. }
  865. /* Check values in IPIVOT */
  866. badpvt = FALSE_;
  867. if (ipvtng > 0) {
  868. i__1 = npvts;
  869. for (j = 1; j <= i__1; ++j) {
  870. if (ipivot[j] <= 0 || ipivot[j] > npvts) {
  871. badpvt = TRUE_;
  872. }
  873. /* L20: */
  874. }
  875. }
  876. /* Set INFO if an error */
  877. if (*m < 0) {
  878. *info = -1;
  879. } else if (*m != *n && isym == 0) {
  880. *info = -1;
  881. } else if (*n < 0) {
  882. *info = -2;
  883. } else if (idist == -1) {
  884. *info = -3;
  885. } else if (isym == -1) {
  886. *info = -5;
  887. } else if (*mode < -6 || *mode > 6) {
  888. *info = -7;
  889. } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.) {
  890. *info = -8;
  891. } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
  892. *info = -10;
  893. } else if (igrade == -1 || igrade == 4 && *m != *n || igrade >= 1 &&
  894. igrade <= 4 && isym == 0) {
  895. *info = -11;
  896. } else if (igrade == 4 && dzero) {
  897. *info = -12;
  898. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  899. *model < -6 || *model > 6)) {
  900. *info = -13;
  901. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  902. *model != -6 && *model != 0 && *model != 6) && *condl < 1.) {
  903. *info = -14;
  904. } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
  905. *info = -16;
  906. } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
  907. *moder != 6) && *condr < 1.) {
  908. *info = -17;
  909. } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
  910. ipvtng == 2) && isym == 0) {
  911. *info = -18;
  912. } else if (ipvtng != 0 && badpvt) {
  913. *info = -19;
  914. } else if (*kl < 0) {
  915. *info = -20;
  916. } else if (*ku < 0 || isym == 0 && *kl != *ku) {
  917. *info = -21;
  918. } else if (*sparse < 0. || *sparse > 1.) {
  919. *info = -22;
  920. } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
  921. ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
  922. || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
  923. {
  924. *info = -24;
  925. } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
  926. (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
  927. 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
  928. *info = -26;
  929. }
  930. if (*info != 0) {
  931. i__1 = -(*info);
  932. xerbla_("DLATMR", &i__1, 6);
  933. return;
  934. }
  935. /* Decide if we can pivot consistently */
  936. fulbnd = FALSE_;
  937. if (kuu == *n - 1 && kll == *m - 1) {
  938. fulbnd = TRUE_;
  939. }
  940. /* Initialize random number generator */
  941. for (i__ = 1; i__ <= 4; ++i__) {
  942. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  943. /* L30: */
  944. }
  945. iseed[4] = (iseed[4] / 2 << 1) + 1;
  946. /* 2) Set up D, DL, and DR, if indicated. */
  947. /* Compute D according to COND and MODE */
  948. dlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
  949. if (*info != 0) {
  950. *info = 1;
  951. return;
  952. }
  953. if (*mode != 0 && *mode != -6 && *mode != 6) {
  954. /* Scale by DMAX */
  955. temp = abs(d__[1]);
  956. i__1 = mnmin;
  957. for (i__ = 2; i__ <= i__1; ++i__) {
  958. /* Computing MAX */
  959. d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
  960. temp = f2cmax(d__2,d__3);
  961. /* L40: */
  962. }
  963. if (temp == 0. && *dmax__ != 0.) {
  964. *info = 2;
  965. return;
  966. }
  967. if (temp != 0.) {
  968. alpha = *dmax__ / temp;
  969. } else {
  970. alpha = 1.;
  971. }
  972. i__1 = mnmin;
  973. for (i__ = 1; i__ <= i__1; ++i__) {
  974. d__[i__] = alpha * d__[i__];
  975. /* L50: */
  976. }
  977. }
  978. /* Compute DL if grading set */
  979. if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) {
  980. dlatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
  981. if (*info != 0) {
  982. *info = 3;
  983. return;
  984. }
  985. }
  986. /* Compute DR if grading set */
  987. if (igrade == 2 || igrade == 3) {
  988. dlatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
  989. if (*info != 0) {
  990. *info = 4;
  991. return;
  992. }
  993. }
  994. /* 3) Generate IWORK if pivoting */
  995. if (ipvtng > 0) {
  996. i__1 = npvts;
  997. for (i__ = 1; i__ <= i__1; ++i__) {
  998. iwork[i__] = i__;
  999. /* L60: */
  1000. }
  1001. if (fulbnd) {
  1002. i__1 = npvts;
  1003. for (i__ = 1; i__ <= i__1; ++i__) {
  1004. k = ipivot[i__];
  1005. j = iwork[i__];
  1006. iwork[i__] = iwork[k];
  1007. iwork[k] = j;
  1008. /* L70: */
  1009. }
  1010. } else {
  1011. for (i__ = npvts; i__ >= 1; --i__) {
  1012. k = ipivot[i__];
  1013. j = iwork[i__];
  1014. iwork[i__] = iwork[k];
  1015. iwork[k] = j;
  1016. /* L80: */
  1017. }
  1018. }
  1019. }
  1020. /* 4) Generate matrices for each kind of PACKing */
  1021. /* Always sweep matrix columnwise (if symmetric, upper */
  1022. /* half only) so that matrix generated does not depend */
  1023. /* on PACK */
  1024. if (fulbnd) {
  1025. /* Use DLATM3 so matrices generated with differing PIVOTing only */
  1026. /* differ only in the order of their rows and/or columns. */
  1027. if (ipack == 0) {
  1028. if (isym == 0) {
  1029. i__1 = *n;
  1030. for (j = 1; j <= i__1; ++j) {
  1031. i__2 = j;
  1032. for (i__ = 1; i__ <= i__2; ++i__) {
  1033. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1034. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1035. dr[1], &ipvtng, &iwork[1], sparse);
  1036. a[isub + jsub * a_dim1] = temp;
  1037. a[jsub + isub * a_dim1] = temp;
  1038. /* L90: */
  1039. }
  1040. /* L100: */
  1041. }
  1042. } else if (isym == 1) {
  1043. i__1 = *n;
  1044. for (j = 1; j <= i__1; ++j) {
  1045. i__2 = *m;
  1046. for (i__ = 1; i__ <= i__2; ++i__) {
  1047. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1048. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1049. dr[1], &ipvtng, &iwork[1], sparse);
  1050. a[isub + jsub * a_dim1] = temp;
  1051. /* L110: */
  1052. }
  1053. /* L120: */
  1054. }
  1055. }
  1056. } else if (ipack == 1) {
  1057. i__1 = *n;
  1058. for (j = 1; j <= i__1; ++j) {
  1059. i__2 = j;
  1060. for (i__ = 1; i__ <= i__2; ++i__) {
  1061. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1062. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1063. , &ipvtng, &iwork[1], sparse);
  1064. mnsub = f2cmin(isub,jsub);
  1065. mxsub = f2cmax(isub,jsub);
  1066. a[mnsub + mxsub * a_dim1] = temp;
  1067. if (mnsub != mxsub) {
  1068. a[mxsub + mnsub * a_dim1] = 0.;
  1069. }
  1070. /* L130: */
  1071. }
  1072. /* L140: */
  1073. }
  1074. } else if (ipack == 2) {
  1075. i__1 = *n;
  1076. for (j = 1; j <= i__1; ++j) {
  1077. i__2 = j;
  1078. for (i__ = 1; i__ <= i__2; ++i__) {
  1079. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1080. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1081. , &ipvtng, &iwork[1], sparse);
  1082. mnsub = f2cmin(isub,jsub);
  1083. mxsub = f2cmax(isub,jsub);
  1084. a[mxsub + mnsub * a_dim1] = temp;
  1085. if (mnsub != mxsub) {
  1086. a[mnsub + mxsub * a_dim1] = 0.;
  1087. }
  1088. /* L150: */
  1089. }
  1090. /* L160: */
  1091. }
  1092. } else if (ipack == 3) {
  1093. i__1 = *n;
  1094. for (j = 1; j <= i__1; ++j) {
  1095. i__2 = j;
  1096. for (i__ = 1; i__ <= i__2; ++i__) {
  1097. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1098. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1099. , &ipvtng, &iwork[1], sparse);
  1100. /* Compute K = location of (ISUB,JSUB) entry in packed */
  1101. /* array */
  1102. mnsub = f2cmin(isub,jsub);
  1103. mxsub = f2cmax(isub,jsub);
  1104. k = mxsub * (mxsub - 1) / 2 + mnsub;
  1105. /* Convert K to (IISUB,JJSUB) location */
  1106. jjsub = (k - 1) / *lda + 1;
  1107. iisub = k - *lda * (jjsub - 1);
  1108. a[iisub + jjsub * a_dim1] = temp;
  1109. /* L170: */
  1110. }
  1111. /* L180: */
  1112. }
  1113. } else if (ipack == 4) {
  1114. i__1 = *n;
  1115. for (j = 1; j <= i__1; ++j) {
  1116. i__2 = j;
  1117. for (i__ = 1; i__ <= i__2; ++i__) {
  1118. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1119. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1120. , &ipvtng, &iwork[1], sparse);
  1121. /* Compute K = location of (I,J) entry in packed array */
  1122. mnsub = f2cmin(isub,jsub);
  1123. mxsub = f2cmax(isub,jsub);
  1124. if (mnsub == 1) {
  1125. k = mxsub;
  1126. } else {
  1127. k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
  1128. mnsub + 2) / 2 + mxsub - mnsub + 1;
  1129. }
  1130. /* Convert K to (IISUB,JJSUB) location */
  1131. jjsub = (k - 1) / *lda + 1;
  1132. iisub = k - *lda * (jjsub - 1);
  1133. a[iisub + jjsub * a_dim1] = temp;
  1134. /* L190: */
  1135. }
  1136. /* L200: */
  1137. }
  1138. } else if (ipack == 5) {
  1139. i__1 = *n;
  1140. for (j = 1; j <= i__1; ++j) {
  1141. i__2 = j;
  1142. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1143. if (i__ < 1) {
  1144. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
  1145. } else {
  1146. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1147. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1148. dr[1], &ipvtng, &iwork[1], sparse);
  1149. mnsub = f2cmin(isub,jsub);
  1150. mxsub = f2cmax(isub,jsub);
  1151. a[mxsub - mnsub + 1 + mnsub * a_dim1] = temp;
  1152. }
  1153. /* L210: */
  1154. }
  1155. /* L220: */
  1156. }
  1157. } else if (ipack == 6) {
  1158. i__1 = *n;
  1159. for (j = 1; j <= i__1; ++j) {
  1160. i__2 = j;
  1161. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1162. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1163. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1164. , &ipvtng, &iwork[1], sparse);
  1165. mnsub = f2cmin(isub,jsub);
  1166. mxsub = f2cmax(isub,jsub);
  1167. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1168. /* L230: */
  1169. }
  1170. /* L240: */
  1171. }
  1172. } else if (ipack == 7) {
  1173. if (isym == 0) {
  1174. i__1 = *n;
  1175. for (j = 1; j <= i__1; ++j) {
  1176. i__2 = j;
  1177. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1178. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1179. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1180. dr[1], &ipvtng, &iwork[1], sparse);
  1181. mnsub = f2cmin(isub,jsub);
  1182. mxsub = f2cmax(isub,jsub);
  1183. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1184. if (i__ < 1) {
  1185. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
  1186. }
  1187. if (i__ >= 1 && mnsub != mxsub) {
  1188. a[mxsub - mnsub + 1 + kuu + mnsub * a_dim1] =
  1189. temp;
  1190. }
  1191. /* L250: */
  1192. }
  1193. /* L260: */
  1194. }
  1195. } else if (isym == 1) {
  1196. i__1 = *n;
  1197. for (j = 1; j <= i__1; ++j) {
  1198. i__2 = j + kll;
  1199. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1200. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1201. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1202. dr[1], &ipvtng, &iwork[1], sparse);
  1203. a[isub - jsub + kuu + 1 + jsub * a_dim1] = temp;
  1204. /* L270: */
  1205. }
  1206. /* L280: */
  1207. }
  1208. }
  1209. }
  1210. } else {
  1211. /* Use DLATM2 */
  1212. if (ipack == 0) {
  1213. if (isym == 0) {
  1214. i__1 = *n;
  1215. for (j = 1; j <= i__1; ++j) {
  1216. i__2 = j;
  1217. for (i__ = 1; i__ <= i__2; ++i__) {
  1218. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1219. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1220. dr[1], &ipvtng, &iwork[1], sparse);
  1221. a[j + i__ * a_dim1] = a[i__ + j * a_dim1];
  1222. /* L290: */
  1223. }
  1224. /* L300: */
  1225. }
  1226. } else if (isym == 1) {
  1227. i__1 = *n;
  1228. for (j = 1; j <= i__1; ++j) {
  1229. i__2 = *m;
  1230. for (i__ = 1; i__ <= i__2; ++i__) {
  1231. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1232. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1233. dr[1], &ipvtng, &iwork[1], sparse);
  1234. /* L310: */
  1235. }
  1236. /* L320: */
  1237. }
  1238. }
  1239. } else if (ipack == 1) {
  1240. i__1 = *n;
  1241. for (j = 1; j <= i__1; ++j) {
  1242. i__2 = j;
  1243. for (i__ = 1; i__ <= i__2; ++i__) {
  1244. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
  1245. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1246. , &ipvtng, &iwork[1], sparse);
  1247. if (i__ != j) {
  1248. a[j + i__ * a_dim1] = 0.;
  1249. }
  1250. /* L330: */
  1251. }
  1252. /* L340: */
  1253. }
  1254. } else if (ipack == 2) {
  1255. i__1 = *n;
  1256. for (j = 1; j <= i__1; ++j) {
  1257. i__2 = j;
  1258. for (i__ = 1; i__ <= i__2; ++i__) {
  1259. a[j + i__ * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
  1260. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1261. , &ipvtng, &iwork[1], sparse);
  1262. if (i__ != j) {
  1263. a[i__ + j * a_dim1] = 0.;
  1264. }
  1265. /* L350: */
  1266. }
  1267. /* L360: */
  1268. }
  1269. } else if (ipack == 3) {
  1270. isub = 0;
  1271. jsub = 1;
  1272. i__1 = *n;
  1273. for (j = 1; j <= i__1; ++j) {
  1274. i__2 = j;
  1275. for (i__ = 1; i__ <= i__2; ++i__) {
  1276. ++isub;
  1277. if (isub > *lda) {
  1278. isub = 1;
  1279. ++jsub;
  1280. }
  1281. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1282. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[
  1283. 1], &ipvtng, &iwork[1], sparse);
  1284. /* L370: */
  1285. }
  1286. /* L380: */
  1287. }
  1288. } else if (ipack == 4) {
  1289. if (isym == 0) {
  1290. i__1 = *n;
  1291. for (j = 1; j <= i__1; ++j) {
  1292. i__2 = j;
  1293. for (i__ = 1; i__ <= i__2; ++i__) {
  1294. /* Compute K = location of (I,J) entry in packed array */
  1295. if (i__ == 1) {
  1296. k = j;
  1297. } else {
  1298. k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
  1299. i__ + 2) / 2 + j - i__ + 1;
  1300. }
  1301. /* Convert K to (ISUB,JSUB) location */
  1302. jsub = (k - 1) / *lda + 1;
  1303. isub = k - *lda * (jsub - 1);
  1304. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
  1305. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1306. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1307. /* L390: */
  1308. }
  1309. /* L400: */
  1310. }
  1311. } else {
  1312. isub = 0;
  1313. jsub = 1;
  1314. i__1 = *n;
  1315. for (j = 1; j <= i__1; ++j) {
  1316. i__2 = *m;
  1317. for (i__ = j; i__ <= i__2; ++i__) {
  1318. ++isub;
  1319. if (isub > *lda) {
  1320. isub = 1;
  1321. ++jsub;
  1322. }
  1323. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
  1324. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1325. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1326. /* L410: */
  1327. }
  1328. /* L420: */
  1329. }
  1330. }
  1331. } else if (ipack == 5) {
  1332. i__1 = *n;
  1333. for (j = 1; j <= i__1; ++j) {
  1334. i__2 = j;
  1335. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1336. if (i__ < 1) {
  1337. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
  1338. } else {
  1339. a[j - i__ + 1 + i__ * a_dim1] = dlatm2_(m, n, &i__, &
  1340. j, kl, ku, &idist, &iseed[1], &d__[1], &
  1341. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1342. sparse);
  1343. }
  1344. /* L430: */
  1345. }
  1346. /* L440: */
  1347. }
  1348. } else if (ipack == 6) {
  1349. i__1 = *n;
  1350. for (j = 1; j <= i__1; ++j) {
  1351. i__2 = j;
  1352. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1353. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &i__, &
  1354. j, kl, ku, &idist, &iseed[1], &d__[1], &igrade, &
  1355. dl[1], &dr[1], &ipvtng, &iwork[1], sparse);
  1356. /* L450: */
  1357. }
  1358. /* L460: */
  1359. }
  1360. } else if (ipack == 7) {
  1361. if (isym == 0) {
  1362. i__1 = *n;
  1363. for (j = 1; j <= i__1; ++j) {
  1364. i__2 = j;
  1365. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1366. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
  1367. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1368. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1369. sparse);
  1370. if (i__ < 1) {
  1371. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
  1372. }
  1373. if (i__ >= 1 && i__ != j) {
  1374. a[j - i__ + 1 + kuu + i__ * a_dim1] = a[i__ - j +
  1375. kuu + 1 + j * a_dim1];
  1376. }
  1377. /* L470: */
  1378. }
  1379. /* L480: */
  1380. }
  1381. } else if (isym == 1) {
  1382. i__1 = *n;
  1383. for (j = 1; j <= i__1; ++j) {
  1384. i__2 = j + kll;
  1385. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1386. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
  1387. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1388. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1389. sparse);
  1390. /* L490: */
  1391. }
  1392. /* L500: */
  1393. }
  1394. }
  1395. }
  1396. }
  1397. /* 5) Scaling the norm */
  1398. if (ipack == 0) {
  1399. onorm = dlange_("M", m, n, &a[a_offset], lda, tempa);
  1400. } else if (ipack == 1) {
  1401. onorm = dlansy_("M", "U", n, &a[a_offset], lda, tempa);
  1402. } else if (ipack == 2) {
  1403. onorm = dlansy_("M", "L", n, &a[a_offset], lda, tempa);
  1404. } else if (ipack == 3) {
  1405. onorm = dlansp_("M", "U", n, &a[a_offset], tempa);
  1406. } else if (ipack == 4) {
  1407. onorm = dlansp_("M", "L", n, &a[a_offset], tempa);
  1408. } else if (ipack == 5) {
  1409. onorm = dlansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
  1410. } else if (ipack == 6) {
  1411. onorm = dlansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
  1412. } else if (ipack == 7) {
  1413. onorm = dlangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
  1414. }
  1415. if (*anorm >= 0.) {
  1416. if (*anorm > 0. && onorm == 0.) {
  1417. /* Desired scaling impossible */
  1418. *info = 5;
  1419. return;
  1420. } else if (*anorm > 1. && onorm < 1. || *anorm < 1. && onorm > 1.) {
  1421. /* Scale carefully to avoid over / underflow */
  1422. if (ipack <= 2) {
  1423. i__1 = *n;
  1424. for (j = 1; j <= i__1; ++j) {
  1425. d__1 = 1. / onorm;
  1426. dscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
  1427. dscal_(m, anorm, &a[j * a_dim1 + 1], &c__1);
  1428. /* L510: */
  1429. }
  1430. } else if (ipack == 3 || ipack == 4) {
  1431. i__1 = *n * (*n + 1) / 2;
  1432. d__1 = 1. / onorm;
  1433. dscal_(&i__1, &d__1, &a[a_offset], &c__1);
  1434. i__1 = *n * (*n + 1) / 2;
  1435. dscal_(&i__1, anorm, &a[a_offset], &c__1);
  1436. } else if (ipack >= 5) {
  1437. i__1 = *n;
  1438. for (j = 1; j <= i__1; ++j) {
  1439. i__2 = kll + kuu + 1;
  1440. d__1 = 1. / onorm;
  1441. dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1442. i__2 = kll + kuu + 1;
  1443. dscal_(&i__2, anorm, &a[j * a_dim1 + 1], &c__1);
  1444. /* L520: */
  1445. }
  1446. }
  1447. } else {
  1448. /* Scale straightforwardly */
  1449. if (ipack <= 2) {
  1450. i__1 = *n;
  1451. for (j = 1; j <= i__1; ++j) {
  1452. d__1 = *anorm / onorm;
  1453. dscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
  1454. /* L530: */
  1455. }
  1456. } else if (ipack == 3 || ipack == 4) {
  1457. i__1 = *n * (*n + 1) / 2;
  1458. d__1 = *anorm / onorm;
  1459. dscal_(&i__1, &d__1, &a[a_offset], &c__1);
  1460. } else if (ipack >= 5) {
  1461. i__1 = *n;
  1462. for (j = 1; j <= i__1; ++j) {
  1463. i__2 = kll + kuu + 1;
  1464. d__1 = *anorm / onorm;
  1465. dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1466. /* L540: */
  1467. }
  1468. }
  1469. }
  1470. }
  1471. /* End of DLATMR */
  1472. return;
  1473. } /* dlatmr_ */