home *** CD-ROM | disk | FTP | other *** search
- /* mthutl.c
- *
- * Utilities for Cephes Math Library
- *
- *
- *
- *
- * DESCRIPTION:
- *
- * This file is a concatenation of several modules from the
- * Cephes Math Library. Many of the math routines use some
- * of the constants and subroutines found in this file.
- *
- *
- * NOTES NOT MENTIONED ELSEWHERE:
- *
- * The math routines in this package assume that your computer
- * has IBM/DEC style double precision numbers, with an 8 bit
- * exponent and 56 bit mantissa. They will NOT work without
- * modification if your computer uses IEEE style double precision
- * numbers.
- *
- */
-
- /* const.c
- Cephes Math Library Release 1.0: July, 1984
- Copyright 1984 by Stephen L. Moshier
- Contributed to BIX for personal, non-commercial use only.
- Direct inquiries to 30 Frost Street, Cambridge, MA 02140
- */
- /* log(2**127) = 88.029691931113054295988 */
- extern short MAXLOG[4] = {041660,007463,0143742,025733};
-
- /* log(2**-128) = -88.72283911167299960540 */
- extern short MINLOG[4] = {0141661,071027,0173721,0147572};
-
- /* 2**127 = 1.701411834604692317316873e38 */
- extern short MAXNUM[4] = {077777,0177777,0177777,0177777};
-
- /* pi = 3.14159265358979323846 */
- extern short PI[4] = {040511,007732,0121041,064302};
-
- /* pi/2 = 1.57079632679489661923 */
- extern short PIO2[4] = {040311,007732,0121041,064302};
-
- /* pi/4 = 0.78539816339744830962 */
- extern short PIO4[4] = {040111,007732,0121041,064302};
-
- /* sqrt(2) = 1.41421356237309504880 */
- extern short SQRT2[4] = {040265,002363,031771,0157145};
-
- /* sqrt(2)/2 = 0.70710678118654752440 */
- extern short SQRTH[4] = {040065,002363,031771,0157144};
-
- /* 1/log(2) = 1.4426950408889634073599 */
- extern short LOG2E[4] = {040270,0125073,024534,013761};
-
- /* const.c 2 */
-
- /* sqrt( 2/pi ) = 0.79788456080286535587989 */
- extern short SQ2OPI[4] = {040114,041051,0117241,0131204};
-
- /* log(2) = 0.69314718055994530941 */
- extern short LOGE2[4] = {040061,071027,0173721,0147572};
-
- /* log(2)/2 = 0.346573590279972654708 */
- extern short LOGSQ2[4] = {037661,071027,0173721,0147572};
-
- /* 3*pi/4 = 2.35619449019234492885 */
- extern short THPIO4[4] = {040426,0145743,0174631,007222};
-
- /* 2/pi = .63661977236758134307553505 */
- extern short TWOOPI[4] = {040042,0174603,067116,042025};
-
- static char x[] =
- "Cephes Math Library by Stephen L. Moshier";
- /* polevl.c
- * p1evl.c
- *
- * Evaluate polynomial
- *
- *
- *
- * SYNOPSIS:
- *
- * int N;
- * double x, y, coef[N+1], polevl[];
- *
- * y = polevl( C, x, N );
- *
- *
- *
- * DESCRIPTION:
- *
- * Evaluates polynomial of degree N:
- *
- * 2 N
- * y = C + C x + C x +...+ C x
- * 0 1 2 N
- *
- * Coefficients are stored in reverse order:
- *
- * coef[0] = C , ..., coef[N] = C .
- * N 0
- *
- * The function p1evl() assumes that coef[N] = 1.0 and is
- * omitted from the array. Its calling arguments are
- * otherwise the same as polevl().
- *
- *
- * SPEED:
- *
- * In the interest of speed, there are no checks for out
- * of bounds arithmetic. This routine is used by most of
- * the functions in the library. Depending on available
- * equipment features, the user may wish to rewrite the
- * program in microcode or assembly language.
- *
- */
- /* polevl.c */
-
-
- double polevl( x, coef, N )
- double x;
- double coef[];
- int N;
- {
- double ans;
- short i;
- register double *p;
-
- p = coef;
- ans = 0.0;
- i = N+1;
-
- do
- ans = ans * x + *p++;
- while( --i );
-
- return( ans );
- }
-
- /* p1evl() */
- /* N
- * Evaluate polynomial when coefficient of x is 1.0.
- * Otherwise same as polevl.
- */
-
- double p1evl( x, coef, N )
- double x;
- double coef[];
- int N;
- {
- double ans;
- register double *p;
- short i;
-
- p = coef;
- ans = x + *p++;
- i = N-1;
-
- do
- ans = ans * x + *p++;
- while( --i );
-
- return( ans );
- }
-