Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Portable Math Library in C (Part 4 of 6)

5 views
Skip to first unread message

f...@mcdsun.uucp

unread,
Apr 10, 1987, 7:44:27 PM4/10/87
to

This is a portable math library written entirely in C. Since it has been
several years since I had any interest in doing any more work on it, and
people may find it useful, I have decided to post it. There should be
a lead-in posting (part 0 of 6?) containing a README file and commands
to make the directories for the regular parts 1-6. Be sure to read the
README file in 'part 0'.

-Fred Fish

=============== Cut here and feed to the shell ========================

#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 4 (of 6)."
# Contents: doc/header.r funcs/src/exp.c funcs/src/pmlerr.c
# funcs/src/unused/OLDpml.h tests/d2d.dat tests/errors.c
# Wrapped by fnf@mcdsun on Fri Apr 10 16:21:45 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f doc/header.r -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"doc/header.r\"
else
echo shar: Extracting \"doc/header.r\" \(7828 characters\)
sed "s/^X//" >doc/header.r <<'END_OF_doc/header.r'
X.tp
X.(1C
XP M L U S E R S G U I D E
X.sp 2
XP o r t a b l e M a t h L i b r a r y
X.sp 2
XVersion 2.0
X.sp 2
X\*(td
X.sp 4
Xby
X.sp
XFred Fish
X.)1
X.bp
X.sh 1
XINTRODUCTION
X.(x
Xdocument topics
X.)x
X.sh 2
XDocument structure
X.pp
XThis document describes the PML library, a
Xmathematical function library for C programs.
XIt contains the following major sections:
X.(1
XIntroduction to the document (this section).
XA module description section.
XAn index.
X.)1
X.sh 2
XDesign Considerations
X
X.pp
XIn writing this library many tradeoffs had to be considered. The
Xprimary design goal was transportability. It was desired that
Xthe final library be easily transportable among a wide class
Xof machines. As of this release, the library has been used
Xwith only minor modifications on
Xa DECSYSTEM-20 (a 36 bit machine), a VAX-11/780 under compatibility
Xmode, and various PDP-11's.
X
X.pp
XThis portability was achieved by careful isolation of machine
Xdependencies and parameterization of the environment (see references).
XThe only assumption made is that the C compiler can generate proper code for
Xthe four basic operations (+,-,/,*).
X
X.pp
XEven though efficiency
Xwas considered to be of only secondary importance, the final routines
Xcompared favorably with an informal test "race" against the
XDECSYSTEM-20 FORTRAN, which has optimized assembly language
Xlibrary routines. The PML library routines seldom took
Xmore than twice as long as the FORTRAN library, and many were
Xclose enough to call a draw.
X
X.pp
XThere are currently only four highly machine dependent routines in
Xthe Portable Math Library. When transporting the library to a new machine,
Xthese should be the only ones in which recoding is necessary.
XThese routines, written in machine targeted C, are:
X
X.pp
Xdscale --- scale a double precision floating point number by a specified
Xpower of two. Equivalent to multiplication or division
Xby a power of two, depending upon sign of the scale value.
X
X.pp
Xdxexp --- extract exponent of double precision floating point number and
Xreturn it as an integer.
X
X.pp
Xdxmant --- extract mantissa of double precision floating point number and
Xreturn it as a double precision floating point number.
X
X.pp
Xdint --- discard fractional part of double precision number, returning
Xinteger part as a double precision floating point
Xnumber.
X
X.pp
XThe entire Portable Math Library is built upon six "primitives"
Xwhich compute their values from polynomial approximations. All
Xothers can be defined in terms of the primitives using various
Xidentities. The primitives are (1) datan, (2) dexp, (3) dln,
X(4) dsin, (5) dcos, and (6) dsqrt. Strictly speaking, only
Xone of dsin and dcos could be chosen as a primitive and the
Xother defined with an appropriate identity. In this implementation
Xhowever, dsin and dcos call themselves recursively, and each other,
Xto perform range reduction.
X
X.sh 2
XError Handling
X
X.pp
XNo assumptions are made about whether the four basic operations are done by
Xhardware or software. Any overflows or underflows in the basic operations
Xare assumed to be handled by the environment, if at all. Pathological
Xcases in the library routines are trapped internally and control
Xis passed to an error handler routine "pmlerr"
X(which may be replaced with
Xone of the user's choosing) for error recovery.
X
X.pp
XThe default error handler is conceptually similar to the one used by DEC for
Xthe FORTRAN compilers. It contains an internal table which
Xallows various actions to be taken for each error recognized.
XCurrently each error has a corresponding flag word with three
Xbits, each bit assigned as follows:
X
X.pp
XCONTINUE --- If the bit is set control is returned to the calling
Xroutine after completion of error processing. Otherwise
Xthe task exits with an error status.
X
X.pp
XLOG --- If the log bit is set then an error warning message is
Xwritten to the standard error output channel prior to exiting
Xor continuing. If reset, no message is given.
X
X.pp
XCOUNT --- If the count bit is set then the task's PML
Xerror count (internal to the error handler) is incremented.
XIf the total error count exceeds the maximum allowed
Xthen the task exits with
Xerror status. If the count bit is reset then the error
Xis ignored with respect to the error count and exit on limit.
X
X.pp
XThe default conditions in the error handler for all errors
Xis that the CONTINUE, LOG, and COUNT bits are all set. The
Xerror limit is set at 10. These values can be changed by
Xsuitably editing the header file "pml.h"
Xand <pmluser.h>.
X
X.pp
XThe error handler responses can also be changed dynamically
Xvia the following routines:
X
X.pp
XPMLSFS --- Sets the specified bits in the specified error's
Xflag word.
XFor example, "pmlsfs(NEG__DSQRT,CONTINUE | LOG)" sets
Xthe CONTINUE and LOG bits for the "double precision square root
Xof a negative number" error. The COUNT bit is not affected.
XThe manifest constant values are defined in <pmluser.h>.
X
X.pp
XPMLCFS --- Clears the specified bits in the specified error's
Xflag word.
XFor example, "pmlcfs(NEG__DSQRT,CONTINUE | LOG)" clears
Xthe CONTINUE and LOG bits for the "double precision square root
Xof a negative number" error. The COUNT bit is not affected.
XThe manifest constant values are defined in <pmluser.h>.
X
X.pp
XPMLLIM --- Changes the task's PML error limit to
Xthe specified value and returns the previous value.
X
X.pp
XPMLCNT --- Returns the current value of the PML error
Xcount and resets it back to zero.
X
X.sh 2
XFunction Names
X
X.pp
XIn general, FORTRAN naming conventions were followed since no
Xother more obvious convention was apparent. There is one
Xstrong exception however, and that is the natural
Xlogarithm functions use the generic name "ln" while the
Xlogarithm to the base 10 functions use the name "log".
XThis is consistent with the normal usage in virtually all
Xmodern mathematical and engineering texts. How FORTRAN came
Xto use "log" and "log10" respectively is beyond me.
XThis usage has bitten many a starting FORTRAN programmer.
X
X.sh 2
XInstallation
X
X.pp
XAs part of the installation kit, some simple minded testing programs
Xare provided. They are by no means exhaustive tests or ones that
Xcarefully check possible trouble areas. They are intended to
Xprovide a quick and dirty way of verifying that no gross errors
Xare inadvertently incorporated in the library as a result of
Ximprovements or bug fixes, and that the installation is successful.
XFuture releases may incorporate more extensive test routines
Xand suggestions are solicited.
X
X.sh 2
XBugs
X
X.pp
XOn the subject of bugs, all exterminators are encouraged
Xto notify the author of any problems or fixes so that
Xthey can be incorporated into the next release and renegade
Xversions of the library can be minimized.
XContact:
X.sp 2
X.nf
X Fred Fish
X 1346 W 10th Place
X Tempe, Arizona 85281
X.sp 1
X (602) 894-6881 (home)
X (602) 932-7000 (work @ GACA)
X.fi
X.sp 2
X.pp
XThose users with strong numerical analysis backgrounds or experience
Xmay be able to suggest better methods for some of the library routines.
XMany of the higher level routines are simple minded implementations
Xof identities, and may not be nearly as stable as some more obscure
Xmethods.
X
X.sh 2
XTransporting To Other Machines
X
X.pp
XTo transport the Portable Math Library to a processor other than
Xthe PDP11 or DECSYSTEM-20, do the following:
X.(1
XDefine the machine dependent parameters in "pml.h".
XImplement the four machine dependent modules listed previously.
XCompile the rest of the library modules and the testing routines.
XLink and run the testing routines to verify successful installation.
XRepeat as required.
X.)1
X
X.bp
X.sh 1
XRUNTIME MODULES
X
X.pp
XThe PML modules are documented on the following pages.
XAll the rest of this section was produced by the DEX (documentation
Xextractor) utility directly from the source files. Thus
Xthe information reflects the current state of the runtime
Xmodules.
END_OF_doc/header.r
if test 7828 -ne `wc -c <doc/header.r`; then
echo shar: \"doc/header.r\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f funcs/src/exp.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"funcs/src/exp.c\"
else
echo shar: Extracting \"funcs/src/exp.c\" \(5510 characters\)
sed "s/^X//" >funcs/src/exp.c <<'END_OF_funcs/src/exp.c'
X/************************************************************************
X * *
X * N O T I C E *
X * *
X * Copyright Abandoned, 1987, Fred Fish *
X * *
X * This previously copyrighted work has been placed into the *
X * public domain by the author (Fred Fish) and may be freely used *
X * for any purpose, private or commercial. I would appreciate *
X * it, as a courtesy, if this notice is left in all copies and *
X * derivative works. Thank you, and enjoy... *
X * *
X * The author makes no warranty of any kind with respect to this *
X * product and explicitly disclaims any implied warranties of *
X * merchantability or fitness for any particular purpose. *
X * *
X ************************************************************************
X */
X
X
X/*
X * FUNCTION
X *
X * exp double precision exponential
X *
X * KEY WORDS
X *
X * exp
X * machine independent routines
X * math libraries
X *
X * DESCRIPTION
X *
X * Returns double precision exponential of double precision
X * floating point number.
X *
X * USAGE
X *
X * double exp (x)
X * double x;
X *
X * REFERENCES
X *
X * Fortran IV plus user's guide, Digital Equipment Corp. pp B-3
X *
X * Computer Approximations, J.F. Hart et al, John Wiley & Sons,
X * 1968, pp. 96-104.
X *
X * RESTRICTIONS
X *
X * Inputs greater than log(MAXDOUBLE) result in overflow.
X * Inputs less than log(MINDOUBLE) result in underflow.
X *
X * The maximum relative error for the approximating polynomial
X * is 10**(-16.4). However, this assumes exact arithmetic
X * in the polynomial evaluation. Additional rounding and
X * truncation errors may occur as the argument is reduced
X * to the range over which the polynomial approximation
X * is valid, and as the polynomial is evaluated using
X * finite precision arithmetic.
X *
X * PROGRAMMER
X *
X * Fred Fish
X *
X * INTERNALS
X *
X * Computes exponential from:
X *
X * exp(x) = 2**y * 2**z * 2**w
X *
X * Where:
X *
X * y = int ( x * log2(e) )
X *
X * v = 16 * frac ( x * log2(e))
X *
X * z = (1/16) * int (v)
X *
X * w = (1/16) * frac (v)
X *
X * Note that:
X *
X * 0 =< v < 16
X *
X * z = {0, 1/16, 2/16, ...15/16}
X *
X * 0 =< w < 1/16
X *
X * Then:
X *
X * 2**z is looked up in a table of 2**0, 2**1/16, ...
X *
X * 2**w is computed from an approximation:
X *
X * 2**w = (A + B) / (A - B)
X *
X * A = C + (D * w * w)
X *
X * B = w * (E + (F * w * w))
X *
X * C = 20.8137711965230361973
X *
X * D = 1.0
X *
X * E = 7.2135034108448192083
X *
X * F = 0.057761135831801928
X *
X * Coefficients are from HART, table #1121, pg 206.
X *
X * Effective multiplication by 2**y is done by a
X * floating point scale with y as scale argument.
X *
X */
X
X#include <stdio.h>
X#include <pmluser.h>
X#include "pml.h"
X
X# define C 20.8137711965230361973 /* Polynomial approx coeff. */
X# define D 1.0 /* Polynomial approx coeff. */
X# define E 7.2135034108448192083 /* Polynomial approx coeff. */
X# define F 0.057761135831801928 /* Polynomial approx coeff. */
X
X
X/************************************************************************
X * *
X * This table is fixed in size and reasonably hardware *
X * independent. The given constants were generated on a *
X * DECSYSTEM 20 using double precision FORTRAN. *
X * *
X ************************************************************************
X */
X
Xstatic double fpof2tbl[] = {
X 1.00000000000000000000, /* 2 ** 0/16 */
X 1.04427378242741384020, /* 2 ** 1/16 */
X 1.09050773266525765930, /* 2 ** 2/16 */
X 1.13878863475669165390, /* 2 ** 3/16 */
X 1.18920711500272106640, /* 2 ** 4/16 */
X 1.24185781207348404890, /* 2 ** 5/16 */
X 1.29683955465100966610, /* 2 ** 6/16 */
X 1.35425554693689272850, /* 2 ** 7/16 */
X 1.41421356237309504880, /* 2 ** 8/16 */
X 1.47682614593949931110, /* 2 ** 9/16 */
X 1.54221082540794082350, /* 2 ** 10/16 */
X 1.61049033194925430820, /* 2 ** 11/16 */
X 1.68179283050742908600, /* 2 ** 12/16 */
X 1.75625216037329948340, /* 2 ** 13/16 */
X 1.83400808640934246360, /* 2 ** 14/16 */
X 1.91520656139714729380 /* 2 ** 15/16 */
X};
X
Xstatic char funcname[] = "exp";
X
X
Xdouble exp (x)
Xdouble x;
X{
X register int y;
X register int index;
X auto double w;
X auto double v;
X auto double a;
X auto double b;
X auto double t;
X auto double temp;
X auto double wpof2;
X auto double zpof2;
X auto double rtnval;
X extern double dabs ();
X extern double ldexp ();
X extern double modf ();
X auto struct exception xcpt;
X
X DBUG_ENTER (funcname);
X DBUG_3 ("expin", "arg %le", x);
X if (x > LOGE_MAXDOUBLE) {
X xcpt.type = OVERFLOW;
X xcpt.name = funcname;
X xcpt.arg1 = x;
X if (!matherr (&xcpt)) {
X fprintf (stderr, "%s: OVERFLOW error\n", funcname);
X errno = ERANGE;
X xcpt.retval = MAXDOUBLE;
X }
X } else if (x <= LOGE_MINDOUBLE) {
X xcpt.type = UNDERFLOW;
X xcpt.name = funcname;
X xcpt.arg1 = x;
X if (!matherr (&xcpt)) {
X fprintf (stderr, "%s: OVERFLOW error\n", funcname);
X errno = ERANGE;
X xcpt.retval = 0.0;
X }
X } else {
X t = x * LOG2E;
X (void) modf (t, &temp);
X y = temp;
X v = 16.0 * modf (t, &temp);
X (void) modf (dabs (v), &temp);
X index = temp;
X if (x < 0.0) {
X zpof2 = 1.0 / fpof2tbl[index];
X } else {
X zpof2 = fpof2tbl[index];
X }
X w = modf (v, &temp) / 16.0;
X a = C + (D * w * w);
X b = w * (E + (F * w * w));
X wpof2 = (a + b) / (a - b);
X xcpt.retval = ldexp ((wpof2 * zpof2), y);
X }
X DBUG_3 ("expout", "result %le", rtnval);
X DBUG_RETURN (xcpt.retval);
X}
END_OF_funcs/src/exp.c
if test 5510 -ne `wc -c <funcs/src/exp.c`; then
echo shar: \"funcs/src/exp.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f funcs/src/pmlerr.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"funcs/src/pmlerr.c\"
else
echo shar: Extracting \"funcs/src/pmlerr.c\" \(7682 characters\)
sed "s/^X//" >funcs/src/pmlerr.c <<'END_OF_funcs/src/pmlerr.c'
X/************************************************************************
X * *
X * N O T I C E *
X * *
X * Copyright Abandoned, 1987, Fred Fish *
X * *
X * This previously copyrighted work has been placed into the *
X * public domain by the author (Fred Fish) and may be freely used *
X * for any purpose, private or commercial. I would appreciate *
X * it, as a courtesy, if this notice is left in all copies and *
X * derivative works. Thank you, and enjoy... *
X * *
X * The author makes no warranty of any kind with respect to this *
X * product and explicitly disclaims any implied warranties of *
X * merchantability or fitness for any particular purpose. *
X * *
X ************************************************************************
X */
X
X
X/************************************************************************
X * *
X * PORTABLE MATH LIBRARY -- ERROR HANDLER *
X * *
X * This is a sample PML library error handler. *
X * It may be used as is, or another of the user's choice *
X * substituted. *
X * *
X * In any case, the global "pmlerr" must be defined somewhere *
X * in the user task, since many Portable Math Library routines *
X * reference it. The other routines in this file are not called *
X * by any library routines and may be omitted. *
X * *
X ************************************************************************
X */
X
X# include <stdio.h>
X# include <pmluser.h>
X# include "pml.h"
X
Xstatic struct pml_err {
X int flags; /* Flag word; bits defined in pml.h */
X char *msg; /* Error message */
X char *func; /* Function in which error occured */
X};
X
Xstatic struct pml_err pml_errs[] = {
X CONTINUE | COUNT | LOG, "overflow", "exp",
X CONTINUE | COUNT | LOG, "underflow", "exp",
X CONTINUE | COUNT | LOG, "exponent overflow", "scale",
X CONTINUE | COUNT | LOG, "negative argument", "sqrt",
X CONTINUE | COUNT | LOG, "zero argument", "log",
X CONTINUE | COUNT | LOG, "negative argument", "log",
X CONTINUE | COUNT | LOG, "argument magnitude greater than 1.0", "acos",
X CONTINUE | COUNT | LOG, "argument magnitude greater than 1.0", "asin",
X CONTINUE | COUNT | LOG, "overflow", "tan",
X CONTINUE | COUNT | LOG, "overflow", "cosh",
X CONTINUE | COUNT | LOG, "underflow", "cosh",
X CONTINUE | COUNT | LOG, "overflow", "sinh",
X CONTINUE | COUNT | LOG, "underflow", "sinh",
X CONTINUE | COUNT | LOG, "overflow", "asinh",
X CONTINUE | COUNT | LOG, "argument less than 1.0", "acosh",
X CONTINUE | COUNT | LOG, "overflow", "acosh",
X CONTINUE | COUNT | LOG, "argument magnitude not < 1.0", "atanh",
X CONTINUE | COUNT | LOG, "underflow", "atan",
X CONTINUE | COUNT | LOG, "complex division by zero", "cdiv",
X CONTINUE | COUNT | LOG, "complex reciprocal of zero", "crcp",
X CONTINUE | COUNT | LOG, "exponent underflow", "scale",
X CONTINUE | COUNT | LOG, "argument has no fractional part", "dint",
X};
X
Xstatic int err_count = 0; /* Counter for PML errors */
Xstatic int err_limit = MAX_ERRORS; /* PML error limit */
X
X/*
X * FUNCTION
X *
X * pmlcfs Clear specified PML error handler flags
X *
X * KEY WORDS
X *
X * pmlcfs
X * machine independent routines
X * math libraries
X *
X * DESCRIPTION
X *
X * Clear the specified PML error handler flags for the
X * specified error. Two or more flags may be cleared simultaneously
X * by "or-ing" them in the call, for example "LOG | CONTINUE".
X * The manifest constants for the flags and error codes are
X * defined in <pmluser.h>.
X *
X * USAGE
X *
X * pmlcfs(err_code,flags)
X * int err_code;
X * int flags;
X *
X * PROGRAMMER
X *
X * Fred Fish
X * Tempe, Az 85281
X * (602) 966-8871
X *
X */
X
Xpmlcfs(err_code,flag_word)
Xregister int err_code;
Xregister int flag_word;
X{
X if (err_code < 0 || err_code > (sizeof(pml_errs)/sizeof(struct pml_err))) {
X fprintf(stderr,"pmlcfs: invalid error code %d\n",err_code);
X } else {
X pml_errs[err_code].flags &= ~flag_word;
X }
X}
X
X
X/*
X * FUNCTION
X *
X * pmlcnt get PML error count and reset it to zero
X *
X * KEY WORDS
X *
X * pmlcnt
X * machine independent routines
X * math libraries
X *
X * DESCRIPTION
X *
X * Returns the total number of PML errors seen
X * prior to the call, and resets the error count to zero.
X *
X * USAGE
X *
X * int pmlcnt()
X *
X * PROGRAMMER
X *
X * Fred Fish
X * Tempe, Az 85281
X * (602) 966-8871
X *
X */
X
Xint pmlcnt()
X{
X register int rtn_val;
X
X rtn_val = err_count;
X err_count = 0;
X return(rtn_val);
X}
X
X
X/*
X * FUNCTION
X *
X * pmlerr Portable Math Library error handler
X *
X * KEY WORDS
X *
X * pmlerr
X * machine independent routines
X * math libraries
X *
X * DESCRIPTION
X *
X * Provides a sample PML error handler. Does
X * not use any available hardware "traps" so is machine
X * independent. Generally only called internally by the
X * other PML routines.
X *
X * There are currently three flags which control the
X * response for specific errors:
X *
X * (1) LOG When set an error message is sent
X * to the user terminal.
X *
X * (2) COUNT When set the error is counted
X * against the PML error limit.
X *
X * (3) CONTINUE When set the task continues
X * providing the error count has not
X * exceeded the PML error limit.
X *
X * Each of these flags can be set or reset independently
X * by "pmlsfs" or "pmlcfs" respectively.
X *
X * USAGE
X *
X * pmlerr(err_code)
X * int err_code;
X *
X * PROGRAMMER
X *
X * Fred Fish
X * Tempe, Az 85281
X * (602) 966-8871
X *
X */
X
Xpmlerr(err_code)
Xregister int err_code;
X{
X register struct pml_err *err;
X
X if (err_code < 0 || err_code > (sizeof(pml_errs)/sizeof(struct pml_err))) {
X fprintf(stderr,"pmlerr: invalid error code %d\n",err_code);
X } else {
X err = &pml_errs[err_code];
X if (err->flags & LOG) {
X fprintf(stderr,"pml: %s in function \"%s\"\n",err->msg,err->func);
X }
X if (err->flags & COUNT) {
X err_count++;
X }
X if ((err->flags & CONTINUE) && (err_count <= err_limit)) {
X return;
X } else {
X fprintf(stderr,"pml: error limit exceeded\n");
X fprintf(stderr,"pml: task aborted with %d error(s)\n",
X err_count);
X exit(-1);
X }
X }
X}
X
X
X/*
X * FUNCTION
X *
X * pmllim Set Portable Math Library error limit
X *
X * KEY WORDS
X *
X * pmllim
X * machine independent routines
X * math libraries
X *
X * DESCRIPTION
X *
X * Sets the PML error limit to the specified value
X * and returns it previous value.
X * Does not affect the current error count (which may be reset
X * to zero by a call to "pmlcnt"). Note that the default error
X * limit is set at compile time by the value in "pml.h".
X *
X * USAGE
X *
X * int pmllim(limit)
X * int limit;
X *
X * PROGRAMMER
X *
X * Fred Fish
X * Tempe, Az 85281
X * (602) 966-8871
X *
X */
X
Xint pmllim(limit)
Xregister int limit;
X{
X register int rtn_val;
X
X rtn_val = err_limit;
X err_limit = limit;
X return(rtn_val);
X}
X
X
X/*
X * FUNCTION
X *
X * pmlsfs Set specified PML error handler flags
X *
X * KEY WORDS
X *
X * pmlsfs
X * machine independent routines
X * math libraries
X *
X * DESCRIPTION
X *
X * Set the specified PML error handler flags for the
X * specified error. Two or more flags may be set simultaneously
X * by "or-ing" them in the call, for example "LOG | CONTINUE".
X * The manifest constants for the flags and error codes are
X * defined in <pmluser.h>.
X *
X * USAGE
X *
X * pmlsfs(err_code,flags)
X * int err_code;
X * int flags;
X *
X * PROGRAMMER
X *
X * Fred Fish
X * Tempe, Az 85281
X *
X */
X
Xpmlsfs(err_code,flag_word)
Xregister int err_code;
Xregister int flag_word;
X{
X if (err_code < 0 || err_code > (sizeof(pml_errs)/sizeof(struct pml_err))) {
X fprintf(stderr,"? pmlsfs --- invalid error code %d.\n",err_code);
X } else {
X pml_errs[err_code].flags |= flag_word;
X }
X}
END_OF_funcs/src/pmlerr.c
if test 7682 -ne `wc -c <funcs/src/pmlerr.c`; then
echo shar: \"funcs/src/pmlerr.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f funcs/src/unused/OLDpml.h -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"funcs/src/unused/OLDpml.h\"
else
echo shar: Extracting \"funcs/src/unused/OLDpml.h\" \(6798 characters\)
sed "s/^X//" >funcs/src/unused/OLDpml.h <<'END_OF_funcs/src/unused/OLDpml.h'
X/************************************************************************
X * *
X * N O T I C E *
X * *
X * Copyright Abandoned, 1987, Fred Fish *
X * *
X * This previously copyrighted work has been placed into the *
X * public domain by the author (Fred Fish) and may be freely used *
X * for any purpose, private or commercial. I would appreciate *
X * it, as a courtesy, if this notice is left in all copies and *
X * derivative works. Thank you, and enjoy... *
X * *
X * The author makes no warranty of any kind with respect to this *
X * product and explicitly disclaims any implied warranties of *
X * merchantability or fitness for any particular purpose. *
X * *
X ************************************************************************
X */
X
X
X/*
X * This file gets included with all of the floating point math
X * library routines when they are compiled. Note that
X * this is the proper place to put machine dependencies
X * whenever possible.
X *
X * It should be pointed out that for simplicity's sake, the
X * environment parameters are defined as floating point constants,
X * rather than octal or hexadecimal initializations of allocated
X * storage areas. This means that the range of allowed numbers
X * may not exactly match the hardware's capabilities. For example,
X * if the maximum positive double precision floating point number
X * is EXACTLY 1.11...E100 and the constant "MAX_POS_DBLF is
X * defined to be 1.11E100 then the numbers between 1.11E100 and
X * 1.11...E100 are considered to be undefined. For most
X * applications, this will cause no problems.
X *
X * An alternate method is to allocate a global static "double" variable,
X * say "max_pos_dblf", and use a union declaration and initialization
X * to initialize it with the proper bits for the EXACT maximum value.
X * This was not done because the only compilers available to the
X * author did not fully support union initialization features.
X *
X */
X
X
X/*
X * PDP10 (DECSYSTEM 20) HARDWARE DEPENDENCIES
X *
X * ******** W A R N I N G W A R N I N G ********
X * The current DEC20 implementation treats double precision
X * floats as single precision floats. When true double
X * precision is implemented, the flowing floats may have to
X * change.
X *
X * Since the PDP10 compiler has no static variables, and only
X * first 5 letters are significant, must use preprocessor
X * to avoid name clashes.
X */
X
X#ifndef NO_DBUG
X# include <dbug.h>
X#else
X# define DBUG_ENTER(a1)
X# define DBUG_RETURN(a1) return(a1)
X# define DBUG_VOID_RETURN return
X# define DBUG_EXECUTE(keyword,a1)
X# define DBUG_2(keyword,format)
X# define DBUG_3(keyword,format,a1)
X# define DBUG_4(keyword,format,a1,a2)
X# define DBUG_5(keyword,format,a1,a2,a3)
X# define DBUG_PUSH(a1)
X# define DBUG_POP()
X# define DBUG_PROCESS(a1)
X# define DBUG_FILE (stderr)
X#endif
X
X#ifdef PDP10
X#define MAX_POS_DBLF 1.7014118e38 /* Max positive double */
X#define MIN_POS_DBLF 1.4693680e-39 /* Min positive double */
X#define MAX_NEG_DBLF -1.7014118e38 /* Max negative double */
X#define MIN_NEG_DBLF -1.4693680e-39 /* Min negative double */
X#define MAX_EXPONENT 127 /* Max exponent allowed */
X#define RECIP_MIN 5.877471e-39 /* MAX_POS_DBLF >= 1/RECIP_MIN */
X#define RECIP_MAX 1.7014118e38 /* MIN_POS_DBLF <= 1/RECIP_MAX */
X#define LN_MAXPOSDBL 88.0 /* LN(MAX_POS_DBLF) */
X#define LN_MINPOSDBL -89.4 /* LN(MIN_POS_DBLF) */
X#define TANH_MAXARG 16 /* |TANH(maxarg)| = 1.0 */
X#define SQRT_MPDF 1.304380e19 /* SQRT(MAX_POS_DBLF) */
X#define X6_UNDERFLOWS 3.37174e-7 /* X**6 almost underflows */
X#define X16_UNDERFLOWS 3.74063e-3 /* X**16 almost underflows */
X
X#define atan_coeffs qzzz1 /* rename to avoid name clash */
X#define cos_pcoeffs qzzz2 /* rename to avoid name clash */
X#define cos_qcoeffs qzzz3 /* rename to avoid name clash */
X#define ln_pcoeffs qzzz4 /* rename to avoid name clash */
X#define ln_qcoeffs qzzz5 /* rename to avoid name clash */
X#define sin_pcoeffs qzzz6 /* rename to avoid name clash */
X#define sin_qcoeffs qzzz7 /* rename to avoid name clash */
X#endif
X
X
X/*
X * PDP11 HARDWARE DEPENDENCIES
X *
X */
X
X#ifdef pdp11
X#define MAX_POS_DBLF 1.7014118e38 /* Max positive double */
X#define MIN_POS_DBLF 1.4693680e-39 /* Min positive double */
X#define MAX_NEG_DBLF -1.7014118e38 /* Max negative double */
X#define MIN_NEG_DBLF -1.4693680e-39 /* Min negative double */
X#define MAX_EXPONENT 127 /* Max exponent allowed */
X#define RECIP_MIN 5.877471e-39 /* MAX_POS_DBLF >= 1/RECIP_MIN */
X#define RECIP_MAX 1.7014118e38 /* MIN_POS_DBLF <= 1/RECIP_MAX */
X#define LN_MAXPOSDBL 88.0 /* LN(MAX_POS_DBLF) */
X#define LN_MINPOSDBL -89.4 /* LN(MIN_POS_DBLF) */
X#define TANH_MAXARG 16 /* |TANH(maxarg)| = 1.0 */
X#define SQRT_MPDF 1.304380e19 /* SQRT(MAX_POS_DBLF) */
X#define X6_UNDERFLOWS 3.37174e-7 /* X**6 almost underflows */
X#define X16_UNDERFLOWS 3.74063e-3 /* X**16 almost underflows */
X#endif
X
X
X/*
X * MC68000 HARDWARE DEPENDENCIES
X *
X * cc -DIEEE => uses IEEE floating point format
X *
X */
X
X#if defined(mc68000) && defined(IEEE)
X#define MIN_POS_DBLF 2.22507385850720220000e-308; /* Min positive dbl */
X#define MAX_POS_DBLF 1.79769313486231440000e+308; /* Max positive dbl */
X#define MIN_NEG_DBLF -2.22507385850720220000e-308; /* Min negative dbl */
X#define MAX_NEG_DBLF -1.79769313486231440000e+308; /* Max negative dbl */
X#define MAX_PEXPONENT 1024 /* Max pos exponent */
X#define MAX_NEXPONENT -1022 /* Max neg exponent */
X#endif
X
X
X#if defined(mc68000) && !defined(IEEE)
X#define MAX_POS_DBLF 1.7014118e38 /* Max positive double */
X#define MIN_POS_DBLF 1.4693680e-39 /* Min positive double */
X#define MAX_NEG_DBLF -1.7014118e38 /* Max negative double */
X#define MIN_NEG_DBLF -1.4693680e-39 /* Min negative double */
X#define MAX_EXPONENT 127 /* Max exponent allowed */
X#define RECIP_MIN 5.877471e-39 /* MAX_POS_DBLF >= 1/RECIP_MIN */
X#define RECIP_MAX 1.7014118e38 /* MIN_POS_DBLF <= 1/RECIP_MAX */
X#define LN_MAXPOSDBL 88.0 /* LN(MAX_POS_DBLF) */
X#define LN_MINPOSDBL -89.4 /* LN(MIN_POS_DBLF) */
X#define TANH_MAXARG 16 /* |TANH(maxarg)| = 1.0 */
X#define SQRT_MPDF 1.304380e19 /* SQRT(MAX_POS_DBLF) */
X#define X6_UNDERFLOWS 3.37174e-7 /* X**6 almost underflows */
X#define X16_UNDERFLOWS 3.74063e-3 /* X**16 almost underflows */
X#endif
X
X
X/* Define some commonly used constants */
X
X#define PI 3.14159265358979323846
X#define TWOPI (2.0 * PI)
X#define HALFPI (PI / 2.0)
X#define FOURTHPI (PI / 4.0)
X#define SIXTHPI (PI / 6.0)
X#define LOG2E 1.4426950408889634073
X#define LOG10E 0.4342944819032518276
X#define SQRT2 1.4142135623730950488
X#define SQRT3 1.7320508075688772935
X#define LN2 0.6931471805599453094
X#define LNSQRT2 0.3465735902799726547
X
X
X/* Configuration options */
X
X#define MAX_ERRORS 10 /* Limit on number of errors before abort */
END_OF_funcs/src/unused/OLDpml.h
if test 6798 -ne `wc -c <funcs/src/unused/OLDpml.h`; then
echo shar: \"funcs/src/unused/OLDpml.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f tests/d2d.dat -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"tests/d2d.dat\"
else
echo shar: Extracting \"tests/d2d.dat\" \(8975 characters\)
sed "s/^X//" >tests/d2d.dat <<'END_OF_tests/d2d.dat'
Xdabs 1.2345 1.2345
Xdabs -1.2345 1.2345
Xdabs 1.2345e+20 1.2345e+20
Xdabs -9.987e+25 9.987e+25
Xdabs -7.89e-24 7.89e-24
Xdabs 5.67e-15 5.67e-15
Xexp -40.0 4.248354255291e-18
Xexp -30.0 9.357622968840e-14
Xexp -20.0 2.061153622438e-09
Xexp -10.0 4.539992976248e-05
Xexp -2.0 1.353352832366e-01
Xexp -1.0 0.36787944117144232159552377016146087
Xexp -0.25 0.77880078307140486824517026697832065
Xexp 0.0 1.000000000000e00
Xexp 0.25 1.28402541668774148407342056806243646
Xexp 1.0 2.71828182845904523536028747135266250
Xexp 2.0 7.389056098930e00
Xexp 10.0 2.202646579480e04
Xexp 20.0 4.851651954097e08
Xexp 30.0 1.068647458152e13
Xexp 40.0 2.353852668370e17
Xsqrt 0.0 0.0
Xsqrt 4.999999999999999999e-02 2.236067977499789696e-01
Xsqrt 2.500000000000000000e-01 5.000000000000000000e-01
Xsqrt 5.000000000000000000e-01 7.071067811865475243e-01
Xsqrt 1.000000000000000000e00 1.000000000000000000e00
Xsqrt 2.000000000000000000e00 1.414213562373095048e00
Xsqrt 1.000000000000000000e01 3.162277660168379332e00
Xsqrt 3.000000000000000000e01 5.477225575051661134e00
Xsqrt 7.000000000000000000e01 8.366600265340755481e00
Xsqrt 2.000000000000000000e02 1.414213562373095049e01
Xsqrt 1.999999999999999999e32 1.414213562373095048e16
Xsqrt 0.6366197723675813430755350534900574 0.79788456080286535587989211986876373
Xsqrt 3.1415926535897932384626433832795028 1.77245385090551602729816748334114518
Xlog 4.999999999999999999e-02 -2.995732273553990993e00
Xlog 2.500000000000000000e-01 -1.386294361119890618e00
Xlog 5.000000000000000000e-01 -6.931471805599453094e-01
Xlog 1.000000000000000000e00 0.000000000000000000e00
Xlog 2.0 0.69314718055994530941723212145817657
Xlog 4.0 1.38629436111989061883446424291635313
Xlog 10.0 2.30258509299404568401799145468436421
Xlog 1.000000000000000000e01 2.302585092994045684e00
Xlog 3.000000000000000000e01 3.401197381662155375e00
Xlog 5.000000000000000000e01 3.912023005428146058e00
Xlog 2.000000000000000000e02 5.298317366548036677e00
Xlog 1.999999999999999999e32 7.437587015636940721e01
Xatanh -9.999899999999999999e-01 -6.103033822758835533e00
Xatanh -5.000000000000000000e-01 -5.493061443340548457e-01
Xatanh -2.500000000000000000e-01 -2.554128118829953416e-01
Xatanh 0.000000000000000000e00 0.000000000000000000e00
Xatanh 2.500000000000000000e-01 2.554128118829953415e-01
Xatanh 5.000000000000000000e-01 5.493061443340548457e-01
Xatanh 9.999899999999999999e-01 6.103033822758835533e00
Xsinh -8.000000000000000000e01 -2.770311192196755026e34
Xsinh -1.000000000000000000e01 -1.101323287470339337e04
Xsinh -5.000000000000000000e-01 -5.210953054937473615e-01
Xsinh 0.000000000000000000e00 0.000000000000000000e00
Xsinh 1.500000000000000000e00 2.129279455094817497e00
Xsinh 1.000000000000000000e01 1.101323287470339337e04
Xsinh 8.000000000000000000e01 2.770311192196755026e34
Xcosh -8.000000000000000000e01 2.770311192196755026e34
Xcosh -1.000000000000000000e01 1.101323292010332313e04
Xcosh -5.000000000000000000e-01 1.127625965206380785e00
Xcosh 0.000000000000000000e00 1.000000000000000000e00
Xcosh 1.500000000000000000e00 2.352409615243247325e00
Xcosh 1.000000000000000000e01 1.101323292010332313e04
Xcosh 8.000000000000000000e01 2.770311192196755026e34
Xtanh -8.000000000000000000e01 -1.000000000000000000e00
Xtanh -1.000000000000000000e01 -9.999999958776927635e-01
Xtanh -5.000000000000000000e-01 -4.621171572600097586e-01
Xtanh 0.000000000000000000e00 0.000000000000000000e00
Xtanh 1.500000000000000000e00 9.051482536448664383e-01
Xtanh 1.000000000000000000e01 9.999999958776927635e-01
Xtanh 8.000000000000000000e01 1.000000000000000000e00
Xsin 5.00e-11 5.000000000000000000e-11
Xsin 0.0 0.0
Xsin 0.25 0.24740395925452292959684870484938920
Xsin 0.5 0.47942553860420300027328793521557139
Xsin 0.78539816339744830961556084581987572 0.70710678118654752440084436210484903
Xsin -0.7853981633974483096155608458198757 -0.7071067811865475244008443621048490
Xsin 1.0 0.84147098480789650665250232163029900
Xsin 2.00e00 9.092974268256816953e-01
Xsin 2.50e00 5.984721441039564939e-01
Xsin 3.50e00 -3.507832276896198480e-01
Xsin 4.00e00 -7.568024953079282514e-01
Xsin 5.00e00 -9.589242746631384689e-01
Xsin 6.00e00 -2.794154981989258727e-01
Xsin 7.50e00 9.379999767747388579e-01
Xsin 8.00e00 9.893582466233817778e-01
Xsin 9.00e00 4.121184852417565697e-01
Xsin 9.50e00 -7.515112046180930728e-02
Xsin -5.00e-01 -4.794255386042030000e-01
Xsin -1.00e00 -8.414709848078965066e-01
Xsin -2.00e00 -9.092974268256816953e-01
Xsin -2.50e00 -5.984721441039564939e-01
Xsin -3.50e00 3.507832276896198480e-01
Xsin -4.00e00 7.568024953079282514e-01
Xsin -5.00e00 9.589242746631384689e-01
Xsin -5.50e00 7.055403255703919063e-01
Xsin -6.50e00 -2.151199880878155242e-01
Xsin -7.50e00 -9.379999767747388579e-01
Xsin -8.00e00 -9.893582466233817778e-01
Xsin -9.00e00 -4.121184852417565697e-01
Xsin -9.50e00 7.515112046180930728e-02
Xcos 5.00e-11 9.999999999999999997e-01
Xcos 0.00e00 9.999999999999999997e-01
Xcos 5.00e-01 8.77582561890372716e-01
Xcos 1.00e00 5.403023058681397173e-01
Xcos 2.00e00 -4.161468365471423870e-01
Xcos 2.50e00 -8.011436155469337148e-01
Xcos 3.50e00 -9.364566872907963376e-01
Xcos 4.00e00 -6.536436208636119144e-01
Xcos 5.00e00 2.836621854632262644e-01
Xcos 5.50e00 7.086697742912599999e-01
Xcos 6.50e00 9.765876257280234999e-01
Xcos 7.50e00 3.466353178350258109e-01
Xcos 8.00e00 -1.455000338086135258e-01
Xcos 9.00e00 -9.111302618846769882e-01
Xcos 9.50e00 -9.971721561963784728e-01
Xcos -5.00e-01 8.775825618903727160e-01
Xcos -1.00e00 5.403023058681397173e-01
Xcos -2.00e00 -4.161468365471423870e-01
Xcos -2.50e00 -8.011436155469337148e-01
Xcos -3.50e00 -9.364566872907963376e-01
Xcos -4.00e00 -6.536436208636119144e-01
Xcos -5.00e00 2.836621854632262644e-01
Xcos -6.00e00 9.601702866503660205e-01
Xcos -6.50e00 9.765876257280234999e-01
Xcos -7.50e00 3.466353178350258109e-01
Xcos -8.00e00 -1.455000338086135258e-01
Xcos -9.00e00 -9.111302618846769882e-01
Xcos -9.50e00 -9.971721561963784728e-01
Xtan -2.000000000000000000e00 2.185039863261518991e00
Xtan -1.000000000000000000e00 -1.557407724654902230e00
Xtan -5.000000000000000000e-01 -5.463024898437905132e-01
Xtan 0.000000000000000000e00 0.000000000000000000e00
Xtan 0.39269908169872415480783042290993786 0.41421356237309504880168872420969807
Xtan 0.25 0.25534192122103626650448223649047368
Xtan 0.5 0.54630248984379051325517946578028538
Xtan 0.78539816339744830961556084581987572 1.0
Xtan -0.78539816339744830961556084581987572 -1.0
Xtan 1.0 1.55740772465490223050697480745836017
Xtan 2.000000000000000000e00 -2.185039863261518991e00
Xlog10 1.00e-10 -1.000000000000000000e01
Xlog10 1.00e-05 -5.000000000000000000e00
Xlog10 5.00e-01 -3.010299956639811952e-01
Xlog10 1.00e00 0.000000000000000000e00
Xlog10 1.50e00 1.760912590556812420e-01
Xlog10 2.0 0.30102999566398119521373889472449303
Xlog10 2.71828182845904523536028747135266250 0.43429448190325182765112891891660508
Xlog10 1.00e05 5.000000000000000000e00
Xlog10 1.00e20 2.000000000000000000e01
Xatan 0.000000000000e00 0.000000000000e00
Xatan 4.999999999999e-02 4.995839572194e-02
Xatan 2.500000000000e-01 2.449786631268e-01
Xatan 3.500000000000e-01 3.366748193867e-01
Xatan 7.000000000000e-01 6.107259643892e-01
Xatan 1.000000000000e00 7.85398163397e-01
Xatan 2.000000000000e00 1.10714871779e00
Xatan 1.400000000000e01 1.49948886200e00
Xatan 3.000000000000e01 1.53747533091e00
Xatan 5.000000000000e01 1.55079899282e00
Xatan 7.000000000000e01 1.55651158420e00
Xatan 9.000000000000e01 1.55968567289e00
Xatan 2.000000000000e02 1.56579636846e00
Xasinh -8.000000000000000000e01 -5.075212875445203927e00
Xasinh -1.000000000000000000e01 -2.998222950297969704e00
Xasinh -5.000000000000000000e-01 -4.812118250596034474e-01
Xasinh 0.000000000000000000e00 0.000000000000000000e00
Xasinh 1.500000000000000000e00 1.194763217287109304e00
Xasinh 1.000000000000000000e01 2.998222950297969738e00
Xasinh 8.000000000000000000e01 5.075212875445207223e00
Xasin -1.000000000000000000e00 -1.570796326794896619e00
Xasin -7.000000000000000000e-01 -7.753974966107530636e-01
Xasin -1.999999999999999999e-01 -2.013579207903307914e-01
Xasin 0.000000000000000000e00 0.000000000000000000e00
Xasin 1.999999999999999999e-01 2.013579207903307914e-01
Xasin 7.000000000000000000e-01 7.753974966107530636e-01
Xasin 1.000000000000000000e00 1.570796326794896619e00
Xacosh 1.000000000000000000e00 0.000000000000000000e00
Xacosh 2.000000000000000000e00 1.316957896924816708e00
Xacosh 1.000000000000000000e01 2.993222846126380897e00
Xacosh 2.000000000000000000e02 5.991458297049387423e00
Xacosh 1.000000000000000000e03 7.600902209541988611e00
Xacosh 1.000000000000000000e05 1.220607264550517372e01
Xacosh 1.000000000000000000e18 4.213967885445276762e01
Xacos -1.000000000000000000e00 3.141592653589793238e00
Xacos -7.000000000000000000e-01 2.346193823405649682e00
Xacos -1.999999999999999999e-01 1.772154247585227410e00
Xacos 0.000000000000000000e00 1.570796326794896619e00
Xacos 1.999999999999999999e-01 1.369438406004565827e00
Xacos 7.000000000000000000e-01 7.953988301841435554e-01
Xacos 1.000000000000000000e00 0.000000000000000000e00
END_OF_tests/d2d.dat
if test 8975 -ne `wc -c <tests/d2d.dat`; then
echo shar: \"tests/d2d.dat\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f tests/errors.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"tests/errors.c\"
else
echo shar: Extracting \"tests/errors.c\" \(7459 characters\)
sed "s/^X//" >tests/errors.c <<'END_OF_tests/errors.c'
X/************************************************************************
X * *
X * N O T I C E *
X * *
X * Copyright Abandoned, 1987, Fred Fish *
X * *
X * This previously copyrighted work has been placed into the *
X * public domain by the author (Fred Fish) and may be freely used *
X * for any purpose, private or commercial. I would appreciate *
X * it, as a courtesy, if this notice is left in all copies and *
X * derivative works. Thank you, and enjoy... *
X * *
X * The author makes no warranty of any kind with respect to this *
X * product and explicitly disclaims any implied warranties of *
X * merchantability or fitness for any particular purpose. *
X * *
X ************************************************************************
X */
X
X/*
X * FILE
X *
X * testerrors.c error handler test for portable math library
X *
X * KEY WORDS
X *
X * test routines
X * portable math library
X * error handler
X *
X * DESCRIPTION
X *
X * Tests functions of the optional error handler for the portable
X * math library. Tests the COUNT, LOG, and CONTINUE bits for
X * each function, along with the task error limit.
X *
X * USAGE
X *
X * testerrors
X *
X * PROGRAMMER
X *
X * Fred Fish
X * Engineering Software Tools
X * P.O. Box 2035
X * Tempe, Az 85281
X * (602) 966-8871
X *
X */
X
X#include <stdio.h>
X#include <pmluser.h>
X#include "../funcs/pml.h"
X
Xchar *test1[] = {
X "\n****** TEST #1 ******",
X "",
X " Generate all errors",
X "",
X " (1) LOG bits, COUNT bits, and CONTINUE bits set.",
X " (2) Error limit set high enough to avoid aborting.",
X "",
X " This test should generate an error message for each",
X " error tested, and the final error count should be printed",
X " when done.",
X "\n",
X 0
X};
X
Xchar *test2[] = {
X "\n****** TEST #2 ******",
X "",
X " Turn off logging.",
X "",
X " (1) LOG bits reset.",
X " (2) COUNT bits and CONTINUE bits set.",
X " (3) Error limit set high enough to avoid aborting.",
X "",
X " This test should not log any error messages but the error",
X " count should be the same as test 1.",
X "\n",
X 0
X};
X
Xchar *test3[] = {
X "\n****** TEST #3 ******",
X "",
X " Turn off error counting",
X "",
X " (1) LOG and COUNT bits reset.",
X " (2) CONTINUE bits set.",
X " (3) Error limit set to 0.",
X "",
X " This test should not log or count any errors. The final",
X " error count should be zero.",
X "\n",
X 0
X};
X
Xchar *test4[] = {
X "\n****** TEST #4 ******",
X "",
X " Enable error limit and abort.",
X "",
X " (1) LOG bits, COUNT bits, and CONTINUE bits set.",
X " (2) Error limit set to 5.",
X "",
X " This test should abort after logging the sixth error.",
X "\n",
X 0
X};
X
X
Xmain()
X{
X initialize();
X pmllim(40);
X prtdoc(test1);
X gen_errors();
X printf("\nTotal errors counted = %d\n",pmlcnt());
X
X log_off();
X pmllim(40);
X prtdoc(test2);
X gen_errors();
X printf("\nTotal errors counted = %d\n",pmlcnt());
X
X count_off();
X pmllim(0);
X prtdoc(test3);
X gen_errors();
X printf("\nTotal errors counted = %d\n",pmlcnt());
X
X initialize();
X pmllim(5);
X prtdoc(test4);
X gen_errors();
X}
X
X
Xprtdoc(dp)
Xregister char **dp;
X{
X while (*dp) {
X printf("%s\n",*dp++);
X }
X}
X
X
Xinitialize()
X{
X pmlsfs(EXP_OVERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(EXP_UNDERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(SCALE_OVERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(SCALE_UNDERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(NEG_SQRT,LOG|COUNT|CONTINUE);
X pmlsfs(LOG_OF_ZERO,LOG|COUNT|CONTINUE);
X pmlsfs(LOG_OF_NEGATIVE,LOG|COUNT|CONTINUE);
X pmlsfs(ACOS_BADARG,LOG|COUNT|CONTINUE);
X pmlsfs(ASIN_BADARG,LOG|COUNT|CONTINUE);
X pmlsfs(TAN_OVERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(COSH_OVERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(COSH_UNDERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(SINH_OVERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(SINH_UNDERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(ASINH_OVERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(ACOSH_BADARG,LOG|COUNT|CONTINUE);
X pmlsfs(ACOSH_OVERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(ATANH_BADARG,LOG|COUNT|CONTINUE);
X pmlsfs(ATAN_UNDERFLOW,LOG|COUNT|CONTINUE);
X pmlsfs(C_DIV_ZERO,LOG|COUNT|CONTINUE);
X pmlsfs(CRCP_OF_ZERO,LOG|COUNT|CONTINUE);
X pmlsfs(DINT_2BIG,LOG|COUNT|CONTINUE);
X}
X
Xlog_off()
X{
X pmlcfs(EXP_OVERFLOW,LOG);
X pmlcfs(EXP_UNDERFLOW,LOG);
X pmlcfs(SCALE_OVERFLOW,LOG);
X pmlcfs(SCALE_UNDERFLOW,LOG);
X pmlcfs(NEG_SQRT,LOG);
X pmlcfs(LOG_OF_ZERO,LOG);
X pmlcfs(LOG_OF_NEGATIVE,LOG);
X pmlcfs(ACOS_BADARG,LOG);
X pmlcfs(ASIN_BADARG,LOG);
X pmlcfs(TAN_OVERFLOW,LOG);
X pmlcfs(COSH_OVERFLOW,LOG);
X pmlcfs(COSH_UNDERFLOW,LOG);
X pmlcfs(SINH_OVERFLOW,LOG);
X pmlcfs(SINH_UNDERFLOW,LOG);
X pmlcfs(ASINH_OVERFLOW,LOG);
X pmlcfs(ACOSH_BADARG,LOG);
X pmlcfs(ACOSH_OVERFLOW,LOG);
X pmlcfs(ATANH_BADARG,LOG);
X pmlcfs(ATAN_UNDERFLOW,LOG);
X pmlcfs(C_DIV_ZERO,LOG);
X pmlcfs(CRCP_OF_ZERO,LOG);
X pmlcfs(DINT_2BIG,LOG);
X}
X
Xcount_off()
X{
X pmlcfs(EXP_OVERFLOW,COUNT);
X pmlcfs(EXP_UNDERFLOW,COUNT);
X pmlcfs(SCALE_OVERFLOW,COUNT);
X pmlcfs(SCALE_UNDERFLOW,COUNT);
X pmlcfs(NEG_SQRT,COUNT);
X pmlcfs(LOG_OF_ZERO,COUNT);
X pmlcfs(LOG_OF_NEGATIVE,COUNT);
X pmlcfs(ACOS_BADARG,COUNT);
X pmlcfs(ASIN_BADARG,COUNT);
X pmlcfs(TAN_OVERFLOW,COUNT);
X pmlcfs(COSH_OVERFLOW,COUNT);
X pmlcfs(COSH_UNDERFLOW,COUNT);
X pmlcfs(SINH_OVERFLOW,COUNT);
X pmlcfs(SINH_UNDERFLOW,COUNT);
X pmlcfs(ASINH_OVERFLOW,COUNT);
X pmlcfs(ACOSH_BADARG,COUNT);
X pmlcfs(ACOSH_OVERFLOW,COUNT);
X pmlcfs(ATANH_BADARG,COUNT);
X pmlcfs(ATAN_UNDERFLOW,COUNT);
X pmlcfs(C_DIV_ZERO,COUNT);
X pmlcfs(CRCP_OF_ZERO,COUNT);
X pmlcfs(DINT_2BIG,COUNT);
X}
X
Xgen_errors()
X{
X complex z1, z2;
X
X z1.r = 1.0;
X z1.i = 0.0;
X z2.r = 0.0;
X z2.i = 0.0;
X printf("Testing for exp overflow.\n");
X exp(100.0);
X printf("Testing for exp underflow.\n");
X exp(-100.0);
X printf("Testing for scale exponent overflow.\n");
X scale(1.0,500);
X printf("Testing for scale exponent underflow.\n");
X scale(1.0,-500);
X printf("Testing for sqrt of negative argument.\n");
X sqrt(-1.0);
X printf("Testing for ln of zero.\n");
X ln(0.0);
X printf("Testing for ln of negative argument.\n");
X ln(-1.0);
X printf("Testing for acos argument magnitude greater than 1.0\n");
X acos(2.0);
X printf("Testing for asin argument magnitude greater than 1.0\n");
X asin(-2.0);
X printf("Testing for tan overflow\n");
X tan(HALFPI);
X printf("Testing for cosh overflow\n");
X cosh(LN_MAXPOSDBL+1.0);
X printf("Testing for cosh underflow\n");
X cosh(LN_MINPOSDBL-1.0);
X printf("Testing for sinh overflow\n");
X sinh(LN_MAXPOSDBL+1.0);
X printf("Testing for sinh underflow\n");
X sinh(LN_MINPOSDBL-1.0);
X printf("Testing for asinh overflow\n");
X asinh(2.0 * SQRT_MPDF);
X printf("Testing for acosh argument less than 1.0\n");
X acosh(0.0);
X printf("Testing for acosh overflow\n");
X acosh(2.0 * SQRT_MPDF);
X printf("Testing for atanh argument magnitude >= 1.0\n");
X atanh(-1.0);
X printf("Testing for atan underflow\n");
X atan(RECIP_MAX);
X printf("Testing for complex division by zero\n");
X cdiv(&z1,&z2);
X printf("Testing for complex reciprocal of zero\n");
X crcp(&z2);
X printf("Testing for dint argument has no fractional part\n");
X dint(MAX_POS_DBLF);
X}
X
END_OF_tests/errors.c
if test 7459 -ne `wc -c <tests/errors.c`; then
echo shar: \"tests/errors.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 4 \(of 6\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 6 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
= Drug tests; just say *NO*! (Moto just announced new drug testing program) =
= Fred Fish Motorola Computer Division, 3013 S 52nd St, Tempe, Az 85282 USA =
= seismo!noao!mcdsun!fnf (602) 438-5976 =

0 new messages