


      MMMMAAAATTTTHHHHEEEERRRRRRRR((((3333MMMM))))                 ((((UUUUNNNNIIIIXXXX 5555....0000))))                MMMMAAAATTTTHHHHEEEERRRRRRRR((((3333MMMM))))



      NNNNAAAAMMMMEEEE
           matherr - error-handling function

      SSSSYYYYNNNNTTTTAAAAXXXX
           ####iiiinnnncccclllluuuuddddeeee <<<<mmmmaaaatttthhhh....hhhh>>>>

           iiiinnnntttt mmmmaaaatttthhhheeeerrrrrrrr ((((xxxx))))
           ssssttttrrrruuuucccctttt eeeexxxxcccceeeeppppttttiiiioooonnnn ****xxxx;;;;

      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
           _M_a_t_h_e_r_r is invoked by functions in the Math Library when
           errors are detected.  Users may define their own procedures
           for handling errors by including a function named _m_a_t_h_e_r_r in
           their programs.  _M_a_t_h_e_r_r must be of the form described
           above.  A pointer to the exception structure _x will be
           passed to the user-supplied _m_a_t_h_e_r_r function when an error
           occurs.  This structure, which is defined in the <_m_a_t_h._h>
           header file, is as follows:

                struct exception {
                     int type;
                     char *name;
                     double arg1, arg2, retval;
                };

           The element _t_y_p_e is an integer describing the type of error
           that has occurred, from the following list of constants
           (defined in the header file):

                DOMAIN     domain error
                SING       singularity
                OVERFLOW   overflow
                UNDERFLOW  underflow
                TLOSS      total loss of significance
                PLOSS      partial loss of significance

           The element _n_a_m_e points to a string containing the name of
           the function that had the error.  The variables _a_r_g_1 and
           _a_r_g_2 are the arguments to the function that had the error.
           _R_e_t_v_a_l is a double that is returned by the function having
           the error.  If it supplies a return value, the user's
           _m_a_t_h_e_r_r must return non-zero.  If the default error value is
           to be returned, the user's _m_a_t_h_e_r_r must return 0.

           If _m_a_t_h_e_r_r is not supplied by the user, the default error-
           handling procedures, described with the math functions
           involved, will be invoked upon error.  These procedures are
           also summarized in the table below.  In every case, _e_r_r_n_o is
           set to non-zero and the program continues.

      EEEEXXXXAAAAMMMMPPPPLLLLEEEE
           matherr(x)



      Page 1                                                   (9010-E)






      MMMMAAAATTTTHHHHEEEERRRRRRRR((((3333MMMM))))                 ((((UUUUNNNNIIIIXXXX 5555....0000))))                MMMMAAAATTTTHHHHEEEERRRRRRRR((((3333MMMM))))



           register struct exception *x;
           {
                switch (x->type) {
                case DOMAIN:
                case SING: /* print message and abort */
                     fprintf(stderr, "domain error in %s\n", x->name);
                     abort( );
                case OVERFLOW:
                     if (!strcmp("exp", x->name)) {
                          /* if exp, print message, return the argument */
                          fprintf(stderr, "exp of %f\n", x->arg1);
                          x->retval = x->arg1;
                     } else if (!strcmp("sinh", x->name)) {
                          /* if sinh, set errno, return 0 */
                          errno = ERANGE;
                          x->retval = 0;
                     } else
                          /* otherwise, return HUGE */
                          x->retval = HUGE;
                     break;
                case UNDERFLOW:
                     return (0); /* execute default procedure */
                case TLOSS:
                case PLOSS:
                     /* print message and return 0 */
                     fprintf(stderr, "loss of significance in %s\n", x->name);
                     x->retval = 0;
                     break;
                }
                return (1);
           }
























      Page 2                                                   (9010-E)






      MMMMAAAATTTTHHHHEEEERRRRRRRR((((3333MMMM))))                 ((((UUUUNNNNIIIIXXXX 5555....0000))))                MMMMAAAATTTTHHHHEEEERRRRRRRR((((3333MMMM))))



8      _________________________________________________________________
                     DDDDEEEEFFFFAAAAUUUULLLLTTTT EEEERRRRRRRROOOORRRR HHHHAAAANNNNDDDDLLLLIIIINNNNGGGG PPPPRRRROOOOCCCCEEEEDDDDUUUURRRREEEESSSS
8      _________________________________________________________________
                                      _T_y_p_e_s _o_f _E_r_r_o_r_s
8      _________________________________________________________________
                     DOMAIN  SING   OVERFLOW  UNDERFLOW   TLOSS  PLOSS
8      _________________________________________________________________
      BESSEL:          -      -         H         0         -      *
      y0, y1, yn     M, -H    -         -         -         -      -
       (neg. no.)
8      _________________________________________________________________
      EXP:             -      -         H         0         -
8      _________________________________________________________________
      POW:             -      -         H         0         -      -
      (neg.)**(non-  M, 0     -         -         -         -      -
       int.), 0**0
8      _________________________________________________________________
      LOG:
      log(0):          -    M, -H       -         -         -      -
      log(neg.):      M, -H   -         -         -         -      -
8      _________________________________________________________________
      SQRT:           M, 0    -         -         -         -      -
8      _________________________________________________________________
      GAMMA:           -     M, H       -         -         -      -
8      _________________________________________________________________
      HYPOT:           -      -         H         -         -      -
8      _________________________________________________________________
      SINH, COSH:      -      -         H         -         -      -
8      _________________________________________________________________
      SIN, COS:        -      -         -         -        M, 0  M, *
8      _________________________________________________________________
      TAN:             -      -         H         -         0      *
8      _________________________________________________________________
      ACOS, ASIN:     M, 0    -         -         -         -      -
8      _________________________________________________________________
7      |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|

























                    |8|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|























9                            |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|






















                                   |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|






















                                              |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|






















                                                         |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|






















                                                                 |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|






















                                                                       |7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|7|



























8           _____________________________________________________
                               AAAABBBBBBBBRRRREEEEVVVVIIIIAAAATTTTIIIIOOOONNNNSSSS
             *    As much as possible of the value is returned.
             M    Message is printed.
             H    HUGE is returned.
             -H   -HUGE is returned.
             0    0 is returned.
8           _____________________________________________________
7           |8|7|7|7|7|7|




9                                                                |8|7|7|7|7|7|






9














9


      Page 3                                                   (9010-E)



