home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / math / cephes / ldouble / polevll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-17  |  3.6 KB  |  143 lines

  1. /*                            polevll.c
  2.  *                            p1evll.c
  3.  *
  4.  *    Evaluate polynomial
  5.  *
  6.  *
  7.  *
  8.  * SYNOPSIS:
  9.  *
  10.  * int N;
  11.  * long double x, y, coef[N+1], polevl[];
  12.  *
  13.  * y = polevll( x, coef, N );
  14.  *
  15.  *
  16.  *
  17.  * DESCRIPTION:
  18.  *
  19.  * Evaluates polynomial of degree N:
  20.  *
  21.  *                     2          N
  22.  * y  =  C  + C x + C x  +...+ C x
  23.  *        0    1     2          N
  24.  *
  25.  * Coefficients are stored in reverse order:
  26.  *
  27.  * coef[0] = C  , ..., coef[N] = C  .
  28.  *            N                   0
  29.  *
  30.  *  The function p1evll() assumes that coef[N] = 1.0 and is
  31.  * omitted from the array.  Its calling arguments are
  32.  * otherwise the same as polevll().
  33.  *
  34.  *  This module also contains the following globally declared constants:
  35.  * MAXNUML = 1.189731495357231765021263853E4932L;
  36.  * MACHEPL = 5.42101086242752217003726400434970855712890625E-20L;
  37.  * MAXLOGL =  1.1356523406294143949492E4L;
  38.  * MINLOGL = -1.1355137111933024058873E4L;
  39.  * LOGE2L  = 6.9314718055994530941723E-1L;
  40.  * LOG2EL  = 1.4426950408889634073599E0L;
  41.  * PIL     = 3.1415926535897932384626L;
  42.  * PIO2L   = 1.5707963267948966192313L;
  43.  * PIO4L   = 7.8539816339744830961566E-1L;
  44.  *
  45.  * SPEED:
  46.  *
  47.  * In the interest of speed, there are no checks for out
  48.  * of bounds arithmetic.  This routine is used by most of
  49.  * the functions in the library.  Depending on available
  50.  * equipment features, the user may wish to rewrite the
  51.  * program in microcode or assembly language.
  52.  *
  53.  */
  54.  
  55.  
  56. /*
  57. Cephes Math Library Release 2.2:  July, 1992
  58. Copyright 1984, 1987, 1988, 1992 by Stephen L. Moshier
  59. Direct inquiries to 30 Frost Street, Cambridge, MA 02140
  60. */
  61. #include "mconf.h"
  62.  
  63. #if UNK
  64. /* almost 2^16384 */
  65. long double MAXNUML = 1.189731495357231765021263853E4932L;
  66. /* 2^-64 */
  67. long double MACHEPL = 5.42101086242752217003726400434970855712890625E-20L;
  68. /* log( MAXNUML ) */
  69. long double MAXLOGL =  1.1356523406294143949492E4L;
  70. /* log( underflow threshold = 2^(-16382) ) */
  71. long double MINLOGL = -1.1355137111933024058873E4L;
  72. long double LOGE2L  = 6.9314718055994530941723E-1L;
  73. long double LOG2EL  = 1.4426950408889634073599E0L;
  74. long double PIL     = 3.1415926535897932384626L;
  75. long double PIO2L   = 1.5707963267948966192313L;
  76. long double PIO4L   = 7.8539816339744830961566E-1L;
  77. #endif
  78. #if IBMPC
  79. short MAXNUML[] = {0xffff,0xffff,0xffff,0xffff,0x7ffe};
  80. short MAXLOGL[] = {0x79ab,0xd1cf,0x17f7,0xb172,0x400c};
  81. short MINLOGL[] = {0xeb2f,0x1210,0x8c67,0xb16c,0xc00c};
  82. short MACHEPL[] = {0x0000,0x0000,0x0000,0x8000,0x3fbf};
  83. short LOGE2L[]  = {0x79ac,0xd1cf,0x17f7,0xb172,0x3ffe};
  84. short LOG2EL[]  = {0xf0bc,0x5c17,0x3b29,0xb8aa,0x3fff};
  85. short PIL[]     = {0xc235,0x2168,0xdaa2,0xc90f,0x4000};
  86. short PIO2L[]   = {0xc235,0x2168,0xdaa2,0xc90f,0x3fff};
  87. short PIO4L[]   = {0xc235,0x2168,0xdaa2,0xc90f,0x3ffe};
  88. #endif
  89. #if MIEEE
  90. long MAXNUML[] = {0x7ffe0000,0xffffffff,0xffffffff};
  91. long MAXLOGL[] = {0x400c0000,0xb17217f7,0xd1cf79ab};
  92. long MINLOGL[] = {0xc00c0000,0xb16c8c67,0x1210eb2f};
  93. long MACHEPL[] = {0x3fbf0000,0x00000000,0x00000000};
  94. long LOGE2L[]  = {0x3ffe0000,0xb17217f7,0xd1cf79ac};
  95. long LOG2EL[]  = {0x3fff0000,0xb8aa3b29,0x5c17f0bc};
  96. long PIL[]     = {0x40000000,0xc90fdaa2,0x2168c235};
  97. long PIO2L[]   = {0x3fff0000,0xc90fdaa2,0x2168c235};
  98. long PIO4L[]   = {0x3ffe0000,0xc90fdaa2,0x2168c235};
  99. #endif
  100.  
  101.  
  102.  
  103. /* Polynomial evaluator:
  104.  *  P[0] x^n  +  P[1] x^(n-1)  +  ...  +  P[n]
  105.  */
  106. long double polevll( x, P, n )
  107. long double x;
  108. long double *P;
  109. int n;
  110. {
  111. register long double y;
  112.  
  113. y = *P++;
  114. do
  115.     {
  116.     y = y * x + *P++;
  117.     }
  118. while( --n );
  119. return(y);
  120. }
  121.  
  122.  
  123.  
  124. /* Polynomial evaluator:
  125.  *  x^n  +  P[0] x^(n-1)  +  P[1] x^(n-2)  +  ...  +  P[n]
  126.  */
  127. long double p1evll( x, P, n )
  128. long double x;
  129. long double *P;
  130. int n;
  131. {
  132. register long double y;
  133.  
  134. n -= 1;
  135. y = x + *P++;
  136. do
  137.     {
  138.     y = y * x + *P++;
  139.     }
  140. while( --n );
  141. return( y );
  142. }
  143.