github.com/gopherd/gonum@v0.0.4/mathext/internal/amos/amoslib/d1mach.f (about)

     1  *DECK D1MACH
     2        DOUBLE PRECISION FUNCTION D1MACH(I)
     3  C***BEGIN PROLOGUE  D1MACH
     4  C***DATE WRITTEN   750101   (YYMMDD)
     5  C***REVISION DATE  890213   (YYMMDD)
     6  C***CATEGORY NO.  R1
     7  C***KEYWORDS  LIBRARY=SLATEC,TYPE=DOUBLE PRECISION(R1MACH-S D1MACH-D),
     8  C             MACHINE CONSTANTS
     9  C***AUTHOR  FOX, P. A., (BELL LABS)
    10  C           HALL, A. D., (BELL LABS)
    11  C           SCHRYER, N. L., (BELL LABS)
    12  C***PURPOSE  Returns double precision machine dependent constants
    13  C***DESCRIPTION
    14  C
    15  C   D1MACH can be used to obtain machine-dependent parameters
    16  C   for the local machine environment.  It is a function
    17  C   subprogram with one (input) argument, and can be called
    18  C   as follows, for example
    19  C
    20  C        D = D1MACH(I)
    21  C
    22  C   where I=1,...,5.  The (output) value of D above is
    23  C   determined by the (input) value of I.  The results for
    24  C   various values of I are discussed below.
    25  C
    26  C   D1MACH( 1) = B**(EMIN-1), the smallest positive magnitude.
    27  C   D1MACH( 2) = B**EMAX*(1 - B**(-T)), the largest magnitude.
    28  C   D1MACH( 3) = B**(-T), the smallest relative spacing.
    29  C   D1MACH( 4) = B**(1-T), the largest relative spacing.
    30  C   D1MACH( 5) = LOG10(B)
    31  C
    32  C   Assume double precision numbers are represented in the T-digit,
    33  C   base-B form
    34  C
    35  C              sign (B**E)*( (X(1)/B) + ... + (X(T)/B**T) )
    36  C
    37  C   where 0 .LE. X(I) .LT. B for I=1,...,T, 0 .LT. X(1), and
    38  C   EMIN .LE. E .LE. EMAX.
    39  C
    40  C   The values of B, T, EMIN and EMAX are provided in I1MACH as
    41  C   follows:
    42  C   I1MACH(10) = B, the base.
    43  C   I1MACH(14) = T, the number of base-B digits.
    44  C   I1MACH(15) = EMIN, the smallest exponent E.
    45  C   I1MACH(16) = EMAX, the largest exponent E.
    46  C
    47  C   To alter this function for a particular environment,
    48  C   the desired set of DATA statements should be activated by
    49  C   removing the C from column 1.  Also, the values of
    50  C   D1MACH(1) - D1MACH(4) should be checked for consistency
    51  C   with the local operating system.
    52  C
    53  C***REFERENCES  FOX P.A., HALL A.D., SCHRYER N.L.,*FRAMEWORK FOR A
    54  C                 PORTABLE LIBRARY*, ACM TRANSACTIONS ON MATHEMATICAL
    55  C                 SOFTWARE, VOL. 4, NO. 2, JUNE 1978, PP. 177-188.
    56  C***ROUTINES CALLED  XERROR
    57  C***END PROLOGUE  D1MACH
    58  C
    59        INTEGER SMALL(4)
    60        INTEGER LARGE(4)
    61        INTEGER RIGHT(4)
    62        INTEGER DIVER(4)
    63        INTEGER LOG10(4)
    64  C
    65        DOUBLE PRECISION DMACH(5)
    66        SAVE DMACH
    67  C
    68  C      EQUIVALENCE (DMACH(1),SMALL(1))
    69  C      EQUIVALENCE (DMACH(2),LARGE(1))
    70  C      EQUIVALENCE (DMACH(3),RIGHT(1))
    71  C      EQUIVALENCE (DMACH(4),DIVER(1))
    72  C      EQUIVALENCE (DMACH(5),LOG10(1))
    73  C
    74  C     MACHINE CONSTANTS FOR THE IBM PC
    75  C     ASSUMES THAT ALL ARITHMETIC IS DONE IN DOUBLE PRECISION
    76  C     ON 8088, I.E., NOT IN 80 BIT FORM FOR THE 8087.
    77  C
    78        DATA DMACH(1) / 2.23D-308 /
    79  C      DATA SMALL(1),SMALL(2) /  2002288515,    1050897 /
    80        DATA DMACH(2) / 1.79D-308 /
    81  C      DATA LARGE(1),LARGE(2) /  1487780761, 2146426097 /
    82        DATA DMACH(3) / 1.11D-16 /
    83  C      DATA RIGHT(1),RIGHT(2) / -1209488034, 1017118298 /
    84        DATA DMACH(4) / 2.22D-16 /
    85  C      DATA DIVER(1),DIVER(2) / -1209488034, 1018166874 /
    86        DATA DMACH(5) / 0.3010299956639812 /
    87  C      DATA LOG10(1),LOG10(2) /  1352628735, 1070810131 /
    88  C
    89  C
    90  C***FIRST EXECUTABLE STATEMENT  D1MACH
    91        IF (I .LT. 1  .OR.  I .GT. 5)
    92       1   CALL XERROR ('D1MACH -- I OUT OF BOUNDS', 25, 1, 2)
    93  C
    94        D1MACH = DMACH(I)
    95        RETURN
    96  C
    97        END