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.

slamch.c 34 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  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. static float spow_ui(float x, integer n) {
  241. float pow=1.0; unsigned long int u;
  242. if(n != 0) {
  243. if(n < 0) n = -n, x = 1/x;
  244. for(u = n; ; ) {
  245. if(u & 01) pow *= x;
  246. if(u >>= 1) x *= x;
  247. else break;
  248. }
  249. }
  250. return pow;
  251. }
  252. /* -- translated by f2c (version 20000121).
  253. You must link the resulting object file with the libraries:
  254. -lf2c -lm (in that order)
  255. */
  256. /* Table of constant values */
  257. static integer c__1 = 1;
  258. static real c_b32 = 0.f;
  259. /* > \brief \b SLAMCHF77 deprecated */
  260. /* =========== DOCUMENTATION =========== */
  261. /* Online html documentation available at */
  262. /* http://www.netlib.org/lapack/explore-html/ */
  263. /* Definition: */
  264. /* =========== */
  265. /* REAL FUNCTION SLAMCH( CMACH ) */
  266. /* CHARACTER CMACH */
  267. /* > \par Purpose: */
  268. /* ============= */
  269. /* > */
  270. /* > \verbatim */
  271. /* > */
  272. /* > SLAMCH determines single precision machine parameters. */
  273. /* > \endverbatim */
  274. /* Arguments: */
  275. /* ========== */
  276. /* > \param[in] CMACH */
  277. /* > \verbatim */
  278. /* > Specifies the value to be returned by SLAMCH: */
  279. /* > = 'E' or 'e', SLAMCH := eps */
  280. /* > = 'S' or 's , SLAMCH := sfmin */
  281. /* > = 'B' or 'b', SLAMCH := base */
  282. /* > = 'P' or 'p', SLAMCH := eps*base */
  283. /* > = 'N' or 'n', SLAMCH := t */
  284. /* > = 'R' or 'r', SLAMCH := rnd */
  285. /* > = 'M' or 'm', SLAMCH := emin */
  286. /* > = 'U' or 'u', SLAMCH := rmin */
  287. /* > = 'L' or 'l', SLAMCH := emax */
  288. /* > = 'O' or 'o', SLAMCH := rmax */
  289. /* > where */
  290. /* > eps = relative machine precision */
  291. /* > sfmin = safe minimum, such that 1/sfmin does not overflow */
  292. /* > base = base of the machine */
  293. /* > prec = eps*base */
  294. /* > t = number of (base) digits in the mantissa */
  295. /* > rnd = 1.0 when rounding occurs in addition, 0.0 otherwise */
  296. /* > emin = minimum exponent before (gradual) underflow */
  297. /* > rmin = underflow threshold - base**(emin-1) */
  298. /* > emax = largest exponent before overflow */
  299. /* > rmax = overflow threshold - (base**emax)*(1-eps) */
  300. /* > \endverbatim */
  301. /* Authors: */
  302. /* ======== */
  303. /* > \author Univ. of Tennessee */
  304. /* > \author Univ. of California Berkeley */
  305. /* > \author Univ. of Colorado Denver */
  306. /* > \author NAG Ltd. */
  307. /* > \date April 2012 */
  308. /* > \ingroup auxOTHERauxiliary */
  309. /* ===================================================================== */
  310. real slamch_(char *cmach)
  311. {
  312. /* Initialized data */
  313. static logical first = TRUE_;
  314. /* System generated locals */
  315. integer i__1;
  316. real ret_val;
  317. /* Local variables */
  318. static real base;
  319. integer beta;
  320. static real emin, prec, emax;
  321. integer imin, imax;
  322. logical lrnd;
  323. static real rmin, rmax, t;
  324. real rmach;
  325. extern logical lsame_(char *, char *);
  326. real small;
  327. static real sfmin;
  328. extern /* Subroutine */ int slamc2_(integer *, integer *, logical *, real
  329. *, integer *, real *, integer *, real *);
  330. integer it;
  331. static real rnd, eps;
  332. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  333. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  334. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  335. /* April 2012 */
  336. if (first) {
  337. slamc2_(&beta, &it, &lrnd, &eps, &imin, &rmin, &imax, &rmax);
  338. base = (real) beta;
  339. t = (real) it;
  340. if (lrnd) {
  341. rnd = 1.f;
  342. i__1 = 1 - it;
  343. eps = pow_ri(&base, &i__1) / 2;
  344. } else {
  345. rnd = 0.f;
  346. i__1 = 1 - it;
  347. eps = pow_ri(&base, &i__1);
  348. }
  349. prec = eps * base;
  350. emin = (real) imin;
  351. emax = (real) imax;
  352. sfmin = rmin;
  353. small = 1.f / rmax;
  354. if (small >= sfmin) {
  355. /* Use SMALL plus a bit, to avoid the possibility of rounding */
  356. /* causing overflow when computing 1/sfmin. */
  357. sfmin = small * (eps + 1.f);
  358. }
  359. }
  360. if (lsame_(cmach, "E")) {
  361. rmach = eps;
  362. } else if (lsame_(cmach, "S")) {
  363. rmach = sfmin;
  364. } else if (lsame_(cmach, "B")) {
  365. rmach = base;
  366. } else if (lsame_(cmach, "P")) {
  367. rmach = prec;
  368. } else if (lsame_(cmach, "N")) {
  369. rmach = t;
  370. } else if (lsame_(cmach, "R")) {
  371. rmach = rnd;
  372. } else if (lsame_(cmach, "M")) {
  373. rmach = emin;
  374. } else if (lsame_(cmach, "U")) {
  375. rmach = rmin;
  376. } else if (lsame_(cmach, "L")) {
  377. rmach = emax;
  378. } else if (lsame_(cmach, "O")) {
  379. rmach = rmax;
  380. }
  381. ret_val = rmach;
  382. first = FALSE_;
  383. return ret_val;
  384. /* End of SLAMCH */
  385. } /* slamch_ */
  386. /* *********************************************************************** */
  387. /* > \brief \b SLAMC1 */
  388. /* > \details */
  389. /* > \b Purpose: */
  390. /* > \verbatim */
  391. /* > SLAMC1 determines the machine parameters given by BETA, T, RND, and */
  392. /* > IEEE1. */
  393. /* > \endverbatim */
  394. /* > */
  395. /* > \param[out] BETA */
  396. /* > \verbatim */
  397. /* > The base of the machine. */
  398. /* > \endverbatim */
  399. /* > */
  400. /* > \param[out] T */
  401. /* > \verbatim */
  402. /* > The number of ( BETA ) digits in the mantissa. */
  403. /* > \endverbatim */
  404. /* > */
  405. /* > \param[out] RND */
  406. /* > \verbatim */
  407. /* > Specifies whether proper rounding ( RND = .TRUE. ) or */
  408. /* > chopping ( RND = .FALSE. ) occurs in addition. This may not */
  409. /* > be a reliable guide to the way in which the machine performs */
  410. /* > its arithmetic. */
  411. /* > \endverbatim */
  412. /* > */
  413. /* > \param[out] IEEE1 */
  414. /* > \verbatim */
  415. /* > Specifies whether rounding appears to be done in the IEEE */
  416. /* > 'round to nearest' style. */
  417. /* > \endverbatim */
  418. /* > \author LAPACK is a software package provided by Univ. of Tennessee, Univ. of California Berkeley, Univ.
  419. of Colorado Denver and NAG Ltd.. */
  420. /* > \date April 2012 */
  421. /* > \ingroup auxOTHERauxiliary */
  422. /* > */
  423. /* > \details \b Further \b Details */
  424. /* > \verbatim */
  425. /* > */
  426. /* > The routine is based on the routine ENVRON by Malcolm and */
  427. /* > incorporates suggestions by Gentleman and Marovich. See */
  428. /* > */
  429. /* > Malcolm M. A. (1972) Algorithms to reveal properties of */
  430. /* > floating-point arithmetic. Comms. of the ACM, 15, 949-951. */
  431. /* > */
  432. /* > Gentleman W. M. and Marovich S. B. (1974) More on algorithms */
  433. /* > that reveal properties of floating point arithmetic units. */
  434. /* > Comms. of the ACM, 17, 276-277. */
  435. /* > \endverbatim */
  436. /* > */
  437. /* Subroutine */ int slamc1_(integer *beta, integer *t, logical *rnd, logical
  438. *ieee1)
  439. {
  440. /* Initialized data */
  441. static logical first = TRUE_;
  442. /* System generated locals */
  443. real r__1, r__2;
  444. /* Local variables */
  445. static logical lrnd;
  446. real a, b, c__, f;
  447. static integer lbeta;
  448. real savec;
  449. static logical lieee1;
  450. real t1, t2;
  451. extern real slamc3_(real *, real *);
  452. static integer lt;
  453. real one, qtr;
  454. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  455. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  456. /* November 2010 */
  457. /* ===================================================================== */
  458. if (first) {
  459. one = 1.f;
  460. /* LBETA, LIEEE1, LT and LRND are the local values of BETA, */
  461. /* IEEE1, T and RND. */
  462. /* Throughout this routine we use the function SLAMC3 to ensure */
  463. /* that relevant values are stored and not held in registers, or */
  464. /* are not affected by optimizers. */
  465. /* Compute a = 2.0**m with the smallest positive integer m such */
  466. /* that */
  467. /* fl( a + 1.0 ) = a. */
  468. a = 1.f;
  469. c__ = 1.f;
  470. /* + WHILE( C.EQ.ONE )LOOP */
  471. L10:
  472. if (c__ == one) {
  473. a *= 2;
  474. c__ = slamc3_(&a, &one);
  475. r__1 = -a;
  476. c__ = slamc3_(&c__, &r__1);
  477. goto L10;
  478. }
  479. /* + END WHILE */
  480. /* Now compute b = 2.0**m with the smallest positive integer m */
  481. /* such that */
  482. /* fl( a + b ) .gt. a. */
  483. b = 1.f;
  484. c__ = slamc3_(&a, &b);
  485. /* + WHILE( C.EQ.A )LOOP */
  486. L20:
  487. if (c__ == a) {
  488. b *= 2;
  489. c__ = slamc3_(&a, &b);
  490. goto L20;
  491. }
  492. /* + END WHILE */
  493. /* Now compute the base. a and c are neighbouring floating point */
  494. /* numbers in the interval ( beta**t, beta**( t + 1 ) ) and so */
  495. /* their difference is beta. Adding 0.25 to c is to ensure that it */
  496. /* is truncated to beta and not ( beta - 1 ). */
  497. qtr = one / 4;
  498. savec = c__;
  499. r__1 = -a;
  500. c__ = slamc3_(&c__, &r__1);
  501. lbeta = c__ + qtr;
  502. /* Now determine whether rounding or chopping occurs, by adding a */
  503. /* bit less than beta/2 and a bit more than beta/2 to a. */
  504. b = (real) lbeta;
  505. r__1 = b / 2;
  506. r__2 = -b / 100;
  507. f = slamc3_(&r__1, &r__2);
  508. c__ = slamc3_(&f, &a);
  509. if (c__ == a) {
  510. lrnd = TRUE_;
  511. } else {
  512. lrnd = FALSE_;
  513. }
  514. r__1 = b / 2;
  515. r__2 = b / 100;
  516. f = slamc3_(&r__1, &r__2);
  517. c__ = slamc3_(&f, &a);
  518. if (lrnd && c__ == a) {
  519. lrnd = FALSE_;
  520. }
  521. /* Try and decide whether rounding is done in the IEEE 'round to */
  522. /* nearest' style. B/2 is half a unit in the last place of the two */
  523. /* numbers A and SAVEC. Furthermore, A is even, i.e. has last bit */
  524. /* zero, and SAVEC is odd. Thus adding B/2 to A should not change */
  525. /* A, but adding B/2 to SAVEC should change SAVEC. */
  526. r__1 = b / 2;
  527. t1 = slamc3_(&r__1, &a);
  528. r__1 = b / 2;
  529. t2 = slamc3_(&r__1, &savec);
  530. lieee1 = t1 == a && t2 > savec && lrnd;
  531. /* Now find the mantissa, t. It should be the integer part of */
  532. /* log to the base beta of a, however it is safer to determine t */
  533. /* by powering. So we find t as the smallest positive integer for */
  534. /* which */
  535. /* fl( beta**t + 1.0 ) = 1.0. */
  536. lt = 0;
  537. a = 1.f;
  538. c__ = 1.f;
  539. /* + WHILE( C.EQ.ONE )LOOP */
  540. L30:
  541. if (c__ == one) {
  542. ++lt;
  543. a *= lbeta;
  544. c__ = slamc3_(&a, &one);
  545. r__1 = -a;
  546. c__ = slamc3_(&c__, &r__1);
  547. goto L30;
  548. }
  549. /* + END WHILE */
  550. }
  551. *beta = lbeta;
  552. *t = lt;
  553. *rnd = lrnd;
  554. *ieee1 = lieee1;
  555. first = FALSE_;
  556. return 0;
  557. /* End of SLAMC1 */
  558. } /* slamc1_ */
  559. /* *********************************************************************** */
  560. /* > \brief \b SLAMC2 */
  561. /* > \details */
  562. /* > \b Purpose: */
  563. /* > \verbatim */
  564. /* > SLAMC2 determines the machine parameters specified in its argument */
  565. /* > list. */
  566. /* > \endverbatim */
  567. /* > \author LAPACK is a software package provided by Univ. of Tennessee, Univ. of California Berkeley, Univ.
  568. of Colorado Denver and NAG Ltd.. */
  569. /* > \date April 2012 */
  570. /* > \ingroup auxOTHERauxiliary */
  571. /* > */
  572. /* > \param[out] BETA */
  573. /* > \verbatim */
  574. /* > The base of the machine. */
  575. /* > \endverbatim */
  576. /* > */
  577. /* > \param[out] T */
  578. /* > \verbatim */
  579. /* > The number of ( BETA ) digits in the mantissa. */
  580. /* > \endverbatim */
  581. /* > */
  582. /* > \param[out] RND */
  583. /* > \verbatim */
  584. /* > Specifies whether proper rounding ( RND = .TRUE. ) or */
  585. /* > chopping ( RND = .FALSE. ) occurs in addition. This may not */
  586. /* > be a reliable guide to the way in which the machine performs */
  587. /* > its arithmetic. */
  588. /* > \endverbatim */
  589. /* > */
  590. /* > \param[out] EPS */
  591. /* > \verbatim */
  592. /* > The smallest positive number such that */
  593. /* > fl( 1.0 - EPS ) .LT. 1.0, */
  594. /* > where fl denotes the computed value. */
  595. /* > \endverbatim */
  596. /* > */
  597. /* > \param[out] EMIN */
  598. /* > \verbatim */
  599. /* > The minimum exponent before (gradual) underflow occurs. */
  600. /* > \endverbatim */
  601. /* > */
  602. /* > \param[out] RMIN */
  603. /* > \verbatim */
  604. /* > The smallest normalized number for the machine, given by */
  605. /* > BASE**( EMIN - 1 ), where BASE is the floating point value */
  606. /* > of BETA. */
  607. /* > \endverbatim */
  608. /* > */
  609. /* > \param[out] EMAX */
  610. /* > \verbatim */
  611. /* > The maximum exponent before overflow occurs. */
  612. /* > \endverbatim */
  613. /* > */
  614. /* > \param[out] RMAX */
  615. /* > \verbatim */
  616. /* > The largest positive number for the machine, given by */
  617. /* > BASE**EMAX * ( 1 - EPS ), where BASE is the floating point */
  618. /* > value of BETA. */
  619. /* > \endverbatim */
  620. /* > */
  621. /* > \details \b Further \b Details */
  622. /* > \verbatim */
  623. /* > */
  624. /* > The computation of EPS is based on a routine PARANOIA by */
  625. /* > W. Kahan of the University of California at Berkeley. */
  626. /* > \endverbatim */
  627. /* Subroutine */ int slamc2_(integer *beta, integer *t, logical *rnd, real *
  628. eps, integer *emin, real *rmin, integer *emax, real *rmax)
  629. {
  630. /* Initialized data */
  631. static logical first = TRUE_;
  632. static logical iwarn = FALSE_;
  633. /* Format strings */
  634. static char fmt_9999[] = "(//\002 WARNING. The value EMIN may be incorre"
  635. "ct:-\002,\002 EMIN = \002,i8,/\002 If, after inspection, the va"
  636. "lue EMIN looks\002,\002 acceptable please comment out \002,/\002"
  637. " the IF block as marked within the code of routine\002,\002 SLAM"
  638. "C2,\002,/\002 otherwise supply EMIN explicitly.\002,/)";
  639. /* System generated locals */
  640. integer i__1;
  641. real r__1, r__2, r__3, r__4, r__5;
  642. /* Local variables */
  643. logical ieee;
  644. real half;
  645. logical lrnd;
  646. static real leps;
  647. real zero, a, b, c__;
  648. integer i__;
  649. static integer lbeta;
  650. real rbase;
  651. static integer lemin, lemax;
  652. integer gnmin;
  653. real small;
  654. integer gpmin;
  655. real third;
  656. static real lrmin, lrmax;
  657. real sixth;
  658. logical lieee1;
  659. extern /* Subroutine */ int slamc1_(integer *, integer *, logical *,
  660. logical *);
  661. extern real slamc3_(real *, real *);
  662. extern /* Subroutine */ int slamc4_(integer *, real *, integer *),
  663. slamc5_(integer *, integer *, integer *, logical *, integer *,
  664. real *);
  665. static integer lt;
  666. integer ngnmin, ngpmin;
  667. real one, two;
  668. /* Fortran I/O blocks */
  669. static cilist io___58 = { 0, 6, 0, fmt_9999, 0 };
  670. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  671. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  672. /* November 2010 */
  673. /* ===================================================================== */
  674. if (first) {
  675. zero = 0.f;
  676. one = 1.f;
  677. two = 2.f;
  678. /* LBETA, LT, LRND, LEPS, LEMIN and LRMIN are the local values of */
  679. /* BETA, T, RND, EPS, EMIN and RMIN. */
  680. /* Throughout this routine we use the function SLAMC3 to ensure */
  681. /* that relevant values are stored and not held in registers, or */
  682. /* are not affected by optimizers. */
  683. /* SLAMC1 returns the parameters LBETA, LT, LRND and LIEEE1. */
  684. slamc1_(&lbeta, &lt, &lrnd, &lieee1);
  685. /* Start to find EPS. */
  686. b = (real) lbeta;
  687. i__1 = -lt;
  688. a = pow_ri(&b, &i__1);
  689. leps = a;
  690. /* Try some tricks to see whether or not this is the correct EPS. */
  691. b = two / 3;
  692. half = one / 2;
  693. r__1 = -half;
  694. sixth = slamc3_(&b, &r__1);
  695. third = slamc3_(&sixth, &sixth);
  696. r__1 = -half;
  697. b = slamc3_(&third, &r__1);
  698. b = slamc3_(&b, &sixth);
  699. b = abs(b);
  700. if (b < leps) {
  701. b = leps;
  702. }
  703. leps = 1.f;
  704. /* + WHILE( ( LEPS.GT.B ).AND.( B.GT.ZERO ) )LOOP */
  705. L10:
  706. if (leps > b && b > zero) {
  707. leps = b;
  708. r__1 = half * leps;
  709. /* Computing 5th power */
  710. r__3 = two, r__4 = r__3, r__3 *= r__3;
  711. /* Computing 2nd power */
  712. r__5 = leps;
  713. r__2 = r__4 * (r__3 * r__3) * (r__5 * r__5);
  714. c__ = slamc3_(&r__1, &r__2);
  715. r__1 = -c__;
  716. c__ = slamc3_(&half, &r__1);
  717. b = slamc3_(&half, &c__);
  718. r__1 = -b;
  719. c__ = slamc3_(&half, &r__1);
  720. b = slamc3_(&half, &c__);
  721. goto L10;
  722. }
  723. /* + END WHILE */
  724. if (a < leps) {
  725. leps = a;
  726. }
  727. /* Computation of EPS complete. */
  728. /* Now find EMIN. Let A = + or - 1, and + or - (1 + BASE**(-3)). */
  729. /* Keep dividing A by BETA until (gradual) underflow occurs. This */
  730. /* is detected when we cannot recover the previous A. */
  731. rbase = one / lbeta;
  732. small = one;
  733. for (i__ = 1; i__ <= 3; ++i__) {
  734. r__1 = small * rbase;
  735. small = slamc3_(&r__1, &zero);
  736. /* L20: */
  737. }
  738. a = slamc3_(&one, &small);
  739. slamc4_(&ngpmin, &one, &lbeta);
  740. r__1 = -one;
  741. slamc4_(&ngnmin, &r__1, &lbeta);
  742. slamc4_(&gpmin, &a, &lbeta);
  743. r__1 = -a;
  744. slamc4_(&gnmin, &r__1, &lbeta);
  745. ieee = FALSE_;
  746. if (ngpmin == ngnmin && gpmin == gnmin) {
  747. if (ngpmin == gpmin) {
  748. lemin = ngpmin;
  749. /* ( Non twos-complement machines, no gradual underflow; */
  750. /* e.g., VAX ) */
  751. } else if (gpmin - ngpmin == 3) {
  752. lemin = ngpmin - 1 + lt;
  753. ieee = TRUE_;
  754. /* ( Non twos-complement machines, with gradual underflow; */
  755. /* e.g., IEEE standard followers ) */
  756. } else {
  757. lemin = f2cmin(ngpmin,gpmin);
  758. /* ( A guess; no known machine ) */
  759. iwarn = TRUE_;
  760. }
  761. } else if (ngpmin == gpmin && ngnmin == gnmin) {
  762. if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1) {
  763. lemin = f2cmax(ngpmin,ngnmin);
  764. /* ( Twos-complement machines, no gradual underflow; */
  765. /* e.g., CYBER 205 ) */
  766. } else {
  767. lemin = f2cmin(ngpmin,ngnmin);
  768. /* ( A guess; no known machine ) */
  769. iwarn = TRUE_;
  770. }
  771. } else if ((i__1 = ngpmin - ngnmin, abs(i__1)) == 1 && gpmin == gnmin)
  772. {
  773. if (gpmin - f2cmin(ngpmin,ngnmin) == 3) {
  774. lemin = f2cmax(ngpmin,ngnmin) - 1 + lt;
  775. /* ( Twos-complement machines with gradual underflow; */
  776. /* no known machine ) */
  777. } else {
  778. lemin = f2cmin(ngpmin,ngnmin);
  779. /* ( A guess; no known machine ) */
  780. iwarn = TRUE_;
  781. }
  782. } else {
  783. /* Computing MIN */
  784. i__1 = f2cmin(ngpmin,ngnmin), i__1 = f2cmin(i__1,gpmin);
  785. lemin = f2cmin(i__1,gnmin);
  786. /* ( A guess; no known machine ) */
  787. iwarn = TRUE_;
  788. }
  789. first = FALSE_;
  790. /* ** */
  791. /* Comment out this if block if EMIN is ok */
  792. /*
  793. if (iwarn) {
  794. first = TRUE_;
  795. s_wsfe(&io___58);
  796. do_fio(&c__1, (char *)&lemin, (ftnlen)sizeof(integer));
  797. e_wsfe();
  798. }
  799. */
  800. /* ** */
  801. /* Assume IEEE arithmetic if we found denormalised numbers above, */
  802. /* or if arithmetic seems to round in the IEEE style, determined */
  803. /* in routine SLAMC1. A true IEEE machine should have both things */
  804. /* true; however, faulty machines may have one or the other. */
  805. ieee = ieee || lieee1;
  806. /* Compute RMIN by successive division by BETA. We could compute */
  807. /* RMIN as BASE**( EMIN - 1 ), but some machines underflow during */
  808. /* this computation. */
  809. lrmin = 1.f;
  810. i__1 = 1 - lemin;
  811. for (i__ = 1; i__ <= i__1; ++i__) {
  812. r__1 = lrmin * rbase;
  813. lrmin = slamc3_(&r__1, &zero);
  814. /* L30: */
  815. }
  816. /* Finally, call SLAMC5 to compute EMAX and RMAX. */
  817. slamc5_(&lbeta, &lt, &lemin, &ieee, &lemax, &lrmax);
  818. }
  819. *beta = lbeta;
  820. *t = lt;
  821. *rnd = lrnd;
  822. *eps = leps;
  823. *emin = lemin;
  824. *rmin = lrmin;
  825. *emax = lemax;
  826. *rmax = lrmax;
  827. return 0;
  828. /* End of SLAMC2 */
  829. } /* slamc2_ */
  830. /* *********************************************************************** */
  831. /* > \brief \b SLAMC3 */
  832. /* > \details */
  833. /* > \b Purpose: */
  834. /* > \verbatim */
  835. /* > SLAMC3 is intended to force A and B to be stored prior to doing */
  836. /* > the addition of A and B , for use in situations where optimizers */
  837. /* > might hold one of these in a register. */
  838. /* > \endverbatim */
  839. /* > */
  840. /* > \param[in] A */
  841. /* > */
  842. /* > \param[in] B */
  843. /* > \verbatim */
  844. /* > The values A and B. */
  845. /* > \endverbatim */
  846. real slamc3_(real *a, real *b)
  847. {
  848. /* System generated locals */
  849. real ret_val;
  850. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  851. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  852. /* November 2010 */
  853. /* ===================================================================== */
  854. ret_val = *a + *b;
  855. return ret_val;
  856. /* End of SLAMC3 */
  857. } /* slamc3_ */
  858. /* *********************************************************************** */
  859. /* > \brief \b SLAMC4 */
  860. /* > \details */
  861. /* > \b Purpose: */
  862. /* > \verbatim */
  863. /* > SLAMC4 is a service routine for SLAMC2. */
  864. /* > \endverbatim */
  865. /* > */
  866. /* > \param[out] EMIN */
  867. /* > \verbatim */
  868. /* > The minimum exponent before (gradual) underflow, computed by */
  869. /* > setting A = START and dividing by BASE until the previous A */
  870. /* > can not be recovered. */
  871. /* > \endverbatim */
  872. /* > */
  873. /* > \param[in] START */
  874. /* > \verbatim */
  875. /* > The starting point for determining EMIN. */
  876. /* > \endverbatim */
  877. /* > */
  878. /* > \param[in] BASE */
  879. /* > \verbatim */
  880. /* > The base of the machine. */
  881. /* > \endverbatim */
  882. /* > */
  883. /* Subroutine */ int slamc4_(integer *emin, real *start, integer *base)
  884. {
  885. /* System generated locals */
  886. integer i__1;
  887. real r__1;
  888. /* Local variables */
  889. real zero, a;
  890. integer i__;
  891. real rbase, b1, b2, c1, c2, d1, d2;
  892. extern real slamc3_(real *, real *);
  893. real one;
  894. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  895. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  896. /* November 2010 */
  897. /* ===================================================================== */
  898. a = *start;
  899. one = 1.f;
  900. rbase = one / *base;
  901. zero = 0.f;
  902. *emin = 1;
  903. r__1 = a * rbase;
  904. b1 = slamc3_(&r__1, &zero);
  905. c1 = a;
  906. c2 = a;
  907. d1 = a;
  908. d2 = a;
  909. /* + WHILE( ( C1.EQ.A ).AND.( C2.EQ.A ).AND. */
  910. /* $ ( D1.EQ.A ).AND.( D2.EQ.A ) )LOOP */
  911. L10:
  912. if (c1 == a && c2 == a && d1 == a && d2 == a) {
  913. --(*emin);
  914. a = b1;
  915. r__1 = a / *base;
  916. b1 = slamc3_(&r__1, &zero);
  917. r__1 = b1 * *base;
  918. c1 = slamc3_(&r__1, &zero);
  919. d1 = zero;
  920. i__1 = *base;
  921. for (i__ = 1; i__ <= i__1; ++i__) {
  922. d1 += b1;
  923. /* L20: */
  924. }
  925. r__1 = a * rbase;
  926. b2 = slamc3_(&r__1, &zero);
  927. r__1 = b2 / rbase;
  928. c2 = slamc3_(&r__1, &zero);
  929. d2 = zero;
  930. i__1 = *base;
  931. for (i__ = 1; i__ <= i__1; ++i__) {
  932. d2 += b2;
  933. /* L30: */
  934. }
  935. goto L10;
  936. }
  937. /* + END WHILE */
  938. return 0;
  939. /* End of SLAMC4 */
  940. } /* slamc4_ */
  941. /* *********************************************************************** */
  942. /* > \brief \b SLAMC5 */
  943. /* > \details */
  944. /* > \b Purpose: */
  945. /* > \verbatim */
  946. /* > SLAMC5 attempts to compute RMAX, the largest machine floating-point */
  947. /* > number, without overflow. It assumes that EMAX + abs(EMIN) sum */
  948. /* > approximately to a power of 2. It will fail on machines where this */
  949. /* > assumption does not hold, for example, the Cyber 205 (EMIN = -28625, */
  950. /* > EMAX = 28718). It will also fail if the value supplied for EMIN is */
  951. /* > too large (i.e. too close to zero), probably with overflow. */
  952. /* > \endverbatim */
  953. /* > */
  954. /* > \param[in] BETA */
  955. /* > \verbatim */
  956. /* > The base of floating-point arithmetic. */
  957. /* > \endverbatim */
  958. /* > */
  959. /* > \param[in] P */
  960. /* > \verbatim */
  961. /* > The number of base BETA digits in the mantissa of a */
  962. /* > floating-point value. */
  963. /* > \endverbatim */
  964. /* > */
  965. /* > \param[in] EMIN */
  966. /* > \verbatim */
  967. /* > The minimum exponent before (gradual) underflow. */
  968. /* > \endverbatim */
  969. /* > */
  970. /* > \param[in] IEEE */
  971. /* > \verbatim */
  972. /* > A logical flag specifying whether or not the arithmetic */
  973. /* > system is thought to comply with the IEEE standard. */
  974. /* > \endverbatim */
  975. /* > */
  976. /* > \param[out] EMAX */
  977. /* > \verbatim */
  978. /* > The largest exponent before overflow */
  979. /* > \endverbatim */
  980. /* > */
  981. /* > \param[out] RMAX */
  982. /* > \verbatim */
  983. /* > The largest machine floating-point number. */
  984. /* > \endverbatim */
  985. /* > */
  986. /* Subroutine */ int slamc5_(integer *beta, integer *p, integer *emin,
  987. logical *ieee, integer *emax, real *rmax)
  988. {
  989. /* System generated locals */
  990. integer i__1;
  991. real r__1;
  992. /* Local variables */
  993. integer lexp;
  994. real oldy;
  995. integer uexp, i__;
  996. real y, z__;
  997. integer nbits;
  998. extern real slamc3_(real *, real *);
  999. real recbas;
  1000. integer exbits, expsum, try__;
  1001. /* -- LAPACK auxiliary routine (version 3.7.0) -- */
  1002. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  1003. /* November 2010 */
  1004. /* ===================================================================== */
  1005. /* First compute LEXP and UEXP, two powers of 2 that bound */
  1006. /* abs(EMIN). We then assume that EMAX + abs(EMIN) will sum */
  1007. /* approximately to the bound that is closest to abs(EMIN). */
  1008. /* (EMAX is the exponent of the required number RMAX). */
  1009. lexp = 1;
  1010. exbits = 1;
  1011. L10:
  1012. try__ = lexp << 1;
  1013. if (try__ <= -(*emin)) {
  1014. lexp = try__;
  1015. ++exbits;
  1016. goto L10;
  1017. }
  1018. if (lexp == -(*emin)) {
  1019. uexp = lexp;
  1020. } else {
  1021. uexp = try__;
  1022. ++exbits;
  1023. }
  1024. /* Now -LEXP is less than or equal to EMIN, and -UEXP is greater */
  1025. /* than or equal to EMIN. EXBITS is the number of bits needed to */
  1026. /* store the exponent. */
  1027. if (uexp + *emin > -lexp - *emin) {
  1028. expsum = lexp << 1;
  1029. } else {
  1030. expsum = uexp << 1;
  1031. }
  1032. /* EXPSUM is the exponent range, approximately equal to */
  1033. /* EMAX - EMIN + 1 . */
  1034. *emax = expsum + *emin - 1;
  1035. nbits = exbits + 1 + *p;
  1036. /* NBITS is the total number of bits needed to store a */
  1037. /* floating-point number. */
  1038. if (nbits % 2 == 1 && *beta == 2) {
  1039. /* Either there are an odd number of bits used to store a */
  1040. /* floating-point number, which is unlikely, or some bits are */
  1041. /* not used in the representation of numbers, which is possible, */
  1042. /* (e.g. Cray machines) or the mantissa has an implicit bit, */
  1043. /* (e.g. IEEE machines, Dec Vax machines), which is perhaps the */
  1044. /* most likely. We have to assume the last alternative. */
  1045. /* If this is true, then we need to reduce EMAX by one because */
  1046. /* there must be some way of representing zero in an implicit-bit */
  1047. /* system. On machines like Cray, we are reducing EMAX by one */
  1048. /* unnecessarily. */
  1049. --(*emax);
  1050. }
  1051. if (*ieee) {
  1052. /* Assume we are on an IEEE machine which reserves one exponent */
  1053. /* for infinity and NaN. */
  1054. --(*emax);
  1055. }
  1056. /* Now create RMAX, the largest machine number, which should */
  1057. /* be equal to (1.0 - BETA**(-P)) * BETA**EMAX . */
  1058. /* First compute 1.0 - BETA**(-P), being careful that the */
  1059. /* result is less than 1.0 . */
  1060. recbas = 1.f / *beta;
  1061. z__ = *beta - 1.f;
  1062. y = 0.f;
  1063. i__1 = *p;
  1064. for (i__ = 1; i__ <= i__1; ++i__) {
  1065. z__ *= recbas;
  1066. if (y < 1.f) {
  1067. oldy = y;
  1068. }
  1069. y = slamc3_(&y, &z__);
  1070. /* L20: */
  1071. }
  1072. if (y >= 1.f) {
  1073. y = oldy;
  1074. }
  1075. /* Now multiply by BETA**EMAX to get RMAX. */
  1076. i__1 = *emax;
  1077. for (i__ = 1; i__ <= i__1; ++i__) {
  1078. r__1 = y * *beta;
  1079. y = slamc3_(&r__1, &c_b32);
  1080. /* L30: */
  1081. }
  1082. *rmax = y;
  1083. return 0;
  1084. /* End of SLAMC5 */
  1085. } /* slamc5_ */