home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / astrnomy / de118i.zip / POLEVLL.C < prev    next >
C/C++ Source or Header  |  1993-01-30  |  4KB  |  121 lines

  1. #ifndef NOINCS
  2. #include "mconf.h"
  3. #endif
  4.  
  5. #if UNK
  6. /* almost 2^16384 */
  7. long double MAXNUML = 1.189731495357231765021263853E4932L;
  8. /* 2^-64 */
  9. long double MACHEPL = 5.42101086242752217003726400434970855712890625E-20L;
  10. /* log( MAXNUML ) */
  11. long double MAXLOGL =  1.1356523406294143949492E4L;
  12. /* log( underflow threshold = 2^(-16382) ) */
  13. long double MINLOGL = -1.1355137111933024058873E4L;
  14. long double LOGE2L  = 6.9314718055994530941723E-1L;
  15. long double LOG2EL  = 1.4426950408889634073599E0L;
  16. long double PIL     = 3.1415926535897932384626L;
  17. long double PIO2L   = 1.5707963267948966192313L;
  18. long double PIO4L   = 7.8539816339744830961566E-1L;
  19. long double Zero = 0.0L;
  20. long double Fourth = 0.25L;
  21. long double Half = 0.5L;
  22. long double One = 1.0L;
  23. long double OneandaHalf = 1.5L;
  24. long double Two = 2.0L;
  25. long double Three = 3.0L;
  26. long double ThreeandaHalf = 3.5L;
  27. long double Four = 4.0L;
  28. long double Five = 5.0L;
  29. long double Six = 6.0L;
  30. long double Ten = 10.0L;
  31. #endif
  32. #if IBMPC
  33. short MAXNUML[] = {0xffff,0xffff,0xffff,0xffff,0x7ffe, XPD};
  34. short MAXLOGL[] = {0x79ab,0xd1cf,0x17f7,0xb172,0x400c, XPD};
  35. short MINLOGL[] = {0xeb2f,0x1210,0x8c67,0xb16c,0xc00c, XPD};
  36. short MACHEPL[] = {0x0000,0x0000,0x0000,0x8000,0x3fbf, XPD};
  37. short LOGE2L[]  = {0x79ac,0xd1cf,0x17f7,0xb172,0x3ffe, XPD};
  38. short LOG2EL[]  = {0xf0bc,0x5c17,0x3b29,0xb8aa,0x3fff, XPD};
  39. short PIL[]     = {0xc235,0x2168,0xdaa2,0xc90f,0x4000, XPD};
  40. short PIO2L[]   = {0xc235,0x2168,0xdaa2,0xc90f,0x3fff, XPD};
  41. short PIO4L[]   = {0xc235,0x2168,0xdaa2,0xc90f,0x3ffe, XPD};
  42. short Zero[]    = {0x0000,0x0000,0x0000,0x0000,0x0000, XPD};
  43. short Fourth[]  = {0x0000,0x0000,0x0000,0x8000,0x3ffd, XPD};
  44. short Half[]    = {0x0000,0x0000,0x0000,0x8000,0x3ffe, XPD};
  45. short One[]     = {0x0000,0x0000,0x0000,0x8000,0x3fff, XPD};
  46. short OneandaHalf[] = {0x0000,0x0000,0x0000,0xc000,0x3fff, XPD};
  47. short Two[]     = {0x0000,0x0000,0x0000,0x8000,0x4000, XPD};
  48. short Three[]   = {0x0000,0x0000,0x0000,0xc000,0x4000, XPD};
  49. short ThreeandaHalf[]   = {0x0000,0x0000,0x0000,0xe000,0x4000, XPD};
  50. short Four[]    = {0x0000,0x0000,0x0000,0x8000,0x4001, XPD};
  51. short Five[]    = {0x0000,0x0000,0x0000,0xa000,0x4001, XPD};
  52. short Six[]     = {0x0000,0x0000,0x0000,0xc000,0x4001, XPD};
  53. short Ten[]     = {0x0000,0x0000,0x0000,0xa000,0x4002, XPD};
  54. #endif
  55. #if MIEEE
  56. long MAXNUML[] = {0x7ffe0000,0xffffffff,0xffffffff};
  57. long MAXLOGL[] = {0x400c0000,0xb17217f7,0xd1cf79ab};
  58. long MINLOGL[] = {0xc00c0000,0xb16c8c67,0x1210eb2f};
  59. long MACHEPL[] = {0x3fbf0000,0x00000000,0x00000000};
  60. long LOGE2L[]  = {0x3ffe0000,0xb17217f7,0xd1cf79ac};
  61. long LOG2EL[]  = {0x3fff0000,0xb8aa3b29,0x5c17f0bc};
  62. long PIL[]     = {0x40000000,0xc90fdaa2,0x2168c235};
  63. long PIO2L[]   = {0x3fff0000,0xc90fdaa2,0x2168c235};
  64. long PIO4L[]   = {0x3ffe0000,0xc90fdaa2,0x2168c235};
  65. long Zero[]    = {0x00000000,0x00000000,0x00000000};
  66. long Fourth[]  = {0x3ffd0000,0x80000000,0x00000000};
  67. long Half[]    = {0x3ffe0000,0x80000000,0x00000000};
  68. long One[]     = {0x3fff0000,0x80000000,0x00000000};
  69. long OneandaHalf[] = {0x3fff0000,0xc0000000,0x00000000};
  70. long Two[]     = {0x40000000,0x80000000,0x00000000};
  71. long Three[]   = {0x40000000,0xc0000000,0x00000000};
  72. long ThreeandaHalf[] = {0x40000000,0xe0000000,0x00000000};
  73. long Four[]    = {0x40010000,0x80000000,0x00000000};
  74. long Five[]    = {0x40010000,0xa0000000,0x00000000};
  75. long Six[]     = {0x40010000,0xc0000000,0x00000000};
  76. long Ten[]     = {0x40020000,0xa0000000,0x00000000};
  77. #endif
  78.  
  79.  
  80.  
  81. /* Polynomial evaluator:
  82.  *  P[0] x^n  +  P[1] x^(n-1)  +  ...  +  P[n]
  83.  */
  84. long double polevll( x, P, n )
  85. long double x;
  86. long double *P;
  87. int n;
  88. {
  89. register long double y;
  90.  
  91. y = *P++;
  92. do
  93.     {
  94.     y = y * x + *P++;
  95.     }
  96. while( --n );
  97. return(y);
  98. }
  99.  
  100.  
  101.  
  102. /* Polynomial evaluator:
  103.  *  x^n  +  P[0] x^(n-1)  +  P[1] x^(n-2)  +  ...  +  P[n]
  104.  */
  105. long double p1evll( x, P, n )
  106. long double x;
  107. long double *P;
  108. int n;
  109. {
  110. register long double y;
  111.  
  112. n -= 1;
  113. y = x + *P++;
  114. do
  115.     {
  116.     y = y * x + *P++;
  117.     }
  118. while( --n );
  119. return( y );
  120. }
  121.