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

◆ slamc5()

subroutine slamc5 ( integer  beta,
integer  p,
integer  emin,
logical  ieee,
integer  emax,
real  rmax 
)

Definition at line 1564 of file tools.f.

1565*
1566* -- LAPACK auxiliary routine (version 2.0) --
1567* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
1568* Courant Institute, Argonne National Lab, and Rice University
1569* October 31, 1992
1570*
1571* .. Scalar Arguments ..
1572 LOGICAL IEEE
1573 INTEGER BETA, EMAX, EMIN, P
1574 REAL RMAX
1575* ..
1576*
1577* Purpose
1578* =======
1579*
1580* SLAMC5 attempts to compute RMAX, the largest machine floating-point
1581* number, without overflow. It assumes that EMAX + abs(EMIN) sum
1582* approximately to a power of 2. It will fail on machines where this
1583* assumption does not hold, for example, the Cyber 205 (EMIN = -28625,
1584* EMAX = 28718). It will also fail if the value supplied for EMIN is
1585* too large (i.e. too close to zero), probably with overflow.
1586*
1587* Arguments
1588* =========
1589*
1590* BETA (input) INTEGER
1591* The base of floating-point arithmetic.
1592*
1593* P (input) INTEGER
1594* The number of base BETA digits in the mantissa of a
1595* floating-point value.
1596*
1597* EMIN (input) INTEGER
1598* The minimum exponent before (gradual) underflow.
1599*
1600* IEEE (input) LOGICAL
1601* A logical flag specifying whether or not the arithmetic
1602* system is thought to comply with the IEEE standard.
1603*
1604* EMAX (output) INTEGER
1605* The largest exponent before overflow
1606*
1607* RMAX (output) REAL
1608* The largest machine floating-point number.
1609*
1610* =====================================================================
1611*
1612* .. Parameters ..
1613 REAL ZERO, ONE
1614 parameter( zero = 0.0e0, one = 1.0e0 )
1615* ..
1616* .. Local Scalars ..
1617 INTEGER EXBITS, EXPSUM, I, LEXP, NBITS, TRY, UEXP
1618 REAL OLDY, RECBAS, Y, Z
1619* ..
1620* .. External Functions ..
1621 REAL SLAMC3
1622 EXTERNAL slamc3
1623* ..
1624* .. Intrinsic Functions ..
1625 INTRINSIC mod
1626* ..
1627* .. Executable Statements ..
1628*
1629* First compute LEXP and UEXP, two powers of 2 that bound
1630* abs(EMIN). We then assume that EMAX + abs(EMIN) will sum
1631* approximately to the bound that is closest to abs(EMIN).
1632* (EMAX is the exponent of the required number RMAX).
1633*
1634 lexp = 1
1635 exbits = 1
1636 10 CONTINUE
1637 try = lexp*2
1638 IF( try.LE.( -emin ) ) THEN
1639 lexp = try
1640 exbits = exbits + 1
1641 GO TO 10
1642 END IF
1643 IF( lexp.EQ.-emin ) THEN
1644 uexp = lexp
1645 ELSE
1646 uexp = try
1647 exbits = exbits + 1
1648 END IF
1649*
1650* Now -LEXP is less than or equal to EMIN, and -UEXP is greater
1651* than or equal to EMIN. EXBITS is the number of bits needed to
1652* store the exponent.
1653*
1654 IF( ( uexp+emin ).GT.( -lexp-emin ) ) THEN
1655 expsum = 2*lexp
1656 ELSE
1657 expsum = 2*uexp
1658 END IF
1659*
1660* EXPSUM is the exponent range, approximately equal to
1661* EMAX - EMIN + 1 .
1662*
1663 emax = expsum + emin - 1
1664 nbits = 1 + exbits + p
1665*
1666* NBITS is the total number of bits needed to store a
1667* floating-point number.
1668*
1669 IF( ( mod( nbits, 2 ).EQ.1 ) .AND. ( beta.EQ.2 ) ) THEN
1670*
1671* Either there are an odd number of bits used to store a
1672* floating-point number, which is unlikely, or some bits are
1673* not used in the representation of numbers, which is possible,
1674* (e.g. Cray machines) or the mantissa has an implicit bit,
1675* (e.g. IEEE machines, Dec Vax machines), which is perhaps the
1676* most likely. We have to assume the last alternative.
1677* If this is true, then we need to reduce EMAX by one because
1678* there must be some way of representing zero in an implicit-bit
1679* system. On machines like Cray, we are reducing EMAX by one
1680* unnecessarily.
1681*
1682 emax = emax - 1
1683 END IF
1684*
1685 IF( ieee ) THEN
1686*
1687* Assume we are on an IEEE machine which reserves one exponent
1688* for infinity and NaN.
1689*
1690 emax = emax - 1
1691 END IF
1692*
1693* Now create RMAX, the largest machine number, which should
1694* be equal to (1.0 - BETA**(-P)) * BETA**EMAX .
1695*
1696* First compute 1.0 - BETA**(-P), being careful that the
1697* result is less than 1.0 .
1698*
1699 recbas = one / beta
1700 z = beta - one
1701 y = zero
1702 DO 20 i = 1, p
1703 z = z*recbas
1704 IF( y.LT.one )
1705 $ oldy = y
1706 y = slamc3( y, z )
1707 20 CONTINUE
1708 IF( y.GE.one )
1709 $ y = oldy
1710*
1711* Now multiply by BETA**EMAX to get RMAX.
1712*
1713 DO 30 i = 1, emax
1714 y = slamc3( y*beta, zero )
1715 30 CONTINUE
1716*
1717 rmax = y
1718 RETURN
1719*
1720* End of SLAMC5
1721*
real function slamc3(a, b)
Definition tools.f:1443
Here is the caller graph for this function: