home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega A/V
/
mega_av.zip
/
mega_av
/
GRAPHUTL
/
FRPOR172.ZIP
/
MPMATH.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-15
|
5KB
|
179 lines
/*
* REMOVED FORMAL PARAMETERS FROM FUNCTION DEFINITIONS (1/4/92)
*/
#ifndef MPMATH_H
#define MPMATH_H
#include <math.h>
#ifdef XFRACT
#ifndef _LCOMPLEX_DEFINED
struct lcomplex {
long x, y;
};
struct complex {
double x,y;
};
#define _LCOMPLEX_DEFINED
#endif
#define far
#endif
#ifndef XFRACT
struct MP {
int Exp;
unsigned long Mant;
};
#else
struct MP {
double val;
};
#endif
struct MPC {
struct MP x, y;
};
extern struct MP MPTrigTable[2][4][256], InvHalfPi, HalfPi, InvLn2, Ln2;
extern int MPaccuracy, MPOverflow;
/* Mark Peterson's expanded floating point operators. Automatically uses
either the 8086 or 80386 processor type specified in global 'cpu'. If
the operation results in an overflow (result < 2**(2**14), or division
by zero) the global 'MPoverflow' is set to one. */
extern int cpu;
struct MP *MPmul(struct MP , struct MP );
struct MP *MPdiv(struct MP , struct MP );
struct MP *MPadd(struct MP , struct MP );
struct MP *MPsub(struct MP , struct MP );
struct MP *MPabs(struct MP );
struct MP *d2MP(double ); /* Convert double to type MP */
double *MP2d(struct MP ); /* Convert type MP to double */
struct MP *fg2MP(long , int ); /* Convert fudged to type MP */
int MPcmp(struct MP , struct MP );
/* return = -1 if x < y
= 0 if x == y
= 1 if x > y */
/* Mark Peterson's complex expanded floating point operators */
struct MPC MPCmul(struct MPC , struct MPC );
struct MPC MPCdiv(struct MPC , struct MPC );
struct MPC MPCadd(struct MPC , struct MPC );
struct MPC MPCsub(struct MPC , struct MPC );
int MPCcmp(struct MPC , struct MPC );
struct MPC MPCpow(struct MPC , int );
struct MPC MPCsqr(struct MPC );
struct MP MPCmod(struct MPC );
struct complex MPC2cmplx(struct MPC );
struct MPC cmplx2MPC(struct complex );
/* Prototypes for direct calling of processor specific routines */
struct MP *MPmul086(struct MP , struct MP );
struct MP *MPdiv086(struct MP , struct MP );
struct MP *MPadd086(struct MP , struct MP );
struct MP *MPsub086(struct MP , struct MP );
int MPcmp086(struct MP , struct MP );
struct MP *d2MP086(double );
double *MP2d086(struct MP );
struct MP *fg2MP086(long , int );
struct MP *MPmul386(struct MP , struct MP );
struct MP *MPdiv386(struct MP , struct MP );
struct MP *MPadd386(struct MP , struct MP );
struct MP *MPsub386(struct MP , struct MP );
int MPcmp386(struct MP , struct MP );
struct MP *d2MP386(double );
double *MP2d386(struct MP );
struct MP *fg2MP386(long , int );
/* function pointer support added by Tim Wegner 12/07/89 */
extern int (*pMPcmp)(struct MP , struct MP );
extern struct MP *(*pMPmul)(struct MP , struct MP );
extern struct MP *(*pMPdiv)(struct MP , struct MP );
extern struct MP *(*pMPadd)(struct MP , struct MP );
extern struct MP *(*pMPsub)(struct MP , struct MP );
extern struct MP *(*pd2MP)(double ) ;
extern double *(*pMP2d)(struct MP ) ;
void setMPfunctions(void);
/* FPU routines */
extern void FPUaptan387(double *, double *, double *);
extern void FPUcplxmul(struct complex *, struct complex *, struct complex *);
extern void FPUcplxdiv(struct complex *, struct complex *, struct complex *);
extern void FPUsincos(double *, double *, double *);
extern void FPUsinhcosh(double *, double *, double *);
extern void FPUcplxlog(struct complex *, struct complex *);
extern void FPUcplxexp387(struct complex *, struct complex *);
extern struct complex ComplexPower(struct complex, struct complex);
/* Integer Routines */
void SinCos086(long , long *, long *);
void SinhCosh086(long , long *, long *);
/*** Formula Declarations ***/
typedef enum { D_MATH, M_MATH, L_MATH } MATH_TYPE;
extern MATH_TYPE MathType;
int ParseStr(char *Str);
int Formula(void);
int form_per_pixel(void);
int fpFormulaSetup(void);
int mpcFormulaSetup(void);
int intFormulaSetup(void);
/* char *FormStr, *FormName; BDT commented these out */
long
#ifndef XFRACT
far RegFg2Float(long x, char FudgeFact),
far RegSftFloat(long x, char Shift),
#else
far RegFg2Float(long , int ),
far RegSftFloat(long , int ),
#endif
far RegFloat2Fg(long , int ),
far RegDivFloat(long , long ),
far r16Mul(long , long ),
far LogFudged(unsigned long , int ),
far LogFloat14(unsigned long ),
far ExpFloat14(long );
unsigned long far ExpFudged(long , int );
#define fDiv(x, y, z) (void)((*(long*)&z) = RegDivFloat(*(long*)&x, *(long*)&y))
#define fMul16(x, y, z) (void)((*(long*)&z) = r16Mul(*(long*)&x, *(long*)&y))
#define fShift(x, Shift, z) (void)((*(long*)&z) = \
RegSftFloat(*(long*)&x, Shift))
#define Fg2Float(x, f, z) (void)((*(long*)&z) = RegFg2Float(x, f))
#define Float2Fg(x, f) RegFloat2Fg(*(long*)&x, f)
#define fLog14(x, z) (void)((*(long*)&z) = \
RegFg2Float(LogFloat14(*(long*)&x), 16))
#define fExp14(x, z) (void)((*(long*)&z) = ExpFloat14(*(long*)&x));
#define fSqrt14(x, z) fLog14(x, z); fShift(z, -1, z); fExp14(z, z)
#ifndef _LCOMPLEX_DEFINED
struct lcomplex {
long x, y;
};
#define _LCOMPLEX_DEFINED
#endif
union Arg {
struct complex d;
struct MPC m;
struct lcomplex l;
};
extern union Arg *Arg1,*Arg2;
extern void lStkSin(),lStkCos(),lStkSinh(),lStkCosh(),lStkLog(),lStkExp(),lStkSqr();
extern void dStkSin(),dStkCos(),dStkSinh(),dStkCosh(),dStkLog(),dStkExp(),dStkSqr();
#endif