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 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 DLATMR */
  244. /* =========== DOCUMENTATION =========== */
  245. /* Online html documentation available at */
  246. /* http://www.netlib.org/lapack/explore-html/ */
  247. /* Definition: */
  248. /* =========== */
  249. /* SUBROUTINE DLATMR( 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. /* DOUBLE PRECISION ANORM, COND, CONDL, CONDR, DMAX, SPARSE */
  256. /* INTEGER IPIVOT( * ), ISEED( 4 ), IWORK( * ) */
  257. /* DOUBLE PRECISION A( LDA, * ), D( * ), DL( * ), DR( * ) */
  258. /* > \par Purpose: */
  259. /* ============= */
  260. /* > */
  261. /* > \verbatim */
  262. /* > */
  263. /* > DLATMR generates random matrices of various types for testing */
  264. /* > LAPACK programs. */
  265. /* > */
  266. /* > DLATMR 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 DLATMR differ only in the PACK parameter, */
  307. /* > they will generate mathematically equivalent matrices. */
  308. /* > */
  309. /* > If two calls to DLATMR 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 DLATMR */
  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,out] D */
  364. /* > \verbatim */
  365. /* > D is DOUBLE PRECISION 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 DOUBLE PRECISION */
  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 DOUBLE PRECISION */
  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 DOUBLE PRECISION 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 DOUBLE PRECISION */
  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 DOUBLE PRECISION 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 DOUBLE PRECISION */
  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 DLATMR 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, DLATMR */
  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 DOUBLE PRECISION */
  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 DOUBLE PRECISION */
  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 DLATMR differ only in the PACK parameter, */
  607. /* > they will generate mathematically equivalent matrices. */
  608. /* > Not modified. */
  609. /* > \endverbatim */
  610. /* > */
  611. /* > \param[out] A */
  612. /* > \verbatim */
  613. /* > A is DOUBLE PRECISION 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 DLATM1 (computing D) */
  678. /* > 2 => Cannot scale diagonal to DMAX (f2cmax. entry is 0) */
  679. /* > 3 => Error return from DLATM1 (computing DL) */
  680. /* > 4 => Error return from DLATM1 (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 double_matgen */
  692. /* ===================================================================== */
  693. /* Subroutine */ void dlatmr_(integer *m, integer *n, char *dist, integer *
  694. iseed, char *sym, doublereal *d__, integer *mode, doublereal *cond,
  695. doublereal *dmax__, char *rsign, char *grade, doublereal *dl, integer
  696. *model, doublereal *condl, doublereal *dr, integer *moder, doublereal
  697. *condr, char *pivtng, integer *ipivot, integer *kl, integer *ku,
  698. doublereal *sparse, doublereal *anorm, char *pack, doublereal *a,
  699. integer *lda, integer *iwork, integer *info)
  700. {
  701. /* System generated locals */
  702. integer a_dim1, a_offset, i__1, i__2;
  703. doublereal d__1, d__2, d__3;
  704. /* Local variables */
  705. integer isub, jsub;
  706. doublereal temp;
  707. integer isym, i__, j, k;
  708. doublereal alpha;
  709. extern /* Subroutine */ void dscal_(integer *, doublereal *, doublereal *,
  710. integer *);
  711. integer ipack;
  712. extern logical lsame_(char *, char *);
  713. doublereal tempa[1];
  714. integer iisub, idist, jjsub, mnmin;
  715. logical dzero;
  716. integer mnsub;
  717. doublereal onorm;
  718. integer mxsub, npvts;
  719. extern /* Subroutine */ void dlatm1_(integer *, doublereal *, integer *,
  720. integer *, integer *, doublereal *, integer *, integer *);
  721. extern doublereal dlatm2_(integer *, integer *, integer *, integer *,
  722. integer *, integer *, integer *, integer *, doublereal *, integer
  723. *, doublereal *, doublereal *, integer *, integer *, doublereal *)
  724. , dlatm3_(integer *, integer *, integer *, integer *, integer *,
  725. integer *, integer *, integer *, integer *, integer *, doublereal
  726. *, integer *, doublereal *, doublereal *, integer *, integer *,
  727. doublereal *), dlangb_(char *, integer *, integer *, integer *,
  728. doublereal *, integer *, doublereal *), dlange_(char *,
  729. integer *, integer *, doublereal *, integer *, doublereal *);
  730. integer igrade;
  731. extern doublereal dlansb_(char *, char *, integer *, integer *,
  732. doublereal *, integer *, doublereal *);
  733. logical fulbnd;
  734. extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen);
  735. logical badpvt;
  736. extern doublereal dlansp_(char *, char *, integer *, doublereal *,
  737. doublereal *), dlansy_(char *, char *, integer *,
  738. doublereal *, integer *, doublereal *);
  739. integer irsign, ipvtng, kll, kuu;
  740. /* -- LAPACK computational routine (version 3.7.0) -- */
  741. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  742. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  743. /* December 2016 */
  744. /* ===================================================================== */
  745. /* 1) Decode and Test the input parameters. */
  746. /* Initialize flags & seed. */
  747. /* Parameter adjustments */
  748. --iseed;
  749. --d__;
  750. --dl;
  751. --dr;
  752. --ipivot;
  753. a_dim1 = *lda;
  754. a_offset = 1 + a_dim1 * 1;
  755. a -= a_offset;
  756. --iwork;
  757. /* Function Body */
  758. *info = 0;
  759. /* Quick return if possible */
  760. if (*m == 0 || *n == 0) {
  761. return;
  762. }
  763. /* Decode DIST */
  764. if (lsame_(dist, "U")) {
  765. idist = 1;
  766. } else if (lsame_(dist, "S")) {
  767. idist = 2;
  768. } else if (lsame_(dist, "N")) {
  769. idist = 3;
  770. } else {
  771. idist = -1;
  772. }
  773. /* Decode SYM */
  774. if (lsame_(sym, "S")) {
  775. isym = 0;
  776. } else if (lsame_(sym, "N")) {
  777. isym = 1;
  778. } else if (lsame_(sym, "H")) {
  779. isym = 0;
  780. } else {
  781. isym = -1;
  782. }
  783. /* Decode RSIGN */
  784. if (lsame_(rsign, "F")) {
  785. irsign = 0;
  786. } else if (lsame_(rsign, "T")) {
  787. irsign = 1;
  788. } else {
  789. irsign = -1;
  790. }
  791. /* Decode PIVTNG */
  792. if (lsame_(pivtng, "N")) {
  793. ipvtng = 0;
  794. } else if (lsame_(pivtng, " ")) {
  795. ipvtng = 0;
  796. } else if (lsame_(pivtng, "L")) {
  797. ipvtng = 1;
  798. npvts = *m;
  799. } else if (lsame_(pivtng, "R")) {
  800. ipvtng = 2;
  801. npvts = *n;
  802. } else if (lsame_(pivtng, "B")) {
  803. ipvtng = 3;
  804. npvts = f2cmin(*n,*m);
  805. } else if (lsame_(pivtng, "F")) {
  806. ipvtng = 3;
  807. npvts = f2cmin(*n,*m);
  808. } else {
  809. ipvtng = -1;
  810. }
  811. /* Decode GRADE */
  812. if (lsame_(grade, "N")) {
  813. igrade = 0;
  814. } else if (lsame_(grade, "L")) {
  815. igrade = 1;
  816. } else if (lsame_(grade, "R")) {
  817. igrade = 2;
  818. } else if (lsame_(grade, "B")) {
  819. igrade = 3;
  820. } else if (lsame_(grade, "E")) {
  821. igrade = 4;
  822. } else if (lsame_(grade, "H") || lsame_(grade,
  823. "S")) {
  824. igrade = 5;
  825. } else {
  826. igrade = -1;
  827. }
  828. /* Decode PACK */
  829. if (lsame_(pack, "N")) {
  830. ipack = 0;
  831. } else if (lsame_(pack, "U")) {
  832. ipack = 1;
  833. } else if (lsame_(pack, "L")) {
  834. ipack = 2;
  835. } else if (lsame_(pack, "C")) {
  836. ipack = 3;
  837. } else if (lsame_(pack, "R")) {
  838. ipack = 4;
  839. } else if (lsame_(pack, "B")) {
  840. ipack = 5;
  841. } else if (lsame_(pack, "Q")) {
  842. ipack = 6;
  843. } else if (lsame_(pack, "Z")) {
  844. ipack = 7;
  845. } else {
  846. ipack = -1;
  847. }
  848. /* Set certain internal parameters */
  849. mnmin = f2cmin(*m,*n);
  850. /* Computing MIN */
  851. i__1 = *kl, i__2 = *m - 1;
  852. kll = f2cmin(i__1,i__2);
  853. /* Computing MIN */
  854. i__1 = *ku, i__2 = *n - 1;
  855. kuu = f2cmin(i__1,i__2);
  856. /* If inv(DL) is used, check to see if DL has a zero entry. */
  857. dzero = FALSE_;
  858. if (igrade == 4 && *model == 0) {
  859. i__1 = *m;
  860. for (i__ = 1; i__ <= i__1; ++i__) {
  861. if (dl[i__] == 0.) {
  862. dzero = TRUE_;
  863. }
  864. /* L10: */
  865. }
  866. }
  867. /* Check values in IPIVOT */
  868. badpvt = FALSE_;
  869. if (ipvtng > 0) {
  870. i__1 = npvts;
  871. for (j = 1; j <= i__1; ++j) {
  872. if (ipivot[j] <= 0 || ipivot[j] > npvts) {
  873. badpvt = TRUE_;
  874. }
  875. /* L20: */
  876. }
  877. }
  878. /* Set INFO if an error */
  879. if (*m < 0) {
  880. *info = -1;
  881. } else if (*m != *n && isym == 0) {
  882. *info = -1;
  883. } else if (*n < 0) {
  884. *info = -2;
  885. } else if (idist == -1) {
  886. *info = -3;
  887. } else if (isym == -1) {
  888. *info = -5;
  889. } else if (*mode < -6 || *mode > 6) {
  890. *info = -7;
  891. } else if (*mode != -6 && *mode != 0 && *mode != 6 && *cond < 1.) {
  892. *info = -8;
  893. } else if (*mode != -6 && *mode != 0 && *mode != 6 && irsign == -1) {
  894. *info = -10;
  895. } else if (igrade == -1 || igrade == 4 && *m != *n || igrade >= 1 &&
  896. igrade <= 4 && isym == 0) {
  897. *info = -11;
  898. } else if (igrade == 4 && dzero) {
  899. *info = -12;
  900. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  901. *model < -6 || *model > 6)) {
  902. *info = -13;
  903. } else if ((igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) && (
  904. *model != -6 && *model != 0 && *model != 6) && *condl < 1.) {
  905. *info = -14;
  906. } else if ((igrade == 2 || igrade == 3) && (*moder < -6 || *moder > 6)) {
  907. *info = -16;
  908. } else if ((igrade == 2 || igrade == 3) && (*moder != -6 && *moder != 0 &&
  909. *moder != 6) && *condr < 1.) {
  910. *info = -17;
  911. } else if (ipvtng == -1 || ipvtng == 3 && *m != *n || (ipvtng == 1 ||
  912. ipvtng == 2) && isym == 0) {
  913. *info = -18;
  914. } else if (ipvtng != 0 && badpvt) {
  915. *info = -19;
  916. } else if (*kl < 0) {
  917. *info = -20;
  918. } else if (*ku < 0 || isym == 0 && *kl != *ku) {
  919. *info = -21;
  920. } else if (*sparse < 0. || *sparse > 1.) {
  921. *info = -22;
  922. } else if (ipack == -1 || (ipack == 1 || ipack == 2 || ipack == 5 ||
  923. ipack == 6) && isym == 1 || ipack == 3 && isym == 1 && (*kl != 0
  924. || *m != *n) || ipack == 4 && isym == 1 && (*ku != 0 || *m != *n))
  925. {
  926. *info = -24;
  927. } else if ((ipack == 0 || ipack == 1 || ipack == 2) && *lda < f2cmax(1,*m) ||
  928. (ipack == 3 || ipack == 4) && *lda < 1 || (ipack == 5 || ipack ==
  929. 6) && *lda < kuu + 1 || ipack == 7 && *lda < kll + kuu + 1) {
  930. *info = -26;
  931. }
  932. if (*info != 0) {
  933. i__1 = -(*info);
  934. xerbla_("DLATMR", &i__1, 6);
  935. return;
  936. }
  937. /* Decide if we can pivot consistently */
  938. fulbnd = FALSE_;
  939. if (kuu == *n - 1 && kll == *m - 1) {
  940. fulbnd = TRUE_;
  941. }
  942. /* Initialize random number generator */
  943. for (i__ = 1; i__ <= 4; ++i__) {
  944. iseed[i__] = (i__1 = iseed[i__], abs(i__1)) % 4096;
  945. /* L30: */
  946. }
  947. iseed[4] = (iseed[4] / 2 << 1) + 1;
  948. /* 2) Set up D, DL, and DR, if indicated. */
  949. /* Compute D according to COND and MODE */
  950. dlatm1_(mode, cond, &irsign, &idist, &iseed[1], &d__[1], &mnmin, info);
  951. if (*info != 0) {
  952. *info = 1;
  953. return;
  954. }
  955. if (*mode != 0 && *mode != -6 && *mode != 6) {
  956. /* Scale by DMAX */
  957. temp = abs(d__[1]);
  958. i__1 = mnmin;
  959. for (i__ = 2; i__ <= i__1; ++i__) {
  960. /* Computing MAX */
  961. d__2 = temp, d__3 = (d__1 = d__[i__], abs(d__1));
  962. temp = f2cmax(d__2,d__3);
  963. /* L40: */
  964. }
  965. if (temp == 0. && *dmax__ != 0.) {
  966. *info = 2;
  967. return;
  968. }
  969. if (temp != 0.) {
  970. alpha = *dmax__ / temp;
  971. } else {
  972. alpha = 1.;
  973. }
  974. i__1 = mnmin;
  975. for (i__ = 1; i__ <= i__1; ++i__) {
  976. d__[i__] = alpha * d__[i__];
  977. /* L50: */
  978. }
  979. }
  980. /* Compute DL if grading set */
  981. if (igrade == 1 || igrade == 3 || igrade == 4 || igrade == 5) {
  982. dlatm1_(model, condl, &c__0, &idist, &iseed[1], &dl[1], m, info);
  983. if (*info != 0) {
  984. *info = 3;
  985. return;
  986. }
  987. }
  988. /* Compute DR if grading set */
  989. if (igrade == 2 || igrade == 3) {
  990. dlatm1_(moder, condr, &c__0, &idist, &iseed[1], &dr[1], n, info);
  991. if (*info != 0) {
  992. *info = 4;
  993. return;
  994. }
  995. }
  996. /* 3) Generate IWORK if pivoting */
  997. if (ipvtng > 0) {
  998. i__1 = npvts;
  999. for (i__ = 1; i__ <= i__1; ++i__) {
  1000. iwork[i__] = i__;
  1001. /* L60: */
  1002. }
  1003. if (fulbnd) {
  1004. i__1 = npvts;
  1005. for (i__ = 1; i__ <= i__1; ++i__) {
  1006. k = ipivot[i__];
  1007. j = iwork[i__];
  1008. iwork[i__] = iwork[k];
  1009. iwork[k] = j;
  1010. /* L70: */
  1011. }
  1012. } else {
  1013. for (i__ = npvts; i__ >= 1; --i__) {
  1014. k = ipivot[i__];
  1015. j = iwork[i__];
  1016. iwork[i__] = iwork[k];
  1017. iwork[k] = j;
  1018. /* L80: */
  1019. }
  1020. }
  1021. }
  1022. /* 4) Generate matrices for each kind of PACKing */
  1023. /* Always sweep matrix columnwise (if symmetric, upper */
  1024. /* half only) so that matrix generated does not depend */
  1025. /* on PACK */
  1026. if (fulbnd) {
  1027. /* Use DLATM3 so matrices generated with differing PIVOTing only */
  1028. /* differ only in the order of their rows and/or columns. */
  1029. if (ipack == 0) {
  1030. if (isym == 0) {
  1031. i__1 = *n;
  1032. for (j = 1; j <= i__1; ++j) {
  1033. i__2 = j;
  1034. for (i__ = 1; i__ <= i__2; ++i__) {
  1035. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1036. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1037. dr[1], &ipvtng, &iwork[1], sparse);
  1038. a[isub + jsub * a_dim1] = temp;
  1039. a[jsub + isub * a_dim1] = temp;
  1040. /* L90: */
  1041. }
  1042. /* L100: */
  1043. }
  1044. } else if (isym == 1) {
  1045. i__1 = *n;
  1046. for (j = 1; j <= i__1; ++j) {
  1047. i__2 = *m;
  1048. for (i__ = 1; i__ <= i__2; ++i__) {
  1049. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1050. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1051. dr[1], &ipvtng, &iwork[1], sparse);
  1052. a[isub + jsub * a_dim1] = temp;
  1053. /* L110: */
  1054. }
  1055. /* L120: */
  1056. }
  1057. }
  1058. } else if (ipack == 1) {
  1059. i__1 = *n;
  1060. for (j = 1; j <= i__1; ++j) {
  1061. i__2 = j;
  1062. for (i__ = 1; i__ <= i__2; ++i__) {
  1063. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1064. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1065. , &ipvtng, &iwork[1], sparse);
  1066. mnsub = f2cmin(isub,jsub);
  1067. mxsub = f2cmax(isub,jsub);
  1068. a[mnsub + mxsub * a_dim1] = temp;
  1069. if (mnsub != mxsub) {
  1070. a[mxsub + mnsub * a_dim1] = 0.;
  1071. }
  1072. /* L130: */
  1073. }
  1074. /* L140: */
  1075. }
  1076. } else if (ipack == 2) {
  1077. i__1 = *n;
  1078. for (j = 1; j <= i__1; ++j) {
  1079. i__2 = j;
  1080. for (i__ = 1; i__ <= i__2; ++i__) {
  1081. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1082. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1083. , &ipvtng, &iwork[1], sparse);
  1084. mnsub = f2cmin(isub,jsub);
  1085. mxsub = f2cmax(isub,jsub);
  1086. a[mxsub + mnsub * a_dim1] = temp;
  1087. if (mnsub != mxsub) {
  1088. a[mnsub + mxsub * a_dim1] = 0.;
  1089. }
  1090. /* L150: */
  1091. }
  1092. /* L160: */
  1093. }
  1094. } else if (ipack == 3) {
  1095. i__1 = *n;
  1096. for (j = 1; j <= i__1; ++j) {
  1097. i__2 = j;
  1098. for (i__ = 1; i__ <= i__2; ++i__) {
  1099. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1100. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1101. , &ipvtng, &iwork[1], sparse);
  1102. /* Compute K = location of (ISUB,JSUB) entry in packed */
  1103. /* array */
  1104. mnsub = f2cmin(isub,jsub);
  1105. mxsub = f2cmax(isub,jsub);
  1106. k = mxsub * (mxsub - 1) / 2 + mnsub;
  1107. /* Convert K to (IISUB,JJSUB) location */
  1108. jjsub = (k - 1) / *lda + 1;
  1109. iisub = k - *lda * (jjsub - 1);
  1110. a[iisub + jjsub * a_dim1] = temp;
  1111. /* L170: */
  1112. }
  1113. /* L180: */
  1114. }
  1115. } else if (ipack == 4) {
  1116. i__1 = *n;
  1117. for (j = 1; j <= i__1; ++j) {
  1118. i__2 = j;
  1119. for (i__ = 1; i__ <= i__2; ++i__) {
  1120. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1121. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1122. , &ipvtng, &iwork[1], sparse);
  1123. /* Compute K = location of (I,J) entry in packed array */
  1124. mnsub = f2cmin(isub,jsub);
  1125. mxsub = f2cmax(isub,jsub);
  1126. if (mnsub == 1) {
  1127. k = mxsub;
  1128. } else {
  1129. k = *n * (*n + 1) / 2 - (*n - mnsub + 1) * (*n -
  1130. mnsub + 2) / 2 + mxsub - mnsub + 1;
  1131. }
  1132. /* Convert K to (IISUB,JJSUB) location */
  1133. jjsub = (k - 1) / *lda + 1;
  1134. iisub = k - *lda * (jjsub - 1);
  1135. a[iisub + jjsub * a_dim1] = temp;
  1136. /* L190: */
  1137. }
  1138. /* L200: */
  1139. }
  1140. } else if (ipack == 5) {
  1141. i__1 = *n;
  1142. for (j = 1; j <= i__1; ++j) {
  1143. i__2 = j;
  1144. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1145. if (i__ < 1) {
  1146. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
  1147. } else {
  1148. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1149. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1150. dr[1], &ipvtng, &iwork[1], sparse);
  1151. mnsub = f2cmin(isub,jsub);
  1152. mxsub = f2cmax(isub,jsub);
  1153. a[mxsub - mnsub + 1 + mnsub * a_dim1] = temp;
  1154. }
  1155. /* L210: */
  1156. }
  1157. /* L220: */
  1158. }
  1159. } else if (ipack == 6) {
  1160. i__1 = *n;
  1161. for (j = 1; j <= i__1; ++j) {
  1162. i__2 = j;
  1163. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1164. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1165. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1166. , &ipvtng, &iwork[1], sparse);
  1167. mnsub = f2cmin(isub,jsub);
  1168. mxsub = f2cmax(isub,jsub);
  1169. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1170. /* L230: */
  1171. }
  1172. /* L240: */
  1173. }
  1174. } else if (ipack == 7) {
  1175. if (isym == 0) {
  1176. i__1 = *n;
  1177. for (j = 1; j <= i__1; ++j) {
  1178. i__2 = j;
  1179. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1180. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1181. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1182. dr[1], &ipvtng, &iwork[1], sparse);
  1183. mnsub = f2cmin(isub,jsub);
  1184. mxsub = f2cmax(isub,jsub);
  1185. a[mnsub - mxsub + kuu + 1 + mxsub * a_dim1] = temp;
  1186. if (i__ < 1) {
  1187. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
  1188. }
  1189. if (i__ >= 1 && mnsub != mxsub) {
  1190. a[mxsub - mnsub + 1 + kuu + mnsub * a_dim1] =
  1191. temp;
  1192. }
  1193. /* L250: */
  1194. }
  1195. /* L260: */
  1196. }
  1197. } else if (isym == 1) {
  1198. i__1 = *n;
  1199. for (j = 1; j <= i__1; ++j) {
  1200. i__2 = j + kll;
  1201. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1202. temp = dlatm3_(m, n, &i__, &j, &isub, &jsub, kl, ku, &
  1203. idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1204. dr[1], &ipvtng, &iwork[1], sparse);
  1205. a[isub - jsub + kuu + 1 + jsub * a_dim1] = temp;
  1206. /* L270: */
  1207. }
  1208. /* L280: */
  1209. }
  1210. }
  1211. }
  1212. } else {
  1213. /* Use DLATM2 */
  1214. if (ipack == 0) {
  1215. if (isym == 0) {
  1216. i__1 = *n;
  1217. for (j = 1; j <= i__1; ++j) {
  1218. i__2 = j;
  1219. for (i__ = 1; i__ <= i__2; ++i__) {
  1220. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1221. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1222. dr[1], &ipvtng, &iwork[1], sparse);
  1223. a[j + i__ * a_dim1] = a[i__ + j * a_dim1];
  1224. /* L290: */
  1225. }
  1226. /* L300: */
  1227. }
  1228. } else if (isym == 1) {
  1229. i__1 = *n;
  1230. for (j = 1; j <= i__1; ++j) {
  1231. i__2 = *m;
  1232. for (i__ = 1; i__ <= i__2; ++i__) {
  1233. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1234. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &
  1235. dr[1], &ipvtng, &iwork[1], sparse);
  1236. /* L310: */
  1237. }
  1238. /* L320: */
  1239. }
  1240. }
  1241. } else if (ipack == 1) {
  1242. i__1 = *n;
  1243. for (j = 1; j <= i__1; ++j) {
  1244. i__2 = j;
  1245. for (i__ = 1; i__ <= i__2; ++i__) {
  1246. a[i__ + j * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
  1247. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1248. , &ipvtng, &iwork[1], sparse);
  1249. if (i__ != j) {
  1250. a[j + i__ * a_dim1] = 0.;
  1251. }
  1252. /* L330: */
  1253. }
  1254. /* L340: */
  1255. }
  1256. } else if (ipack == 2) {
  1257. i__1 = *n;
  1258. for (j = 1; j <= i__1; ++j) {
  1259. i__2 = j;
  1260. for (i__ = 1; i__ <= i__2; ++i__) {
  1261. a[j + i__ * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku, &
  1262. idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[1]
  1263. , &ipvtng, &iwork[1], sparse);
  1264. if (i__ != j) {
  1265. a[i__ + j * a_dim1] = 0.;
  1266. }
  1267. /* L350: */
  1268. }
  1269. /* L360: */
  1270. }
  1271. } else if (ipack == 3) {
  1272. isub = 0;
  1273. jsub = 1;
  1274. i__1 = *n;
  1275. for (j = 1; j <= i__1; ++j) {
  1276. i__2 = j;
  1277. for (i__ = 1; i__ <= i__2; ++i__) {
  1278. ++isub;
  1279. if (isub > *lda) {
  1280. isub = 1;
  1281. ++jsub;
  1282. }
  1283. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl, ku,
  1284. &idist, &iseed[1], &d__[1], &igrade, &dl[1], &dr[
  1285. 1], &ipvtng, &iwork[1], sparse);
  1286. /* L370: */
  1287. }
  1288. /* L380: */
  1289. }
  1290. } else if (ipack == 4) {
  1291. if (isym == 0) {
  1292. i__1 = *n;
  1293. for (j = 1; j <= i__1; ++j) {
  1294. i__2 = j;
  1295. for (i__ = 1; i__ <= i__2; ++i__) {
  1296. /* Compute K = location of (I,J) entry in packed array */
  1297. if (i__ == 1) {
  1298. k = j;
  1299. } else {
  1300. k = *n * (*n + 1) / 2 - (*n - i__ + 1) * (*n -
  1301. i__ + 2) / 2 + j - i__ + 1;
  1302. }
  1303. /* Convert K to (ISUB,JSUB) location */
  1304. jsub = (k - 1) / *lda + 1;
  1305. isub = k - *lda * (jsub - 1);
  1306. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
  1307. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1308. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1309. /* L390: */
  1310. }
  1311. /* L400: */
  1312. }
  1313. } else {
  1314. isub = 0;
  1315. jsub = 1;
  1316. i__1 = *n;
  1317. for (j = 1; j <= i__1; ++j) {
  1318. i__2 = *m;
  1319. for (i__ = j; i__ <= i__2; ++i__) {
  1320. ++isub;
  1321. if (isub > *lda) {
  1322. isub = 1;
  1323. ++jsub;
  1324. }
  1325. a[isub + jsub * a_dim1] = dlatm2_(m, n, &i__, &j, kl,
  1326. ku, &idist, &iseed[1], &d__[1], &igrade, &dl[
  1327. 1], &dr[1], &ipvtng, &iwork[1], sparse);
  1328. /* L410: */
  1329. }
  1330. /* L420: */
  1331. }
  1332. }
  1333. } else if (ipack == 5) {
  1334. i__1 = *n;
  1335. for (j = 1; j <= i__1; ++j) {
  1336. i__2 = j;
  1337. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1338. if (i__ < 1) {
  1339. a[j - i__ + 1 + (i__ + *n) * a_dim1] = 0.;
  1340. } else {
  1341. a[j - i__ + 1 + i__ * a_dim1] = dlatm2_(m, n, &i__, &
  1342. j, kl, ku, &idist, &iseed[1], &d__[1], &
  1343. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1344. sparse);
  1345. }
  1346. /* L430: */
  1347. }
  1348. /* L440: */
  1349. }
  1350. } else if (ipack == 6) {
  1351. i__1 = *n;
  1352. for (j = 1; j <= i__1; ++j) {
  1353. i__2 = j;
  1354. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1355. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &i__, &
  1356. j, kl, ku, &idist, &iseed[1], &d__[1], &igrade, &
  1357. dl[1], &dr[1], &ipvtng, &iwork[1], sparse);
  1358. /* L450: */
  1359. }
  1360. /* L460: */
  1361. }
  1362. } else if (ipack == 7) {
  1363. if (isym == 0) {
  1364. i__1 = *n;
  1365. for (j = 1; j <= i__1; ++j) {
  1366. i__2 = j;
  1367. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1368. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
  1369. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1370. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1371. sparse);
  1372. if (i__ < 1) {
  1373. a[j - i__ + 1 + kuu + (i__ + *n) * a_dim1] = 0.;
  1374. }
  1375. if (i__ >= 1 && i__ != j) {
  1376. a[j - i__ + 1 + kuu + i__ * a_dim1] = a[i__ - j +
  1377. kuu + 1 + j * a_dim1];
  1378. }
  1379. /* L470: */
  1380. }
  1381. /* L480: */
  1382. }
  1383. } else if (isym == 1) {
  1384. i__1 = *n;
  1385. for (j = 1; j <= i__1; ++j) {
  1386. i__2 = j + kll;
  1387. for (i__ = j - kuu; i__ <= i__2; ++i__) {
  1388. a[i__ - j + kuu + 1 + j * a_dim1] = dlatm2_(m, n, &
  1389. i__, &j, kl, ku, &idist, &iseed[1], &d__[1], &
  1390. igrade, &dl[1], &dr[1], &ipvtng, &iwork[1],
  1391. sparse);
  1392. /* L490: */
  1393. }
  1394. /* L500: */
  1395. }
  1396. }
  1397. }
  1398. }
  1399. /* 5) Scaling the norm */
  1400. if (ipack == 0) {
  1401. onorm = dlange_("M", m, n, &a[a_offset], lda, tempa);
  1402. } else if (ipack == 1) {
  1403. onorm = dlansy_("M", "U", n, &a[a_offset], lda, tempa);
  1404. } else if (ipack == 2) {
  1405. onorm = dlansy_("M", "L", n, &a[a_offset], lda, tempa);
  1406. } else if (ipack == 3) {
  1407. onorm = dlansp_("M", "U", n, &a[a_offset], tempa);
  1408. } else if (ipack == 4) {
  1409. onorm = dlansp_("M", "L", n, &a[a_offset], tempa);
  1410. } else if (ipack == 5) {
  1411. onorm = dlansb_("M", "L", n, &kll, &a[a_offset], lda, tempa);
  1412. } else if (ipack == 6) {
  1413. onorm = dlansb_("M", "U", n, &kuu, &a[a_offset], lda, tempa);
  1414. } else if (ipack == 7) {
  1415. onorm = dlangb_("M", n, &kll, &kuu, &a[a_offset], lda, tempa);
  1416. }
  1417. if (*anorm >= 0.) {
  1418. if (*anorm > 0. && onorm == 0.) {
  1419. /* Desired scaling impossible */
  1420. *info = 5;
  1421. return;
  1422. } else if (*anorm > 1. && onorm < 1. || *anorm < 1. && onorm > 1.) {
  1423. /* Scale carefully to avoid over / underflow */
  1424. if (ipack <= 2) {
  1425. i__1 = *n;
  1426. for (j = 1; j <= i__1; ++j) {
  1427. d__1 = 1. / onorm;
  1428. dscal_(m, &d__1, &a[j * a_dim1 + 1], &c__1);
  1429. dscal_(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. d__1 = 1. / onorm;
  1435. dscal_(&i__1, &d__1, &a[a_offset], &c__1);
  1436. i__1 = *n * (*n + 1) / 2;
  1437. dscal_(&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. d__1 = 1. / onorm;
  1443. dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1444. i__2 = kll + kuu + 1;
  1445. dscal_(&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. d__1 = *anorm / onorm;
  1455. dscal_(m, &d__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. d__1 = *anorm / onorm;
  1461. dscal_(&i__1, &d__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. d__1 = *anorm / onorm;
  1467. dscal_(&i__2, &d__1, &a[j * a_dim1 + 1], &c__1);
  1468. /* L540: */
  1469. }
  1470. }
  1471. }
  1472. }
  1473. /* End of DLATMR */
  1474. return;
  1475. } /* dlatmr_ */