summaryrefslogtreecommitdiff
path: root/test/math/mtherr.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-10-02 10:45:16 +0000
committerEric Andersen <andersen@codepoet.org>2001-10-02 10:45:16 +0000
commitf108799afa9b1d207e7139608c261f5546eb56bf (patch)
treeb84ad7a12eb961ca185c83b45098d5fc23ecd1ae /test/math/mtherr.c
parent04dafe547980c50bef57b3ea7a4f9e3d81400a87 (diff)
Add in some math lib tests
Diffstat (limited to 'test/math/mtherr.c')
-rw-r--r--test/math/mtherr.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/test/math/mtherr.c b/test/math/mtherr.c
new file mode 100644
index 000000000..de6d81b94
--- /dev/null
+++ b/test/math/mtherr.c
@@ -0,0 +1,96 @@
+/* mtherr.c
+ *
+ * Library common error handling routine
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * char *fctnam;
+ * int code;
+ * void 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
+by Stephen L. Moshier
+Direct inquiries to 30 Frost Street, Cambridge, MA 02140
+*/
+
+#include "mconf.h"
+
+/* Notice: the order of appearance of the following
+ * messages is bound to the error codes defined
+ * in mconf.h.
+ */
+static char *ermsg[7] = {
+"unknown", /* error code 0 */
+"domain", /* error code 1 */
+"singularity", /* et seq. */
+"overflow",
+"underflow",
+"total loss of precision",
+"partial loss of precision"
+};
+
+
+
+void mtherr( name, code )
+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:
+ */
+printf( "\n%s ", name );
+
+/* Display error message defined
+ * by the code argument.
+ */
+if( (code <= 0) || (code >= 6) )
+ code = 0;
+printf( "%s error\n", ermsg[code] );
+
+/* Return to calling
+ * program
+ */
+}