SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ dlamc5()

subroutine dlamc5 ( integer  beta,
integer  p,
integer  emin,
logical  ieee,
integer  emax,
double precision  rmax 
)

Definition at line 707 of file tools.f.

708*
709* -- LAPACK auxiliary routine (version 2.0) --
710* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
711* Courant Institute, Argonne National Lab, and Rice University
712* October 31, 1992
713*
714* .. Scalar Arguments ..
715 LOGICAL IEEE
716 INTEGER BETA, EMAX, EMIN, P
717 DOUBLE PRECISION RMAX
718* ..
719*
720* Purpose
721* =======
722*
723* DLAMC5 attempts to compute RMAX, the largest machine floating-point
724* number, without overflow. It assumes that EMAX + abs(EMIN) sum
725* approximately to a power of 2. It will fail on machines where this
726* assumption does not hold, for example, the Cyber 205 (EMIN = -28625,
727* EMAX = 28718). It will also fail if the value supplied for EMIN is
728* too large (i.e. too close to zero), probably with overflow.
729*
730* Arguments
731* =========
732*
733* BETA (input) INTEGER
734* The base of floating-point arithmetic.
735*
736* P (input) INTEGER
737* The number of base BETA digits in the mantissa of a
738* floating-point value.
739*
740* EMIN (input) INTEGER
741* The minimum exponent before (gradual) underflow.
742*
743* IEEE (input) LOGICAL
744* A logical flag specifying whether or not the arithmetic
745* system is thought to comply with the IEEE standard.
746*
747* EMAX (output) INTEGER
748* The largest exponent before overflow
749*
750* RMAX (output) DOUBLE PRECISION
751* The largest machine floating-point number.
752*
753* =====================================================================
754*
755* .. Parameters ..
756 DOUBLE PRECISION ZERO, ONE
757 parameter( zero = 0.0d0, one = 1.0d0 )
758* ..
759* .. Local Scalars ..
760 INTEGER EXBITS, EXPSUM, I, LEXP, NBITS, TRY, UEXP
761 DOUBLE PRECISION OLDY, RECBAS, Y, Z
762* ..
763* .. External Functions ..
764 DOUBLE PRECISION DLAMC3
765 EXTERNAL dlamc3
766* ..
767* .. Intrinsic Functions ..
768 INTRINSIC mod
769* ..
770* .. Executable Statements ..
771*
772* First compute LEXP and UEXP, two powers of 2 that bound
773* abs(EMIN). We then assume that EMAX + abs(EMIN) will sum
774* approximately to the bound that is closest to abs(EMIN).
775* (EMAX is the exponent of the required number RMAX).
776*
777 lexp = 1
778 exbits = 1
779 10 CONTINUE
780 try = lexp*2
781 IF( try.LE.( -emin ) ) THEN
782 lexp = try
783 exbits = exbits + 1
784 GO TO 10
785 END IF
786 IF( lexp.EQ.-emin ) THEN
787 uexp = lexp
788 ELSE
789 uexp = try
790 exbits = exbits + 1
791 END IF
792*
793* Now -LEXP is less than or equal to EMIN, and -UEXP is greater
794* than or equal to EMIN. EXBITS is the number of bits needed to
795* store the exponent.
796*
797 IF( ( uexp+emin ).GT.( -lexp-emin ) ) THEN
798 expsum = 2*lexp
799 ELSE
800 expsum = 2*uexp
801 END IF
802*
803* EXPSUM is the exponent range, approximately equal to
804* EMAX - EMIN + 1 .
805*
806 emax = expsum + emin - 1
807 nbits = 1 + exbits + p
808*
809* NBITS is the total number of bits needed to store a
810* floating-point number.
811*
812 IF( ( mod( nbits, 2 ).EQ.1 ) .AND. ( beta.EQ.2 ) ) THEN
813*
814* Either there are an odd number of bits used to store a
815* floating-point number, which is unlikely, or some bits are
816* not used in the representation of numbers, which is possible,
817* (e.g. Cray machines) or the mantissa has an implicit bit,
818* (e.g. IEEE machines, Dec Vax machines), which is perhaps the
819* most likely. We have to assume the last alternative.
820* If this is true, then we need to reduce EMAX by one because
821* there must be some way of representing zero in an implicit-bit
822* system. On machines like Cray, we are reducing EMAX by one
823* unnecessarily.
824*
825 emax = emax - 1
826 END IF
827*
828 IF( ieee ) THEN
829*
830* Assume we are on an IEEE machine which reserves one exponent
831* for infinity and NaN.
832*
833 emax = emax - 1
834 END IF
835*
836* Now create RMAX, the largest machine number, which should
837* be equal to (1.0 - BETA**(-P)) * BETA**EMAX .
838*
839* First compute 1.0 - BETA**(-P), being careful that the
840* result is less than 1.0 .
841*
842 recbas = one / beta
843 z = beta - one
844 y = zero
845 DO 20 i = 1, p
846 z = z*recbas
847 IF( y.LT.one )
848 $ oldy = y
849 y = dlamc3( y, z )
850 20 CONTINUE
851 IF( y.GE.one )
852 $ y = oldy
853*
854* Now multiply by BETA**EMAX to get RMAX.
855*
856 DO 30 i = 1, emax
857 y = dlamc3( y*beta, zero )
858 30 CONTINUE
859*
860 rmax = y
861 RETURN
862*
863* End of DLAMC5
864*
double precision function dlamc3(a, b)
Definition tools.f:586
Here is the caller graph for this function: