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 699 of file dlamch.f.

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