home *** CD-ROM | disk | FTP | other *** search
/ Mega A/V / mega_av.zip / mega_av / GRAPHUTL / FRPOR172.ZIP / MPMATH.H < prev    next >
C/C++ Source or Header  |  1992-03-15  |  5KB  |  179 lines

  1. /*
  2.  *  REMOVED FORMAL PARAMETERS FROM FUNCTION DEFINITIONS (1/4/92)
  3.  */
  4.  
  5.  
  6. #ifndef MPMATH_H
  7. #define MPMATH_H
  8.  
  9. #include <math.h>
  10.  
  11. #ifdef XFRACT
  12. #ifndef _LCOMPLEX_DEFINED
  13. struct lcomplex {
  14.    long x, y;
  15. };
  16. struct complex {
  17.     double x,y;
  18. };
  19. #define _LCOMPLEX_DEFINED
  20. #endif
  21. #define far
  22. #endif
  23.  
  24. #ifndef XFRACT
  25. struct MP {
  26.    int Exp;
  27.         unsigned long Mant;
  28. };
  29. #else
  30. struct MP {
  31.    double val;
  32. };
  33. #endif
  34.  
  35. struct MPC {
  36.         struct MP x, y;
  37. };
  38.  
  39. extern struct MP MPTrigTable[2][4][256], InvHalfPi, HalfPi, InvLn2, Ln2;
  40. extern int MPaccuracy, MPOverflow;
  41.  
  42. /* Mark Peterson's expanded floating point operators.  Automatically uses
  43.    either the 8086 or 80386 processor type specified in global 'cpu'. If
  44.    the operation results in an overflow (result < 2**(2**14), or division
  45.    by zero) the global 'MPoverflow' is set to one. */
  46.  
  47. extern int cpu;
  48.  
  49. struct MP *MPmul(struct MP , struct MP );
  50. struct MP *MPdiv(struct MP , struct MP );
  51. struct MP *MPadd(struct MP , struct MP );
  52. struct MP *MPsub(struct MP , struct MP );
  53. struct MP *MPabs(struct MP );
  54. struct MP *d2MP(double );  /* Convert double to type MP */
  55. double *MP2d(struct MP );  /* Convert type MP to double */
  56. struct MP *fg2MP(long , int ); /* Convert fudged to type MP */
  57.  
  58.  
  59. int MPcmp(struct MP , struct MP );
  60. /* return = -1 if x < y
  61.           = 0 if x == y
  62.           = 1 if x > y */
  63.  
  64. /* Mark Peterson's complex expanded floating point operators */
  65. struct MPC MPCmul(struct MPC , struct MPC );
  66. struct MPC MPCdiv(struct MPC , struct MPC );
  67. struct MPC MPCadd(struct MPC , struct MPC );
  68. struct MPC MPCsub(struct MPC , struct MPC );
  69. int MPCcmp(struct MPC , struct MPC );
  70. struct MPC MPCpow(struct MPC , int );
  71. struct MPC MPCsqr(struct MPC );
  72. struct MP MPCmod(struct MPC );
  73. struct complex MPC2cmplx(struct MPC );
  74. struct MPC cmplx2MPC(struct complex );
  75.  
  76. /* Prototypes for direct calling of processor specific routines */
  77. struct MP *MPmul086(struct MP , struct MP );
  78. struct MP *MPdiv086(struct MP , struct MP );
  79. struct MP *MPadd086(struct MP , struct MP );
  80. struct MP *MPsub086(struct MP , struct MP );
  81. int MPcmp086(struct MP , struct MP );
  82. struct MP *d2MP086(double );
  83. double *MP2d086(struct MP );
  84. struct MP *fg2MP086(long , int );
  85.  
  86. struct MP *MPmul386(struct MP , struct MP );
  87. struct MP *MPdiv386(struct MP , struct MP );
  88. struct MP *MPadd386(struct MP , struct MP );
  89. struct MP *MPsub386(struct MP , struct MP );
  90. int MPcmp386(struct MP , struct MP );
  91. struct MP *d2MP386(double );
  92. double *MP2d386(struct MP );
  93. struct MP *fg2MP386(long , int );
  94.  
  95. /* function pointer support added by Tim Wegner 12/07/89 */
  96. extern int         (*pMPcmp)(struct MP , struct MP );
  97. extern struct MP  *(*pMPmul)(struct MP , struct MP );
  98. extern struct MP  *(*pMPdiv)(struct MP , struct MP );
  99. extern struct MP  *(*pMPadd)(struct MP , struct MP );
  100. extern struct MP  *(*pMPsub)(struct MP , struct MP );
  101. extern struct MP  *(*pd2MP)(double )                ;
  102. extern double     *(*pMP2d)(struct MP )             ;
  103. void setMPfunctions(void);
  104.  
  105.  
  106. /* FPU routines */
  107. extern void FPUaptan387(double *, double *, double *);
  108. extern void FPUcplxmul(struct complex *, struct complex *, struct complex *);
  109. extern void FPUcplxdiv(struct complex *, struct complex *, struct complex *);
  110. extern void FPUsincos(double *, double *, double *);
  111. extern void FPUsinhcosh(double *, double *, double *);
  112. extern void FPUcplxlog(struct complex *, struct complex *);
  113. extern void FPUcplxexp387(struct complex *, struct complex *);
  114. extern struct complex ComplexPower(struct complex, struct complex);
  115.  
  116. /* Integer Routines */
  117. void SinCos086(long , long *, long *);
  118. void SinhCosh086(long , long *, long *);
  119.  
  120. /*** Formula Declarations ***/
  121. typedef enum { D_MATH, M_MATH, L_MATH } MATH_TYPE;
  122. extern MATH_TYPE MathType;
  123.  
  124. int ParseStr(char *Str);
  125. int Formula(void);
  126. int form_per_pixel(void);
  127. int fpFormulaSetup(void);
  128. int mpcFormulaSetup(void);
  129. int intFormulaSetup(void);
  130. /* char *FormStr, *FormName;    BDT commented these out */
  131.  
  132. long
  133. #ifndef XFRACT
  134.    far RegFg2Float(long x, char FudgeFact),
  135.    far RegSftFloat(long x, char Shift),
  136. #else
  137.    far RegFg2Float(long , int ),
  138.    far RegSftFloat(long , int ),
  139. #endif
  140.    far RegFloat2Fg(long , int ),
  141.    far RegDivFloat(long , long ),
  142.    far r16Mul(long , long ),
  143.    far LogFudged(unsigned long , int ),
  144.    far LogFloat14(unsigned long ),
  145.    far ExpFloat14(long );
  146.  
  147. unsigned long far ExpFudged(long , int );
  148.  
  149. #define fDiv(x, y, z) (void)((*(long*)&z) = RegDivFloat(*(long*)&x, *(long*)&y))
  150. #define fMul16(x, y, z) (void)((*(long*)&z) = r16Mul(*(long*)&x, *(long*)&y))
  151. #define fShift(x, Shift, z) (void)((*(long*)&z) = \
  152.    RegSftFloat(*(long*)&x, Shift))
  153. #define Fg2Float(x, f, z) (void)((*(long*)&z) = RegFg2Float(x, f))
  154. #define Float2Fg(x, f) RegFloat2Fg(*(long*)&x, f)
  155. #define fLog14(x, z) (void)((*(long*)&z) = \
  156.         RegFg2Float(LogFloat14(*(long*)&x), 16))
  157. #define fExp14(x, z) (void)((*(long*)&z) = ExpFloat14(*(long*)&x));
  158. #define fSqrt14(x, z) fLog14(x, z); fShift(z, -1, z); fExp14(z, z)
  159.  
  160. #ifndef _LCOMPLEX_DEFINED
  161. struct lcomplex {
  162.    long x, y;
  163. };
  164. #define _LCOMPLEX_DEFINED
  165. #endif
  166.  
  167. union Arg {
  168.    struct complex d;
  169.    struct MPC m;
  170.    struct lcomplex l;
  171. };
  172.  
  173. extern union Arg *Arg1,*Arg2;
  174.  
  175. extern void lStkSin(),lStkCos(),lStkSinh(),lStkCosh(),lStkLog(),lStkExp(),lStkSqr();
  176. extern void dStkSin(),dStkCos(),dStkSinh(),dStkCosh(),dStkLog(),dStkExp(),dStkSqr();
  177.  
  178. #endif
  179.