LAPACK  3.9.0
LAPACK: Linear Algebra PACKage

◆ dlamc5()

subroutine dlamc5 ( integer  BETA,
integer  P,
integer  EMIN,
logical  IEEE,
integer  EMAX,
double precision  RMAX 
)

DLAMC5

Purpose:

 DLAMC5 attempts to compute RMAX, the largest machine floating-point
 number, without overflow.  It assumes that EMAX + abs(EMIN) sum
 approximately to a power of 2.  It will fail on machines where this
 assumption does not hold, for example, the Cyber 205 (EMIN = -28625,
 EMAX = 28718).  It will also fail if the value supplied for EMIN is
 too large (i.e. too close to zero), probably with overflow.
Parameters
[in]BETA
          The base of floating-point arithmetic.
[in]P
          The number of base BETA digits in the mantissa of a
          floating-point value.
[in]EMIN
          The minimum exponent before (gradual) underflow.
[in]IEEE
          A logical flag specifying whether or not the arithmetic
          system is thought to comply with the IEEE standard.
[out]EMAX
          The largest exponent before overflow
[out]RMAX
          The largest machine floating-point number.

Definition at line 801 of file dlamchf77.f.

801 *
802 * -- LAPACK auxiliary routine (version 3.7.0) --
803 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
804 * November 2010
805 *
806 * .. Scalar Arguments ..
807  LOGICAL IEEE
808  INTEGER BETA, EMAX, EMIN, P
809  DOUBLE PRECISION RMAX
810 * ..
811 * =====================================================================
812 *
813 * .. Parameters ..
814  DOUBLE PRECISION ZERO, ONE
815  parameter( zero = 0.0d0, one = 1.0d0 )
816 * ..
817 * .. Local Scalars ..
818  INTEGER EXBITS, EXPSUM, I, LEXP, NBITS, TRY, UEXP
819  DOUBLE PRECISION OLDY, RECBAS, Y, Z
820 * ..
821 * .. External Functions ..
822  DOUBLE PRECISION DLAMC3
823  EXTERNAL dlamc3
824 * ..
825 * .. Intrinsic Functions ..
826  INTRINSIC mod
827 * ..
828 * .. Executable Statements ..
829 *
830 * First compute LEXP and UEXP, two powers of 2 that bound
831 * abs(EMIN). We then assume that EMAX + abs(EMIN) will sum
832 * approximately to the bound that is closest to abs(EMIN).
833 * (EMAX is the exponent of the required number RMAX).
834 *
835  lexp = 1
836  exbits = 1
837  10 CONTINUE
838  try = lexp*2
839  IF( try.LE.( -emin ) ) THEN
840  lexp = try
841  exbits = exbits + 1
842  GO TO 10
843  END IF
844  IF( lexp.EQ.-emin ) THEN
845  uexp = lexp
846  ELSE
847  uexp = try
848  exbits = exbits + 1
849  END IF
850 *
851 * Now -LEXP is less than or equal to EMIN, and -UEXP is greater
852 * than or equal to EMIN. EXBITS is the number of bits needed to
853 * store the exponent.
854 *
855  IF( ( uexp+emin ).GT.( -lexp-emin ) ) THEN
856  expsum = 2*lexp
857  ELSE
858  expsum = 2*uexp
859  END IF
860 *
861 * EXPSUM is the exponent range, approximately equal to
862 * EMAX - EMIN + 1 .
863 *
864  emax = expsum + emin - 1
865  nbits = 1 + exbits + p
866 *
867 * NBITS is the total number of bits needed to store a
868 * floating-point number.
869 *
870  IF( ( mod( nbits, 2 ).EQ.1 ) .AND. ( beta.EQ.2 ) ) THEN
871 *
872 * Either there are an odd number of bits used to store a
873 * floating-point number, which is unlikely, or some bits are
874 * not used in the representation of numbers, which is possible,
875 * (e.g. Cray machines) or the mantissa has an implicit bit,
876 * (e.g. IEEE machines, Dec Vax machines), which is perhaps the
877 * most likely. We have to assume the last alternative.
878 * If this is true, then we need to reduce EMAX by one because
879 * there must be some way of representing zero in an implicit-bit
880 * system. On machines like Cray, we are reducing EMAX by one
881 * unnecessarily.
882 *
883  emax = emax - 1
884  END IF
885 *
886  IF( ieee ) THEN
887 *
888 * Assume we are on an IEEE machine which reserves one exponent
889 * for infinity and NaN.
890 *
891  emax = emax - 1
892  END IF
893 *
894 * Now create RMAX, the largest machine number, which should
895 * be equal to (1.0 - BETA**(-P)) * BETA**EMAX .
896 *
897 * First compute 1.0 - BETA**(-P), being careful that the
898 * result is less than 1.0 .
899 *
900  recbas = one / beta
901  z = beta - one
902  y = zero
903  DO 20 i = 1, p
904  z = z*recbas
905  IF( y.LT.one )
906  $ oldy = y
907  y = dlamc3( y, z )
908  20 CONTINUE
909  IF( y.GE.one )
910  $ y = oldy
911 *
912 * Now multiply by BETA**EMAX to get RMAX.
913 *
914  DO 30 i = 1, emax
915  y = dlamc3( y*beta, zero )
916  30 CONTINUE
917 *
918  rmax = y
919  RETURN
920 *
921 * End of DLAMC5
922 *
Here is the caller graph for this function:
dlamc3
double precision function dlamc3(A, B)
DLAMC3
Definition: dlamch.f:174