home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / rpn30src.zip / FTNS.H < prev    next >
C/C++ Source or Header  |  1990-05-22  |  3KB  |  128 lines

  1. /*
  2. | ftns.h - prototypes and constants shared between ftns.c and process.c
  3. |
  4. | v3.0 90.05.14
  5. |    Add some constants; prototypes for linear-regression functions
  6. |    and gamma/factorial function; memory[] reduced to 50 (long double)
  7. |    registers (from 100 (double) registers).
  8. | 2:37:00  1/1/1990
  9. */
  10. #ifndef FTNS_H
  11. #define FTNS_H
  12.  
  13. #define MEMSIZE    100    /** # of available memory-storage locations **/
  14.  
  15. #define B0    90    /** Registers used for linear regressions **/
  16. #define B1    91    /**   and linear interpolations.      **/
  17. #define SB0    92
  18. #define TB0    93
  19. #define SB1    94
  20. #define TB1    95
  21. #define SYX    96
  22. #define R2    97
  23. #define FR    98
  24. #define COV    99
  25.  
  26. #define ONE    (long double)1.0
  27. #define TWO    (long double)2.0
  28.  
  29. #define log_2        (double)(0.301029995663981198)
  30. #define RAD_TO_DEG    (double)(57.2957795131)
  31. #define DEG_TO_RAD    (double)(0.0174532925199432955)
  32. #define Rad_Deg        RAD_TO_DEG
  33.  
  34. #define NUM_CONSTS  6
  35. #define pi         (double)(3.14159265358979324)
  36. #define C    (double)299792.4562        /* km/second */
  37. #define FC    (double)1797610211686.842    /* furlongs/fortnight */
  38. #define PLANCK    ((double)6.6261965e-34)        /* Joules/second */
  39. #define AVOGADRO    ((double)6.0221694e+23)        /* per mole */
  40. #define EPSILON0    ((double)8.854e-12)
  41.             /* Farads/meter - permittivity of free space */
  42.  
  43. typedef struct {
  44.     char *name;
  45.     double val;
  46. } const_struct;
  47. typedef double C_DECL (*f_ptr)(double);
  48. typedef void (*vf_ptr)(void);
  49.  
  50. #define UNARY    0
  51. #define TRIG    1
  52. #define I_TRIG    2
  53. f_ptr  funct_1(char *name, int type);
  54. vf_ptr funct_0(char *name);
  55.  
  56. double C_DECL frac(double x);
  57. double C_DECL p10(double x);
  58. double C_DECL fact(double x);
  59.  
  60. /** these prototypes shouldn't be needed... **/
  61. double C_DECL dec_hrs(double h_ms);
  62. double C_DECL hms(double dec_hr);
  63. double C_DECL log2(double x);
  64. double C_DECL squar(double x);
  65.  
  66. double C_DECL gamma(double x);
  67. double C_DECL interpx(double y);
  68. double C_DECL interpy(double x);
  69.  
  70. void clrreg(int first, int last);
  71. void sumplus(void);
  72. void summinus(void);
  73. void geomean(void);
  74. void harmean(void);
  75. void mean(void);
  76. void stddev(void);
  77. void linreg(void);
  78. void linstats(void);
  79. void lin_coeffs(void);
  80.  
  81. void ru(void);
  82. void rd(void);
  83. void power(void);
  84.  
  85. void   shift_lastx(void);        /** utility ftns   **/
  86. void   clear_state(char *label);    /** from process.c **/
  87. void   push(void);
  88. void   pop(void);
  89. int    mul_ok(double, double, char *);
  90.  
  91. #if 0
  92. /** these have been superceded by signal(SIGFPE...) **/
  93. int    div_ok(double, double, char *);
  94. int    add_ok(double, double, char *);
  95. #define  sub_ok(a,b,c)        add_ok( (a), -(b), (c) )
  96. #endif
  97.  
  98. #ifdef FTNS
  99.  
  100. int  stack_popped;        /** needed for undoing math errors   **/
  101. int  math_error = 0;        /** records whether a math error has **/
  102.                 /** occurred, for cleaner recovery   **/
  103. long double memory[ MEMSIZE ];
  104. long double tmpLX;        /* used to restore lastX in case of error  */
  105. int    stacklift;        /* All ftns except sum+, sum-, Enter, clX  */
  106.                 /*  enable stacklift for following numbers */
  107. const_struct constants[] = {
  108.     {"pi", pi},
  109.     {"c", C},
  110.     {"fc", FC},
  111.     {"planck", PLANCK},
  112.     {"avogadro", AVOGADRO},
  113.     {"epsi", EPSILON0}
  114. };
  115.  
  116. #else    /* !FTNS */
  117.  
  118. extern int  stack_popped;
  119. extern int  math_error;
  120. extern long double memory[ MEMSIZE ];
  121. extern long double tmpLX;
  122. extern int    stacklift;
  123. extern const_struct constants[];
  124.  
  125. #endif    /* FTNS */
  126.  
  127. #endif  /* FTNS_H */
  128.