LAPACK  3.11.0
LAPACK: Linear Algebra PACKage
dlamchf77.f
1 *> \brief \b DLAMCHF77 deprecated
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * DOUBLE PRECISION FUNCTION DLAMCH( CMACH )
12 *
13 * .. Scalar Arguments ..
14 * CHARACTER CMACH
15 * ..
16 *
17 *
18 *> \par Purpose:
19 * =============
20 *>
21 *> \verbatim
22 *>
23 *> DLAMCHF77 determines double precision machine parameters.
24 *> \endverbatim
25 *
26 * Arguments:
27 * ==========
28 *
29 *> \param[in] CMACH
30 *> \verbatim
31 *> Specifies the value to be returned by DLAMCH:
32 *> = 'E' or 'e', DLAMCH := eps
33 *> = 'S' or 's , DLAMCH := sfmin
34 *> = 'B' or 'b', DLAMCH := base
35 *> = 'P' or 'p', DLAMCH := eps*base
36 *> = 'N' or 'n', DLAMCH := t
37 *> = 'R' or 'r', DLAMCH := rnd
38 *> = 'M' or 'm', DLAMCH := emin
39 *> = 'U' or 'u', DLAMCH := rmin
40 *> = 'L' or 'l', DLAMCH := emax
41 *> = 'O' or 'o', DLAMCH := rmax
42 *> where
43 *> eps = relative machine precision
44 *> sfmin = safe minimum, such that 1/sfmin does not overflow
45 *> base = base of the machine
46 *> prec = eps*base
47 *> t = number of (base) digits in the mantissa
48 *> rnd = 1.0 when rounding occurs in addition, 0.0 otherwise
49 *> emin = minimum exponent before (gradual) underflow
50 *> rmin = underflow threshold - base**(emin-1)
51 *> emax = largest exponent before overflow
52 *> rmax = overflow threshold - (base**emax)*(1-eps)
53 *> \endverbatim
54 *
55 * Authors:
56 * ========
57 *
58 *> \author Univ. of Tennessee
59 *> \author Univ. of California Berkeley
60 *> \author Univ. of Colorado Denver
61 *> \author NAG Ltd.
62 *
63 
64 *> \ingroup lamch
65 *
66 * =====================================================================
67  DOUBLE PRECISION FUNCTION dlamch( CMACH )
68 *
69 * -- LAPACK auxiliary routine --
70 * -- LAPACK is a software package provided by Univ. of Tennessee, --
71 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
72 *
73 * .. Scalar Arguments ..
74  CHARACTER cmach
75 * ..
76 * .. Parameters ..
77  DOUBLE PRECISION one, zero
78  parameter( one = 1.0d+0, zero = 0.0d+0 )
79 * ..
80 * .. Local Scalars ..
81  LOGICAL first, lrnd
82  INTEGER beta, imax, imin, it
83  DOUBLE PRECISION base, emax, emin, eps, prec, rmach, rmax, rmin,
84  $ rnd, sfmin, small, t
85 * ..
86 * .. External Functions ..
87  LOGICAL lsame
88  EXTERNAL lsame
89 * ..
90 * .. External Subroutines ..
91  EXTERNAL dlamc2
92 * ..
93 * .. Save statement ..
94  SAVE first, eps, sfmin, base, t, rnd, emin, rmin,
95  $ emax, rmax, prec
96 * ..
97 * .. Data statements ..
98  DATA first / .true. /
99 * ..
100 * .. Executable Statements ..
101 *
102  IF( first ) THEN
103  CALL dlamc2( beta, it, lrnd, eps, imin, rmin, imax, rmax )
104  base = beta
105  t = it
106  IF( lrnd ) THEN
107  rnd = one
108  eps = ( base**( 1-it ) ) / 2
109  ELSE
110  rnd = zero
111  eps = base**( 1-it )
112  END IF
113  prec = eps*base
114  emin = imin
115  emax = imax
116  sfmin = rmin
117  small = one / rmax
118  IF( small.GE.sfmin ) THEN
119 *
120 * Use SMALL plus a bit, to avoid the possibility of rounding
121 * causing overflow when computing 1/sfmin.
122 *
123  sfmin = small*( one+eps )
124  END IF
125  END IF
126 *
127  IF( lsame( cmach, 'E' ) ) THEN
128  rmach = eps
129  ELSE IF( lsame( cmach, 'S' ) ) THEN
130  rmach = sfmin
131  ELSE IF( lsame( cmach, 'B' ) ) THEN
132  rmach = base
133  ELSE IF( lsame( cmach, 'P' ) ) THEN
134  rmach = prec
135  ELSE IF( lsame( cmach, 'N' ) ) THEN
136  rmach = t
137  ELSE IF( lsame( cmach, 'R' ) ) THEN
138  rmach = rnd
139  ELSE IF( lsame( cmach, 'M' ) ) THEN
140  rmach = emin
141  ELSE IF( lsame( cmach, 'U' ) ) THEN
142  rmach = rmin
143  ELSE IF( lsame( cmach, 'L' ) ) THEN
144  rmach = emax
145  ELSE IF( lsame( cmach, 'O' ) ) THEN
146  rmach = rmax
147  END IF
148 *
149  dlamch = rmach
150  first = .false.
151  RETURN
152 *
153 * End of DLAMCH
154 *
155  END
156 *
157 ************************************************************************
158 *> \brief \b DLAMC1
159 *> \details
160 *> \b Purpose:
161 *> \verbatim
162 *> DLAMC1 determines the machine parameters given by BETA, T, RND, and
163 *> IEEE1.
164 *> \endverbatim
165 *>
166 *> \param[out] BETA
167 *> \verbatim
168 *> The base of the machine.
169 *> \endverbatim
170 *>
171 *> \param[out] T
172 *> \verbatim
173 *> The number of ( BETA ) digits in the mantissa.
174 *> \endverbatim
175 *>
176 *> \param[out] RND
177 *> \verbatim
178 *> Specifies whether proper rounding ( RND = .TRUE. ) or
179 *> chopping ( RND = .FALSE. ) occurs in addition. This may not
180 *> be a reliable guide to the way in which the machine performs
181 *> its arithmetic.
182 *> \endverbatim
183 *>
184 *> \param[out] IEEE1
185 *> \verbatim
186 *> Specifies whether rounding appears to be done in the IEEE
187 *> 'round to nearest' style.
188 *> \endverbatim
189 *> \author LAPACK is a software package provided by Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..
190 *>
191 *> \ingroup lamc1
192 *>
193 *> \details \b Further \b Details
194 *> \verbatim
195 *>
196 *> The routine is based on the routine ENVRON by Malcolm and
197 *> incorporates suggestions by Gentleman and Marovich. See
198 *>
199 *> Malcolm M. A. (1972) Algorithms to reveal properties of
200 *> floating-point arithmetic. Comms. of the ACM, 15, 949-951.
201 *>
202 *> Gentleman W. M. and Marovich S. B. (1974) More on algorithms
203 *> that reveal properties of floating point arithmetic units.
204 *> Comms. of the ACM, 17, 276-277.
205 *> \endverbatim
206 *>
207  SUBROUTINE dlamc1( BETA, T, RND, IEEE1 )
208 *
209 * -- LAPACK auxiliary routine --
210 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
211 *
212 * .. Scalar Arguments ..
213  LOGICAL IEEE1, RND
214  INTEGER BETA, T
215 * ..
216 * =====================================================================
217 *
218 * .. Local Scalars ..
219  LOGICAL FIRST, LIEEE1, LRND
220  INTEGER LBETA, LT
221  DOUBLE PRECISION A, B, C, F, ONE, QTR, SAVEC, T1, T2
222 * ..
223 * .. External Functions ..
224  DOUBLE PRECISION DLAMC3
225  EXTERNAL dlamc3
226 * ..
227 * .. Save statement ..
228  SAVE first, lieee1, lbeta, lrnd, lt
229 * ..
230 * .. Data statements ..
231  DATA first / .true. /
232 * ..
233 * .. Executable Statements ..
234 *
235  IF( first ) THEN
236  one = 1
237 *
238 * LBETA, LIEEE1, LT and LRND are the local values of BETA,
239 * IEEE1, T and RND.
240 *
241 * Throughout this routine we use the function DLAMC3 to ensure
242 * that relevant values are stored and not held in registers, or
243 * are not affected by optimizers.
244 *
245 * Compute a = 2.0**m with the smallest positive integer m such
246 * that
247 *
248 * fl( a + 1.0 ) = a.
249 *
250  a = 1
251  c = 1
252 *
253 *+ WHILE( C.EQ.ONE )LOOP
254  10 CONTINUE
255  IF( c.EQ.one ) THEN
256  a = 2*a
257  c = dlamc3( a, one )
258  c = dlamc3( c, -a )
259  GO TO 10
260  END IF
261 *+ END WHILE
262 *
263 * Now compute b = 2.0**m with the smallest positive integer m
264 * such that
265 *
266 * fl( a + b ) .gt. a.
267 *
268  b = 1
269  c = dlamc3( a, b )
270 *
271 *+ WHILE( C.EQ.A )LOOP
272  20 CONTINUE
273  IF( c.EQ.a ) THEN
274  b = 2*b
275  c = dlamc3( a, b )
276  GO TO 20
277  END IF
278 *+ END WHILE
279 *
280 * Now compute the base. a and c are neighbouring floating point
281 * numbers in the interval ( beta**t, beta**( t + 1 ) ) and so
282 * their difference is beta. Adding 0.25 to c is to ensure that it
283 * is truncated to beta and not ( beta - 1 ).
284 *
285  qtr = one / 4
286  savec = c
287  c = dlamc3( c, -a )
288  lbeta = c + qtr
289 *
290 * Now determine whether rounding or chopping occurs, by adding a
291 * bit less than beta/2 and a bit more than beta/2 to a.
292 *
293  b = lbeta
294  f = dlamc3( b / 2, -b / 100 )
295  c = dlamc3( f, a )
296  IF( c.EQ.a ) THEN
297  lrnd = .true.
298  ELSE
299  lrnd = .false.
300  END IF
301  f = dlamc3( b / 2, b / 100 )
302  c = dlamc3( f, a )
303  IF( ( lrnd ) .AND. ( c.EQ.a ) )
304  $ lrnd = .false.
305 *
306 * Try and decide whether rounding is done in the IEEE 'round to
307 * nearest' style. B/2 is half a unit in the last place of the two
308 * numbers A and SAVEC. Furthermore, A is even, i.e. has last bit
309 * zero, and SAVEC is odd. Thus adding B/2 to A should not change
310 * A, but adding B/2 to SAVEC should change SAVEC.
311 *
312  t1 = dlamc3( b / 2, a )
313  t2 = dlamc3( b / 2, savec )
314  lieee1 = ( t1.EQ.a ) .AND. ( t2.GT.savec ) .AND. lrnd
315 *
316 * Now find the mantissa, t. It should be the integer part of
317 * log to the base beta of a, however it is safer to determine t
318 * by powering. So we find t as the smallest positive integer for
319 * which
320 *
321 * fl( beta**t + 1.0 ) = 1.0.
322 *
323  lt = 0
324  a = 1
325  c = 1
326 *
327 *+ WHILE( C.EQ.ONE )LOOP
328  30 CONTINUE
329  IF( c.EQ.one ) THEN
330  lt = lt + 1
331  a = a*lbeta
332  c = dlamc3( a, one )
333  c = dlamc3( c, -a )
334  GO TO 30
335  END IF
336 *+ END WHILE
337 *
338  END IF
339 *
340  beta = lbeta
341  t = lt
342  rnd = lrnd
343  ieee1 = lieee1
344  first = .false.
345  RETURN
346 *
347 * End of DLAMC1
348 *
349  END
350 *
351 ************************************************************************
352 *> \brief \b DLAMC2
353 *> \details
354 *> \b Purpose:
355 *> \verbatim
356 *> DLAMC2 determines the machine parameters specified in its argument
357 *> list.
358 *> \endverbatim
359 *> \author LAPACK is a software package provided by Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..
360 *>
361 *> \ingroup lamc2
362 *>
363 *> \param[out] BETA
364 *> \verbatim
365 *> The base of the machine.
366 *> \endverbatim
367 *>
368 *> \param[out] T
369 *> \verbatim
370 *> The number of ( BETA ) digits in the mantissa.
371 *> \endverbatim
372 *>
373 *> \param[out] RND
374 *> \verbatim
375 *> Specifies whether proper rounding ( RND = .TRUE. ) or
376 *> chopping ( RND = .FALSE. ) occurs in addition. This may not
377 *> be a reliable guide to the way in which the machine performs
378 *> its arithmetic.
379 *> \endverbatim
380 *>
381 *> \param[out] EPS
382 *> \verbatim
383 *> The smallest positive number such that
384 *> fl( 1.0 - EPS ) .LT. 1.0,
385 *> where fl denotes the computed value.
386 *> \endverbatim
387 *>
388 *> \param[out] EMIN
389 *> \verbatim
390 *> The minimum exponent before (gradual) underflow occurs.
391 *> \endverbatim
392 *>
393 *> \param[out] RMIN
394 *> \verbatim
395 *> The smallest normalized number for the machine, given by
396 *> BASE**( EMIN - 1 ), where BASE is the floating point value
397 *> of BETA.
398 *> \endverbatim
399 *>
400 *> \param[out] EMAX
401 *> \verbatim
402 *> The maximum exponent before overflow occurs.
403 *> \endverbatim
404 *>
405 *> \param[out] RMAX
406 *> \verbatim
407 *> The largest positive number for the machine, given by
408 *> BASE**EMAX * ( 1 - EPS ), where BASE is the floating point
409 *> value of BETA.
410 *> \endverbatim
411 *>
412 *> \details \b Further \b Details
413 *> \verbatim
414 *>
415 *> The computation of EPS is based on a routine PARANOIA by
416 *> W. Kahan of the University of California at Berkeley.
417 *> \endverbatim
418  SUBROUTINE dlamc2( BETA, T, RND, EPS, EMIN, RMIN, EMAX, RMAX )
419 *
420 * -- LAPACK auxiliary routine --
421 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
422 *
423 * .. Scalar Arguments ..
424  LOGICAL RND
425  INTEGER BETA, EMAX, EMIN, T
426  DOUBLE PRECISION EPS, RMAX, RMIN
427 * ..
428 * =====================================================================
429 *
430 * .. Local Scalars ..
431  LOGICAL FIRST, IEEE, IWARN, LIEEE1, LRND
432  INTEGER GNMIN, GPMIN, I, LBETA, LEMAX, LEMIN, LT,
433  $ ngnmin, ngpmin
434  DOUBLE PRECISION A, B, C, HALF, LEPS, LRMAX, LRMIN, ONE, RBASE,
435  $ sixth, small, third, two, zero
436 * ..
437 * .. External Functions ..
438  DOUBLE PRECISION DLAMC3
439  EXTERNAL dlamc3
440 * ..
441 * .. External Subroutines ..
442  EXTERNAL dlamc1, dlamc4, dlamc5
443 * ..
444 * .. Intrinsic Functions ..
445  INTRINSIC abs, max, min
446 * ..
447 * .. Save statement ..
448  SAVE first, iwarn, lbeta, lemax, lemin, leps, lrmax,
449  $ lrmin, lt
450 * ..
451 * .. Data statements ..
452  DATA first / .true. / , iwarn / .false. /
453 * ..
454 * .. Executable Statements ..
455 *
456  IF( first ) THEN
457  zero = 0
458  one = 1
459  two = 2
460 *
461 * LBETA, LT, LRND, LEPS, LEMIN and LRMIN are the local values of
462 * BETA, T, RND, EPS, EMIN and RMIN.
463 *
464 * Throughout this routine we use the function DLAMC3 to ensure
465 * that relevant values are stored and not held in registers, or
466 * are not affected by optimizers.
467 *
468 * DLAMC1 returns the parameters LBETA, LT, LRND and LIEEE1.
469 *
470  CALL dlamc1( lbeta, lt, lrnd, lieee1 )
471 *
472 * Start to find EPS.
473 *
474  b = lbeta
475  a = b**( -lt )
476  leps = a
477 *
478 * Try some tricks to see whether or not this is the correct EPS.
479 *
480  b = two / 3
481  half = one / 2
482  sixth = dlamc3( b, -half )
483  third = dlamc3( sixth, sixth )
484  b = dlamc3( third, -half )
485  b = dlamc3( b, sixth )
486  b = abs( b )
487  IF( b.LT.leps )
488  $ b = leps
489 *
490  leps = 1
491 *
492 *+ WHILE( ( LEPS.GT.B ).AND.( B.GT.ZERO ) )LOOP
493  10 CONTINUE
494  IF( ( leps.GT.b ) .AND. ( b.GT.zero ) ) THEN
495  leps = b
496  c = dlamc3( half*leps, ( two**5 )*( leps**2 ) )
497  c = dlamc3( half, -c )
498  b = dlamc3( half, c )
499  c = dlamc3( half, -b )
500  b = dlamc3( half, c )
501  GO TO 10
502  END IF
503 *+ END WHILE
504 *
505  IF( a.LT.leps )
506  $ leps = a
507 *
508 * Computation of EPS complete.
509 *
510 * Now find EMIN. Let A = + or - 1, and + or - (1 + BASE**(-3)).
511 * Keep dividing A by BETA until (gradual) underflow occurs. This
512 * is detected when we cannot recover the previous A.
513 *
514  rbase = one / lbeta
515  small = one
516  DO 20 i = 1, 3
517  small = dlamc3( small*rbase, zero )
518  20 CONTINUE
519  a = dlamc3( one, small )
520  CALL dlamc4( ngpmin, one, lbeta )
521  CALL dlamc4( ngnmin, -one, lbeta )
522  CALL dlamc4( gpmin, a, lbeta )
523  CALL dlamc4( gnmin, -a, lbeta )
524  ieee = .false.
525 *
526  IF( ( ngpmin.EQ.ngnmin ) .AND. ( gpmin.EQ.gnmin ) ) THEN
527  IF( ngpmin.EQ.gpmin ) THEN
528  lemin = ngpmin
529 * ( Non twos-complement machines, no gradual underflow;
530 * e.g., VAX )
531  ELSE IF( ( gpmin-ngpmin ).EQ.3 ) THEN
532  lemin = ngpmin - 1 + lt
533  ieee = .true.
534 * ( Non twos-complement machines, with gradual underflow;
535 * e.g., IEEE standard followers )
536  ELSE
537  lemin = min( ngpmin, gpmin )
538 * ( A guess; no known machine )
539  iwarn = .true.
540  END IF
541 *
542  ELSE IF( ( ngpmin.EQ.gpmin ) .AND. ( ngnmin.EQ.gnmin ) ) THEN
543  IF( abs( ngpmin-ngnmin ).EQ.1 ) THEN
544  lemin = max( ngpmin, ngnmin )
545 * ( Twos-complement machines, no gradual underflow;
546 * e.g., CYBER 205 )
547  ELSE
548  lemin = min( ngpmin, ngnmin )
549 * ( A guess; no known machine )
550  iwarn = .true.
551  END IF
552 *
553  ELSE IF( ( abs( ngpmin-ngnmin ).EQ.1 ) .AND.
554  $ ( gpmin.EQ.gnmin ) ) THEN
555  IF( ( gpmin-min( ngpmin, ngnmin ) ).EQ.3 ) THEN
556  lemin = max( ngpmin, ngnmin ) - 1 + lt
557 * ( Twos-complement machines with gradual underflow;
558 * no known machine )
559  ELSE
560  lemin = min( ngpmin, ngnmin )
561 * ( A guess; no known machine )
562  iwarn = .true.
563  END IF
564 *
565  ELSE
566  lemin = min( ngpmin, ngnmin, gpmin, gnmin )
567 * ( A guess; no known machine )
568  iwarn = .true.
569  END IF
570  first = .false.
571 ***
572 * Comment out this if block if EMIN is ok
573  IF( iwarn ) THEN
574  first = .true.
575  WRITE( 6, fmt = 9999 )lemin
576  END IF
577 ***
578 *
579 * Assume IEEE arithmetic if we found denormalised numbers above,
580 * or if arithmetic seems to round in the IEEE style, determined
581 * in routine DLAMC1. A true IEEE machine should have both things
582 * true; however, faulty machines may have one or the other.
583 *
584  ieee = ieee .OR. lieee1
585 *
586 * Compute RMIN by successive division by BETA. We could compute
587 * RMIN as BASE**( EMIN - 1 ), but some machines underflow during
588 * this computation.
589 *
590  lrmin = 1
591  DO 30 i = 1, 1 - lemin
592  lrmin = dlamc3( lrmin*rbase, zero )
593  30 CONTINUE
594 *
595 * Finally, call DLAMC5 to compute EMAX and RMAX.
596 *
597  CALL dlamc5( lbeta, lt, lemin, ieee, lemax, lrmax )
598  END IF
599 *
600  beta = lbeta
601  t = lt
602  rnd = lrnd
603  eps = leps
604  emin = lemin
605  rmin = lrmin
606  emax = lemax
607  rmax = lrmax
608 *
609  RETURN
610 *
611  9999 FORMAT( / / ' WARNING. The value EMIN may be incorrect:-',
612  $ ' EMIN = ', i8, /
613  $ ' If, after inspection, the value EMIN looks',
614  $ ' acceptable please comment out ',
615  $ / ' the IF block as marked within the code of routine',
616  $ ' DLAMC2,', / ' otherwise supply EMIN explicitly.', / )
617 *
618 * End of DLAMC2
619 *
620  END
621 *
622 ************************************************************************
623 *> \brief \b DLAMC3
624 *> \details
625 *> \b Purpose:
626 *> \verbatim
627 *> DLAMC3 is intended to force A and B to be stored prior to doing
628 *> the addition of A and B , for use in situations where optimizers
629 *> might hold one of these in a register.
630 *> \endverbatim
631 *>
632 *> \param[in] A
633 *>
634 *> \param[in] B
635 *> \verbatim
636 *> The values A and B.
637 *> \endverbatim
638 *>
639 *> \ingroup lamc3
640 *>
641  DOUBLE PRECISION FUNCTION dlamc3( A, B )
642 *
643 * -- LAPACK auxiliary routine --
644 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
645 *
646 * .. Scalar Arguments ..
647  DOUBLE PRECISION A, B
648 * ..
649 * =====================================================================
650 *
651 * .. Executable Statements ..
652 *
653  dlamc3 = a + b
654 *
655  RETURN
656 *
657 * End of DLAMC3
658 *
659  END
660 *
661 ************************************************************************
662 *> \brief \b DLAMC4
663 *> \details
664 *> \b Purpose:
665 *> \verbatim
666 *> DLAMC4 is a service routine for DLAMC2.
667 *> \endverbatim
668 *>
669 *> \param[out] EMIN
670 *> \verbatim
671 *> The minimum exponent before (gradual) underflow, computed by
672 *> setting A = START and dividing by BASE until the previous A
673 *> can not be recovered.
674 *> \endverbatim
675 *>
676 *> \param[in] START
677 *> \verbatim
678 *> The starting point for determining EMIN.
679 *> \endverbatim
680 *>
681 *> \param[in] BASE
682 *> \verbatim
683 *> The base of the machine.
684 *> \endverbatim
685 *>
686 *> \ingroup lamc4
687 *>
688  SUBROUTINE dlamc4( EMIN, START, BASE )
689 *
690 * -- LAPACK auxiliary routine --
691 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
692 *
693 * .. Scalar Arguments ..
694  INTEGER BASE, EMIN
695  DOUBLE PRECISION START
696 * ..
697 * =====================================================================
698 *
699 * .. Local Scalars ..
700  INTEGER I
701  DOUBLE PRECISION A, B1, B2, C1, C2, D1, D2, ONE, RBASE, ZERO
702 * ..
703 * .. External Functions ..
704  DOUBLE PRECISION DLAMC3
705  EXTERNAL dlamc3
706 * ..
707 * .. Executable Statements ..
708 *
709  a = start
710  one = 1
711  rbase = one / base
712  zero = 0
713  emin = 1
714  b1 = dlamc3( a*rbase, zero )
715  c1 = a
716  c2 = a
717  d1 = a
718  d2 = a
719 *+ WHILE( ( C1.EQ.A ).AND.( C2.EQ.A ).AND.
720 * $ ( D1.EQ.A ).AND.( D2.EQ.A ) )LOOP
721  10 CONTINUE
722  IF( ( c1.EQ.a ) .AND. ( c2.EQ.a ) .AND. ( d1.EQ.a ) .AND.
723  $ ( d2.EQ.a ) ) THEN
724  emin = emin - 1
725  a = b1
726  b1 = dlamc3( a / base, zero )
727  c1 = dlamc3( b1*base, zero )
728  d1 = zero
729  DO 20 i = 1, base
730  d1 = d1 + b1
731  20 CONTINUE
732  b2 = dlamc3( a*rbase, zero )
733  c2 = dlamc3( b2 / rbase, zero )
734  d2 = zero
735  DO 30 i = 1, base
736  d2 = d2 + b2
737  30 CONTINUE
738  GO TO 10
739  END IF
740 *+ END WHILE
741 *
742  RETURN
743 *
744 * End of DLAMC4
745 *
746  END
747 *
748 ************************************************************************
749 *> \brief \b DLAMC5
750 *> \details
751 *> \b Purpose:
752 *> \verbatim
753 *> DLAMC5 attempts to compute RMAX, the largest machine floating-point
754 *> number, without overflow. It assumes that EMAX + abs(EMIN) sum
755 *> approximately to a power of 2. It will fail on machines where this
756 *> assumption does not hold, for example, the Cyber 205 (EMIN = -28625,
757 *> EMAX = 28718). It will also fail if the value supplied for EMIN is
758 *> too large (i.e. too close to zero), probably with overflow.
759 *> \endverbatim
760 *>
761 *> \param[in] BETA
762 *> \verbatim
763 *> The base of floating-point arithmetic.
764 *> \endverbatim
765 *>
766 *> \param[in] P
767 *> \verbatim
768 *> The number of base BETA digits in the mantissa of a
769 *> floating-point value.
770 *> \endverbatim
771 *>
772 *> \param[in] EMIN
773 *> \verbatim
774 *> The minimum exponent before (gradual) underflow.
775 *> \endverbatim
776 *>
777 *> \param[in] IEEE
778 *> \verbatim
779 *> A logical flag specifying whether or not the arithmetic
780 *> system is thought to comply with the IEEE standard.
781 *> \endverbatim
782 *>
783 *> \param[out] EMAX
784 *> \verbatim
785 *> The largest exponent before overflow
786 *> \endverbatim
787 *>
788 *> \param[out] RMAX
789 *> \verbatim
790 *> The largest machine floating-point number.
791 *> \endverbatim
792 *>
793 *> \ingroup lamc5
794 *>
795  SUBROUTINE dlamc5( BETA, P, EMIN, IEEE, EMAX, RMAX )
796 *
797 * -- LAPACK auxiliary routine --
798 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
799 *
800 * .. Scalar Arguments ..
801  LOGICAL IEEE
802  INTEGER BETA, EMAX, EMIN, P
803  DOUBLE PRECISION RMAX
804 * ..
805 * =====================================================================
806 *
807 * .. Parameters ..
808  DOUBLE PRECISION ZERO, ONE
809  parameter( zero = 0.0d0, one = 1.0d0 )
810 * ..
811 * .. Local Scalars ..
812  INTEGER EXBITS, EXPSUM, I, LEXP, NBITS, TRY, UEXP
813  DOUBLE PRECISION OLDY, RECBAS, Y, Z
814 * ..
815 * .. External Functions ..
816  DOUBLE PRECISION DLAMC3
817  EXTERNAL dlamc3
818 * ..
819 * .. Intrinsic Functions ..
820  INTRINSIC mod
821 * ..
822 * .. Executable Statements ..
823 *
824 * First compute LEXP and UEXP, two powers of 2 that bound
825 * abs(EMIN). We then assume that EMAX + abs(EMIN) will sum
826 * approximately to the bound that is closest to abs(EMIN).
827 * (EMAX is the exponent of the required number RMAX).
828 *
829  lexp = 1
830  exbits = 1
831  10 CONTINUE
832  try = lexp*2
833  IF( try.LE.( -emin ) ) THEN
834  lexp = try
835  exbits = exbits + 1
836  GO TO 10
837  END IF
838  IF( lexp.EQ.-emin ) THEN
839  uexp = lexp
840  ELSE
841  uexp = try
842  exbits = exbits + 1
843  END IF
844 *
845 * Now -LEXP is less than or equal to EMIN, and -UEXP is greater
846 * than or equal to EMIN. EXBITS is the number of bits needed to
847 * store the exponent.
848 *
849  IF( ( uexp+emin ).GT.( -lexp-emin ) ) THEN
850  expsum = 2*lexp
851  ELSE
852  expsum = 2*uexp
853  END IF
854 *
855 * EXPSUM is the exponent range, approximately equal to
856 * EMAX - EMIN + 1 .
857 *
858  emax = expsum + emin - 1
859  nbits = 1 + exbits + p
860 *
861 * NBITS is the total number of bits needed to store a
862 * floating-point number.
863 *
864  IF( ( mod( nbits, 2 ).EQ.1 ) .AND. ( beta.EQ.2 ) ) THEN
865 *
866 * Either there are an odd number of bits used to store a
867 * floating-point number, which is unlikely, or some bits are
868 * not used in the representation of numbers, which is possible,
869 * (e.g. Cray machines) or the mantissa has an implicit bit,
870 * (e.g. IEEE machines, Dec Vax machines), which is perhaps the
871 * most likely. We have to assume the last alternative.
872 * If this is true, then we need to reduce EMAX by one because
873 * there must be some way of representing zero in an implicit-bit
874 * system. On machines like Cray, we are reducing EMAX by one
875 * unnecessarily.
876 *
877  emax = emax - 1
878  END IF
879 *
880  IF( ieee ) THEN
881 *
882 * Assume we are on an IEEE machine which reserves one exponent
883 * for infinity and NaN.
884 *
885  emax = emax - 1
886  END IF
887 *
888 * Now create RMAX, the largest machine number, which should
889 * be equal to (1.0 - BETA**(-P)) * BETA**EMAX .
890 *
891 * First compute 1.0 - BETA**(-P), being careful that the
892 * result is less than 1.0 .
893 *
894  recbas = one / beta
895  z = beta - one
896  y = zero
897  DO 20 i = 1, p
898  z = z*recbas
899  IF( y.LT.one )
900  $ oldy = y
901  y = dlamc3( y, z )
902  20 CONTINUE
903  IF( y.GE.one )
904  $ y = oldy
905 *
906 * Now multiply by BETA**EMAX to get RMAX.
907 *
908  DO 30 i = 1, emax
909  y = dlamc3( y*beta, zero )
910  30 CONTINUE
911 *
912  rmax = y
913  RETURN
914 *
915 * End of DLAMC5
916 *
917  END
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine dlamc5(BETA, P, EMIN, IEEE, EMAX, RMAX)
DLAMC5
Definition: dlamchf77.f:796
subroutine dlamc2(BETA, T, RND, EPS, EMIN, RMIN, EMAX, RMAX)
DLAMC2
Definition: dlamchf77.f:419
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:69
subroutine dlamc4(EMIN, START, BASE)
DLAMC4
Definition: dlamchf77.f:689
double precision function dlamc3(A, B)
DLAMC3
Definition: dlamch.f:172
subroutine dlamc1(BETA, T, RND, IEEE1)
DLAMC1
Definition: dlamchf77.f:208