File: mtherr.c

package info (click to toggle)
python-scipy 0.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 52,228 kB
  • ctags: 63,719
  • sloc: python: 112,726; fortran: 88,685; cpp: 86,979; ansic: 85,860; makefile: 530; sh: 236
file content (112 lines) | stat: -rw-r--r-- 2,733 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*                                                     mtherr.c
 *
 *     Library common error handling routine
 *
 *
 *
 * SYNOPSIS:
 *
 * char *fctnam;
 * int code;
 * int mtherr();
 *
 * mtherr( fctnam, code );
 *
 *
 *
 * DESCRIPTION:
 *
 * This routine may be called to report one of the following
 * error conditions (in the include file mconf.h).
 *  
 *   Mnemonic        Value          Significance
 *
 *    DOMAIN            1       argument domain error
 *    SING              2       function singularity
 *    OVERFLOW          3       overflow range error
 *    UNDERFLOW         4       underflow range error
 *    TLOSS             5       total loss of precision
 *    PLOSS             6       partial loss of precision
 *    EDOM             33       Unix domain error code
 *    ERANGE           34       Unix range error code
 *
 * The default version of the file prints the function name,
 * passed to it by the pointer fctnam, followed by the
 * error condition.  The display is directed to the standard
 * output device.  The routine then returns to the calling
 * program.  Users may wish to modify the program to abort by
 * calling exit() under severe error conditions such as domain
 * errors.
 *
 * Since all error conditions pass control to this function,
 * the display may be easily changed, eliminated, or directed
 * to an error logging device.
 *
 * SEE ALSO:
 *
 * mconf.h
 *
 */

/*
 * Cephes Math Library Release 2.0:  April, 1987
 * Copyright 1984, 1987 by Stephen L. Moshier
 * Direct inquiries to 30 Frost Street, Cambridge, MA 02140
 */

#include <stdio.h>
#include "mconf.h"

#include "sf_error.h"

int merror = 0;

/* Notice: the order of appearance of the following
 * messages is bound to the error codes defined
 * in mconf.h.
 */
static char *ermsg[8] = {
    "unknown",			/* error code 0 */
    "domain",			/* error code 1 */
    "singularity",		/* et seq.      */
    "overflow",
    "underflow",
    "total loss of precision",
    "partial loss of precision",
    "too many iterations"
};

static sf_error_t conv_to_sf[8] = {
    SF_ERROR_OTHER,
    SF_ERROR_DOMAIN,
    SF_ERROR_SINGULAR,
    SF_ERROR_OVERFLOW,
    SF_ERROR_UNDERFLOW,
    SF_ERROR_NO_RESULT,
    SF_ERROR_LOSS,
    SF_ERROR_SLOW
};

int mtherr(char *name, int code)
{
    /* Display string passed by calling program,
     * which is supposed to be the name of the
     * function in which the error occurred:
     */

    /* Set global error message word */
    merror = code;

    /* Display error message defined
     * by the code argument.
     */
    if ((code <= 0) || (code >= 8))
	code = 0;

    sf_error(name, conv_to_sf[code], NULL);

    /* Return to calling
     * program
     */
    return (0);
}