diff --git a/psys/include/p2c/math.h b/psys/include/p2c/math.h index 1a82b60bb1fd1ed773eac83410196afe106a4c6e..b5aebccf5ca05dc1e82d8a6de36e6ada7ff12b19 100644 --- a/psys/include/p2c/math.h +++ b/psys/include/p2c/math.h @@ -1,6 +1,7 @@ #ifndef MATH_H #define MATH_H +#include <p2c/p2c.h> #include <p2c/newasm.h> #ifdef MATH_G @@ -43,7 +44,7 @@ vextern long ma_dummy; /* obsolete -- use initrandom/seedrandom */ -extern int ma_trapuf (int flag); +extern int ma_trapuf (int flag) DEPRECATED; extern double ma_rround (double r); extern double ma_rrounde (double r); extern double ma_rtrunc (double r); @@ -97,10 +98,10 @@ extern double ma_hypot (double a, double b); extern void ma_quadrsolve (double a, double b, double c, double *x1, double *x2); extern void ma_sincos (double r, double *s, double *c); -extern double ma_tan (double r); -extern double ma_arcsin (double r); -extern double ma_arccos (double r); -extern double ma_arctan2 (double r1, double r2); +extern double ma_tan (double r) DEPRECATED; /* Use tan */ +extern double ma_arcsin (double r) DEPRECATED; /* use asin */ +extern double ma_arccos (double r) DEPRECATED; /* use acos */ +extern double ma_arctan2 (double r1, double r2) DEPRECATED ; /* use atan2 */ /* = arctan(r1/r2) */ extern void ma_sincosd (double r, double *s, double *c); @@ -111,12 +112,12 @@ extern double ma_arcsind (double r); extern double ma_arccosd (double r); extern double ma_arctand (double r); extern double ma_arctand2 (double r1, double r2); -extern double ma_sinh (double r); -extern double ma_cosh (double r); -extern double ma_tanh (double r); -extern double ma_arcsinh (double r); -extern double ma_arccosh (double r); -extern double ma_arctanh (double r); +extern double ma_sinh (double r) DEPRECATED; /* use sinh */ +extern double ma_cosh (double r) DEPRECATED; /* use cosh */ +extern double ma_tanh (double r) DEPRECATED; /* use tanh */ +extern double ma_arcsinh (double r) DEPRECATED; /* use asinh */ +extern double ma_arccosh (double r) DEPRECATED; /* use acosh */ +extern double ma_arctanh (double r) DEPRECATED; /* use atanh */ extern double ma_lngamma (double x, int *minus); extern double ma_rgamma (double x); extern long ma_ifactorial (long n); @@ -167,17 +168,16 @@ extern char *ma_strfmtcomplex2 (char *ma_Result, ma_complex a, long wid, extern void ma_strsubreadcomplex (char *buf, long first, long *pos, ma_complex *a); extern ma_complex ma_strreadcomplex (char *buf); -extern double ma_rrand (); -extern long ma_rand2 (long min, long max); -extern double ma_rrand2 (double min, double max); -extern double ma_nrand2 (double mean, double sdev); -extern void ma_initrandom (void * *s); -extern void ma_seedrandom (void * *s, long seed); -extern double ma_urandom (void * s); -extern long ma_irandom (void * s, long min, long max); -extern double ma_rrandom (void * s, double min, double max); -extern double ma_nrandom (void * s, double mean, double sdev); - +extern double ma_rrand () DEPRECATED; +extern long ma_rand2 (long min, long max) DEPRECATED; +extern double ma_rrand2 (double min, double max) DEPRECATED; +extern double ma_nrand2 (double mean, double sdev) DEPRECATED; +extern void ma_initrandom (void * *s) DEPRECATED; +extern void ma_seedrandom (void * *s, long seed) DEPRECATED; +extern double ma_urandom (void * s) DEPRECATED; +extern long ma_irandom (void * s, long min, long max) DEPRECATED; +extern double ma_rrandom (void * s, double min, double max) DEPRECATED; +extern double ma_nrandom (void * s, double mean, double sdev) DEPRECATED; #undef vextern diff --git a/psys/include/p2c/newkbd.h b/psys/include/p2c/newkbd.h index 6dd536aaed2ae7d7b6d13c6ac9cbb1383b2bf4b7..d1837d5607274ec4039f4adc440c95fbb571e821 100644 --- a/psys/include/p2c/newkbd.h +++ b/psys/include/p2c/newkbd.h @@ -126,6 +126,7 @@ extern void nk_unmap (int numkeys, nk_remap_info *newdefs); extern void nk_newkbdinstall (); extern void nk_newkbdremove (); +#undef vextern #endif /*NEWKBD_H*/ diff --git a/psys/include/p2c/rnd.h b/psys/include/p2c/rnd.h index 129d368725027a2184003fc18545e6e7053acabf..507c8a375532f85b6bf7b1106c255532e3b1d9fa 100644 --- a/psys/include/p2c/rnd.h +++ b/psys/include/p2c/rnd.h @@ -1,7 +1,12 @@ #ifndef RND_H #define RND_H -extern void P_random(); -extern long P_rand(); +#include <p2c/p2c.h> + +/** + * Use the c library random methods + */ +extern void P_random() DEPRECATED; +extern long P_rand() DEPRECATED; #endif /* RND_H */ diff --git a/psys/src/math.c b/psys/src/math.c index 05dc9ebf0d89fd84938badee4063af1924846ba9..5fc5088521cb904f5baf317f43aae605852fe8e6 100644 --- a/psys/src/math.c +++ b/psys/src/math.c @@ -31,7 +31,6 @@ const ma_complex ma_cpi = { }; - #include <p2c/newci.h> #include <p2c/rnd.h> #include <p2c/strings.h> @@ -70,8 +69,7 @@ int ma_trapuf(int flag) /* General operations on reals */ -double ma_rround(r) -double r; +double ma_rround(double r) { int minus; double r2; @@ -108,8 +106,7 @@ double r; -double ma_rrounde(r) -double r; +double ma_rrounde(double r) { int minus; double r2; @@ -153,8 +150,7 @@ double r; } -double ma_rtrunc(r) -double r; +double ma_rtrunc(double r) { int minus; double r2; @@ -189,10 +185,7 @@ double r; return r; } - - -double ma_rfloor(r) -double r; +double ma_rfloor(double r) { double a; @@ -207,9 +200,7 @@ double r; } } - -double ma_rceil(r) -double r; +double ma_rceil(double r) { double a; @@ -224,27 +215,20 @@ double r; } } - -double ma_rfrac(r) -double r; +double ma_rfrac(double r) { return (r - ma_rtrunc(r)); } - - - /* Handy predicates */ -int ma_isinteger(r) -double r; +int ma_isinteger(double r) { return (r >= LONG_MIN && r <= LONG_MAX && (long)floor(r + 0.5) == r); } -int ma_isint(r) -double r; +int ma_isint(double r) { if (r >= LONG_MIN && r <= LONG_MAX) return ((long)floor(r + 0.5) == r); @@ -253,8 +237,7 @@ double r; } -int ma_rnequal(a, b, eps) -double a, b, eps; +int ma_rnequal(double a, double b, double eps) { if (a == b) return true; @@ -263,12 +246,9 @@ double a, b, eps; } - - /* Operations on integers */ -long ma_igcd(a, b) -long a, b; +long ma_igcd(long a, long b) { long t; short sa, sb, st; @@ -308,13 +288,9 @@ long a, b; return a; } - - - /* Handy functions for real numbers */ -double ma_rmod(a, b) -double a, b; +double ma_rmod(double a, double b) { double r; @@ -326,9 +302,7 @@ double a, b; } -double ma_rmod2(a, b, q) -double a, b; -long *q; +double ma_rmod2(double a, double b, long *q) { double ma_Result, r; @@ -353,9 +327,7 @@ long *q; return ma_Result; } - -double ma_rrem(a, b) -double a, b; +double ma_rrem(double a, double b) { double r; @@ -367,8 +339,7 @@ double a, b; } -double rrem_ieee(a, b) -double a, b; +double rrem_ieee(double a, double b) { double r; @@ -380,8 +351,7 @@ double a, b; } -long ma_sgn(r) -double r; +long ma_sgn(double r) { if (r > 0) return 1; @@ -394,8 +364,7 @@ double r; } -double ma_sgn2(r, s) -double r, s; +double ma_sgn2(double r, double s) { if (s > 0) return fabs(r); @@ -407,9 +376,7 @@ double r, s; } } - -double ma_min2(a, b) -double a, b; +double ma_min2(double a, double b) { if (a < b) return a; @@ -418,8 +385,7 @@ double a, b; } -double ma_min3(a, b, c) -double a, b, c; +double ma_min3(double a, double b, double c) { if (a < b) { if (a < c) @@ -434,9 +400,7 @@ double a, b, c; } } - -double ma_min4(a, b, c, d) -double a, b, c, d; +double ma_min4(double a, double b, double c, double d) { if (a < b) { if (a < c) { @@ -466,8 +430,7 @@ double a, b, c, d; } -double ma_max2(a, b) -double a, b; +double ma_max2(double a, double b) { if (a > b) return a; @@ -475,9 +438,7 @@ double a, b; return b; } - -double ma_max3(a, b, c) -double a, b, c; +double ma_max3(double a, double b, double c) { if (a > b) { if (a > c) @@ -493,8 +454,7 @@ double a, b, c; } -double ma_max4(a, b, c, d) -double a, b, c, d; +double ma_max4(double a, double b, double c, double d) { if (a > b) { if (a > c) { @@ -524,30 +484,25 @@ double a, b, c, d; } -double ma_mean2(a, b) -double a, b; +double ma_mean2(double a, double b) { return ((a + b) * 0.5); } -double ma_mean3(a, b, c) -double a, b, c; +double ma_mean3(double a, double b, double c) { return ((a + b + c) / 3); } -double ma_mean4(a, b, c, d) -double a, b, c, d; +double ma_mean4(double a, double b, double c, double d) { return ((a + b + c + d) * 0.25); } - -void ma_rswap2(a, b) -double *a, *b; +void ma_rswap2(double *a, double *b) { double t; @@ -557,44 +512,23 @@ double *a, *b; } -void ma_rsort2(a, b) -double *a, *b; +void ma_rsort2(double *a, double *b) { - double t; - if (*a <= *b) return; - t = *a; - *a = *b; - *b = t; + ma_rswap2(a, b); } -void ma_rsort3(a, b, c) -double *a, *b, *c; +void ma_rsort3(double *a, double *b, double *c) { - double t; - - if (*a > *b) { - t = *a; - *a = *b; - *b = t; - } - if (*b > *c) { - t = *b; - *b = *c; - *c = t; - } - if (*a <= *b) - return; - t = *a; - *a = *b; - *b = t; + ma_rsort2(a,b); + ma_rsort2(b,c); + ma_rsort2(a,b); } -void ma_rsort4(a, b, c, d) -double *a, *b, *c, *d; +void ma_rsort4(double *a, double *b, double *c, double *d) { double t; @@ -617,38 +551,25 @@ double *a, *b, *c, *d; } -double ma_rbound(min, r, max) -double min, r, max; +double ma_rbound(double min, double r, double max) { - if (min <= max) { - if (r <= min) - return min; - else { - if (r >= max) - return max; - else - return r; - } - } else { - if (r <= max) - return max; - else if (r >= min) - return min; - else - return r; - } + if (min <= max) { + ma_rswap2(&min, &max); + } + if (r <= max) + return max; + else if (r >= min) + return min; + else + return r; } - -int ma_between(min, r, max) -double min, r, max; +int ma_between(double min, double r, double max) { return ((min <= r && r <= max) || (max <= r && r <= min)); } - -int ma_betweenm(min, r, max, margin) -double min, r, max, margin; +int ma_betweenm(double min, double r, double max, double margin) { if (min < max) return (min - margin <= r && r <= max + margin); @@ -656,25 +577,19 @@ double min, r, max, margin; return (max - margin <= r && r <= min + margin); } - -void ma_amin(min, r) -double *min, r; +void ma_amin(double *min, double r) { if (r < *min) *min = r; } - -void ma_amax(max, r) -double *max, r; +void ma_amax(double *max, double r) { if (r > *max) *max = r; } - -void ma_aminmax(min, max, r) -double *min, *max, r; +void ma_aminmax(double *min, double *max, double r) { if (r < *min) *min = r; @@ -682,13 +597,9 @@ double *min, *max, r; *max = r; } - - - /* Epsilons */ -double ma_rsucc(r) -double r; +double ma_rsucc(double r) { na_quadword q; @@ -714,8 +625,7 @@ double r; } -double ma_rpred(r) -double r; +double ma_rpred(double r) { na_quadword q; @@ -743,17 +653,9 @@ double r; } - - - - /* String munching */ -static void formatreal(buf, r, wid, prec, flags, minv, maxv) -char *buf; -double r; -long wid, prec, flags; -double minv, maxv; +static void formatreal(char *buf, double r, long wid, long prec, long flags, double minv, double maxv) { long i, j, pwid, maxlen, expon; int nowid, carry, minus; @@ -862,8 +764,6 @@ double minv, maxv; expon = strtol(buf + i, &STR1, 10); j = STR1 - buf + 1; buf[i - 1] = '\0'; -/* p2c: math.text, line 1013: - * Note: Modification of string length may translate incorrectly */ if (expon < 0) wid--; if (labs(expon) >= 10) { @@ -888,13 +788,11 @@ double minv, maxv; else pwid = wid; } - if (strlen(buf) > pwid) { + if (strlen(buf) > (unsigned long)pwid) { i = strposc(buf, '.', 1L); maxlen = P_imax2(pwid, i); carry = (buf[maxlen] >= '5'); buf[maxlen] = '\0'; -/* p2c: math.text, line 1039: - * Note: Modification of string length may translate incorrectly */ while (carry && maxlen >= 1) { if (buf[maxlen - 1] == '.') { maxlen--; @@ -939,12 +837,7 @@ double minv, maxv; } - - -char *ma_strfmtreal(ma_Result, r, wid, prec) -char *ma_Result; -double r; -long wid, prec; +char *ma_strfmtreal(char *ma_Result, double r, long wid, long prec) { char s[256]; @@ -953,11 +846,7 @@ long wid, prec; } -char *ma_strfmtreal2(ma_Result, r, wid, prec, flags, min, max) -char *ma_Result; -double r; -long wid, prec, flags; -double min, max; +char *ma_strfmtreal2(char *ma_Result, double r, long wid, long prec, long flags, double min, double max) { char s[256]; @@ -965,25 +854,15 @@ double min, max; return strcpy(ma_Result, s); } - - - - - - - /* Logarithms and roots */ -double ma_log(r) -double r; +double ma_log(double r) { return (log(r) * ma_iln10); } -double ma_ytoi(y, i) -double y; -long i; +double ma_ytoi(double y, long i) { double yy; @@ -1012,10 +891,7 @@ long i; return 0.0; /* should never happen */ } - -double ma_yrooti(y, i) -double y; -long i; +double ma_yrooti(double y, long i) { double ma_Result; @@ -1054,9 +930,7 @@ long i; return ma_Result; } - -double ma_ytox(y, x) -double y, x; +double ma_ytox(double y, double x) { long i; @@ -1079,8 +953,7 @@ double y, x; } -double ma_mytox(y, x) -double y, x; +double ma_mytox(double y, double x) { if (y > 0) return exp(x * log(y)); @@ -1090,8 +963,7 @@ double y, x; /* Warning: this is almost, but not quite, monotonic*/ -double ma_tentox(x) -double x; +double ma_tentox(double x) { long i; @@ -1107,15 +979,13 @@ double x; } -double ma_mtentox(x) -double x; +double ma_mtentox(double x) { return exp(x * ma_ln10); } -double ma_hypot(a, b) -double a, b; +double ma_hypot(double a, double b) { double TEMP; @@ -1143,8 +1013,7 @@ double a, b; } -void ma_quadrsolve(a, b, c, x1, x2) -double a, b, c, *x1, *x2; +void ma_quadrsolve(double a, double b, double c, double *x1, double *x2) { double d, q; @@ -1177,28 +1046,22 @@ double a, b, c, *x1, *x2; } - - - /* Trigonometric and inverse trigonometric functions */ -void ma_sincos(r, s, c) -double r, *s, *c; +void ma_sincos(double r, double *s, double *c) { *s = sin(r); *c = cos(r); } -double ma_tan(r) -double r; +double ma_tan(double r) { return (sin(r) / cos(r)); } -double ma_arctan2(r1, r2) -double r1, r2; +double ma_arctan2(double r1, double r2) { /* = arctan(r1/r2) */ if (r1 == 0) { @@ -1223,30 +1086,21 @@ double r1, r2; } } - -double ma_arcsin(r) -double r; +double ma_arcsin(double r) { return (ma_arctan2(r, sqrt(1 - r * r))); } -double ma_arccos(r) -double r; +double ma_arccos(double r) { return (ma_arctan2(sqrt(1 - r * r), r)); } - - - - - /* Trigonometric functions in degrees */ /* Warning: these may be slightly non-monotonic */ -void ma_sincosd(r, s, c) -double r, *s, *c; +void ma_sincosd(double r, double *s, double *c) { long i; @@ -1291,8 +1145,7 @@ double r, *s, *c; } -double ma_sind(r) -double r; +double ma_sind(double r) { long i; @@ -1315,8 +1168,7 @@ double r; } -double ma_cosd(r) -double r; +double ma_cosd(double r) { long i; @@ -1339,8 +1191,7 @@ double r; } -double ma_tand(r) -double r; +double ma_tand(double r) { long i; @@ -1367,29 +1218,25 @@ double r; } -double ma_arcsind(r) -double r; +double ma_arcsind(double r) { return (ma_arcsin(r) * ma_rd); } -double ma_arccosd(r) -double r; +double ma_arccosd(double r) { return (ma_arccos(r) * ma_rd); } -double ma_arctand(r) -double r; +double ma_arctand(double r) { return (atan(r) * ma_rd); } -double ma_arctand2(r1, r2) -double r1, r2; +double ma_arctand2(double r1, double r2) { /* = arctand(r1/r2) */ if (r1 == 0) { @@ -1425,14 +1272,9 @@ double r1, r2; } - - - - /* Hyperbolic functions */ -double ma_sinh(r) -double r; +double ma_sinh(double r) { double e; @@ -1440,9 +1282,7 @@ double r; return ((e * e - 1) / (2 * e)); } - -double ma_cosh(r) -double r; +double ma_cosh(double r) { double e; @@ -1451,8 +1291,7 @@ double r; } -double ma_tanh(r) -double r; +double ma_tanh(double r) { double e; @@ -1474,20 +1313,15 @@ double r; } - - - /* Inverse hyperbolic functions */ -double ma_arcsinh(r) -double r; +double ma_arcsinh(double r) { return log(r + sqrt(r * r + 1)); } -double ma_arccosh(r) -double r; +double ma_arccosh(double r) { if (r < 1.0) /* bad argument to SQRT */ _Escape(-17); @@ -1498,13 +1332,11 @@ double r; } -double ma_arctanh(r) -double r; +double ma_arctanh(double r) { return (log((1 + r) / (1 - r)) * 0.5); } - #define c1_ 76.18009173 /*from Numerical Recipes*/ #define c2_ (-86.50532033) #define c3 24.01409822 @@ -1514,15 +1346,9 @@ double r; #define stp 2.50662827465 /*sqrt(2*pi)*/ - - - - /* Special functions */ -double ma_lngamma(x, minus) -double x; -int *minus; +double ma_lngamma(double x, int *minus) { double ma_Result, xx, sinpix, val, val2; long ival, form; @@ -1557,7 +1383,6 @@ int *minus; val = (xx - 0.5) * log(val) - val + log(stp * (1 + c1_ / xx + c2_ / (xx + 1) + c3 / (xx + 2) + c4 / (xx + 3) + c5 / (xx + 4) + c6 / (xx + 5))); -/* p2c: math.text, line 1698: Note: Line breaker spent 1.0+0.33 seconds, 1807 tries on line 1578 */ switch (form) { case 0: @@ -1591,8 +1416,7 @@ int *minus; #undef stp -double ma_rgamma(x) -double x; +double ma_rgamma(double x) { int minus; double val; @@ -1620,13 +1444,9 @@ const tabletype table = { }; - - - /* Combinatorial functions */ -long ma_ifactorial(n) -long n; +long ma_ifactorial(long n) { if ((unsigned long)n > ifactmaxfast) _Escape(-4); @@ -1637,8 +1457,7 @@ long n; } -double ma_lnfactorial(n) -long n; +double ma_lnfactorial(long n) { int minus; long i; @@ -1676,8 +1495,7 @@ long n; } -long ma_ibincoef(a, b) -long a, b; +long ma_ibincoef(long a, long b) { long res, i; @@ -1705,8 +1523,7 @@ long a, b; } -double ma_rbincoef(a, b) -long a, b; +double ma_rbincoef(long a, long b) { if (a < b) _Escape(-6); @@ -1722,14 +1539,9 @@ long a, b; } - - - - /* Complex number operations */ -ma_complex ma_cmake(r, i) -double r, i; +ma_complex ma_cmake(double r, double i) { ma_complex ma_Result; @@ -1739,8 +1551,7 @@ double r, i; } -ma_complex ma_creal(r) -double r; +ma_complex ma_creal(double r) { ma_complex ma_Result; @@ -1750,8 +1561,7 @@ double r; } -ma_complex ma_cimag(i) -double i; +ma_complex ma_cimag(double i) { ma_complex ma_Result; @@ -1761,8 +1571,7 @@ double i; } -ma_complex ma_cadd(a, b) -ma_complex a, b; +ma_complex ma_cadd(ma_complex a,ma_complex b) { ma_complex ma_Result; @@ -1772,8 +1581,7 @@ ma_complex a, b; } -ma_complex ma_csub(a, b) -ma_complex a, b; +ma_complex ma_csub(ma_complex a, ma_complex b) { ma_complex ma_Result; @@ -1783,8 +1591,7 @@ ma_complex a, b; } -ma_complex ma_cmul(a, b) -ma_complex a, b; +ma_complex ma_cmul(ma_complex a, ma_complex b) { ma_complex ma_Result; @@ -1794,8 +1601,7 @@ ma_complex a, b; } -ma_complex ma_cdiv(a, b) -ma_complex a, b; +ma_complex ma_cdiv(ma_complex a, ma_complex b) { ma_complex ma_Result; double d; @@ -1807,8 +1613,7 @@ ma_complex a, b; } -ma_complex ma_csqr(a) -ma_complex a; +ma_complex ma_csqr(ma_complex a) { ma_complex ma_Result; @@ -1818,8 +1623,7 @@ ma_complex a; } -ma_complex ma_csqrt(a) -ma_complex a; +ma_complex ma_csqrt(ma_complex a) { ma_complex ma_Result; double d; @@ -1844,16 +1648,13 @@ ma_complex a; } -int ma_cequal(a, b) -ma_complex a, b; +int ma_cequal(ma_complex a, ma_complex b) { return (a.re == b.re && a.im == b.im); } -int ma_cnequal(a, b, epssq) -ma_complex a, b; -double epssq; +int ma_cnequal(ma_complex a, ma_complex b, double epssq) { double TEMP, TEMP1; @@ -1869,9 +1670,7 @@ double epssq; } -ma_complex ma_csmul(r, a) -double r; -ma_complex a; +ma_complex ma_csmul(double r, ma_complex a) { ma_complex ma_Result; @@ -1881,8 +1680,7 @@ ma_complex a; } -ma_complex ma_cconj(a) -ma_complex a; +ma_complex ma_cconj(ma_complex a) { ma_complex ma_Result; @@ -1892,8 +1690,7 @@ ma_complex a; } -ma_complex ma_cneg(a) -ma_complex a; +ma_complex ma_cneg(ma_complex a) { ma_complex ma_Result; @@ -1903,29 +1700,25 @@ ma_complex a; } -double ma_cangle(a) -ma_complex a; +double ma_cangle(ma_complex a) { return (ma_arctan2(a.im, a.re)); } -double ma_cabs(a) -ma_complex a; +double ma_cabs(ma_complex a) { return (ma_hypot(a.im, a.re)); } -double ma_cabssqr(a) -ma_complex a; +double ma_cabssqr(ma_complex a) { return (a.im * a.im + a.re * a.re); } -double ma_cdiff(a, b) -ma_complex a, b; +double ma_cdiff(ma_complex a, ma_complex b) { double TEMP, TEMP1; @@ -1935,8 +1728,7 @@ ma_complex a, b; } /*Scott Hemphill's favorite function*/ -ma_complex ma_cnorm(a) -ma_complex a; +ma_complex ma_cnorm(ma_complex a) { double mag; @@ -1949,8 +1741,7 @@ ma_complex a; } -ma_complex ma_cexp(a) -ma_complex a; +ma_complex ma_cexp(ma_complex a) { ma_complex ma_Result; double e; @@ -1967,8 +1758,7 @@ ma_complex a; } -ma_complex ma_cexpi(a) -ma_complex a; +ma_complex ma_cexpi(ma_complex a) { ma_complex ma_Result; double e; @@ -1985,8 +1775,7 @@ ma_complex a; } -ma_complex ma_cln(a) -ma_complex a; +ma_complex ma_cln(ma_complex a) { ma_complex ma_Result; @@ -2001,8 +1790,7 @@ ma_complex a; } -ma_complex ma_csin(a) -ma_complex a; +ma_complex ma_csin(ma_complex a) { ma_complex ma_Result; @@ -2017,8 +1805,7 @@ ma_complex a; } -ma_complex ma_ccos(a) -ma_complex a; +ma_complex ma_ccos(ma_complex a) { ma_complex ma_Result; @@ -2033,8 +1820,7 @@ ma_complex a; } -ma_complex ma_ctan(a) -ma_complex a; +ma_complex ma_ctan(ma_complex a) { ma_complex ma_Result; double d; @@ -2056,8 +1842,7 @@ ma_complex a; /* These definitions follow the Common Lisp standard; they are ugly, but they have the desired behavior around branch cuts and principal values. */ -ma_complex ma_carcsin(a) -ma_complex a; +ma_complex ma_carcsin(ma_complex a) { if (a.im == 0 && fabs(a.re) < 1) return (ma_creal(ma_arcsin(a.re))); @@ -2068,20 +1853,17 @@ ma_complex a; } -ma_complex ma_carccos(a) -ma_complex a; +ma_complex ma_carccos(ma_complex a) { if (a.im == 0 && fabs(a.re) < 1) return (ma_creal(ma_arccos(a.re))); else return (ma_cmul(ma_cmI, ma_cln(ma_cadd(a, ma_cmul(ma_cI, ma_csqrt(ma_csub(ma_c1, ma_csqr(a)))))))); -/* p2c: math.text, line 2108: Note: Line breaker spent 1.5 seconds, 2231 tries on line 2089 */ } -ma_complex ma_carctan(a) -ma_complex a; +ma_complex ma_carctan(ma_complex a) { if (a.im == 0) return (ma_creal(atan(a.re))); @@ -2091,8 +1873,7 @@ ma_complex a; } -ma_complex ma_csinh(a) -ma_complex a; +ma_complex ma_csinh(ma_complex a) { ma_complex ma_Result; @@ -2107,8 +1888,7 @@ ma_complex a; } -ma_complex ma_ccosh(a) -ma_complex a; +ma_complex ma_ccosh(ma_complex a) { ma_complex ma_Result; @@ -2123,8 +1903,7 @@ ma_complex a; } -ma_complex ma_ctanh(a) -ma_complex a; +ma_complex ma_ctanh(ma_complex a) { ma_complex ma_Result; double d; @@ -2143,8 +1922,7 @@ ma_complex a; } -ma_complex ma_carcsinh(a) -ma_complex a; +ma_complex ma_carcsinh(ma_complex a) { if (a.im == 0) return (ma_creal(ma_arcsinh(a.re))); @@ -2153,8 +1931,7 @@ ma_complex a; } -ma_complex ma_carccosh(a) -ma_complex a; +ma_complex ma_carccosh(ma_complex a) { if (a.im == 0 && a.re >= 1) return (ma_creal(ma_arccosh(a.re))); @@ -2164,8 +1941,7 @@ ma_complex a; } -ma_complex ma_carctanh(a) -ma_complex a; +ma_complex ma_carctanh(ma_complex a) { ma_complex ma_Result; @@ -2179,12 +1955,7 @@ ma_complex a; } - -char *ma_strfmtcomplex2(ma_Result, a, wid, prec, flags, min, max) -char *ma_Result; -ma_complex a; -long wid, prec, flags; -double min, max; +char *ma_strfmtcomplex2(char *ma_Result, ma_complex a, long wid, long prec, long flags, double min, double max) { char buf[256], buf2[256]; long i; @@ -2267,23 +2038,17 @@ double min, max; } -char *ma_strfmtcomplex(ma_Result, a, wid, prec) -char *ma_Result; -ma_complex a; -long wid, prec; +char *ma_strfmtcomplex(char *ma_Result, ma_complex a, long wid, long prec) { return (ma_strfmtcomplex2(ma_Result, a, wid, prec, 0L, 1e-2, 0.0)); } -char *ma_strcomplex(ma_Result, a) -char *ma_Result; -ma_complex a; +char *ma_strcomplex(char *ma_Result, ma_complex a) { return (ma_strfmtcomplex2(ma_Result, a, -1L, -1L, 0L, 1e-2, 0.0)); } - /* variables for ma_strsubreadcomplex: */ struct LOC_ma_strsubreadcomplex { char *buf; @@ -2291,15 +2056,13 @@ struct LOC_ma_strsubreadcomplex { long i; } ; -void skipspc(LINK) -struct LOC_ma_strsubreadcomplex *LINK; +void skipspc(struct LOC_ma_strsubreadcomplex *LINK) { while (LINK->i <= strlen(LINK->buf) && LINK->buf[LINK->i - 1] == ' ') LINK->i++; } -void getsign(LINK) -struct LOC_ma_strsubreadcomplex *LINK; +void getsign(struct LOC_ma_strsubreadcomplex *LINK) { LINK->sign = 1.0; skipspc(LINK); @@ -2317,11 +2080,7 @@ struct LOC_ma_strsubreadcomplex *LINK; LINK->sign = -1.0; } - -void ma_strsubreadcomplex(buf_, first, pos, a) -char *buf_; -long first, *pos; -ma_complex *a; +void ma_strsubreadcomplex(char *buf_, long first, long *pos, ma_complex *a) { struct LOC_ma_strsubreadcomplex V; double r; @@ -2435,9 +2194,7 @@ _L1: _L2: ; } - -ma_complex ma_strreadcomplex(buf_) -char *buf_; +ma_complex ma_strreadcomplex(char *buf_) { char buf[256]; ma_complex c; @@ -2459,9 +2216,7 @@ char *buf_; /* Shuffled/seeded random number generator */ /* Various algorithms taken from chapter 7 of "Numerical Recipes" */ -static void seedrand(st, seed) -rstaterec *st; -long seed; +static void seedrand(rstaterec *st, long seed) { long i; @@ -2479,9 +2234,7 @@ long seed; } -void ma_seedrandom(s, seed) -void **s; -long seed; +void ma_seedrandom(void **s, long seed) { rstaterec *rs; @@ -2494,8 +2247,7 @@ long seed; } -void ma_initrandom(s) -void **s; +void ma_initrandom(void **s) { rstaterec *rs; @@ -2504,9 +2256,7 @@ void **s; seedrand(rs, 0L); } - -void ma_duprandom(d, s) -void *d, *s; +void ma_duprandom(void *d, void *s) { rstaterec *rsd, *rss; @@ -2515,9 +2265,7 @@ void *d, *s; *rsd = *rss; } - -double ma_urandom(s) -void *s; +double ma_urandom(void *s) { long i; double v; @@ -2536,10 +2284,7 @@ void *s; return ((v + i) / 2147483648.0); } - -double ma_rrandom(s, min, max) -void *s; -double min, max; +double ma_rrandom(void *s, double min, double max) { if (max <= min) return min; @@ -2547,10 +2292,7 @@ double min, max; return (ma_urandom(s) * (max - min) + min); } - -long ma_irandom(s, min, max) -void *s; -long min, max; +long ma_irandom(void *s, long min, long max) { long i, diff; rstaterec *WITH; @@ -2572,10 +2314,7 @@ long min, max; } } - -double ma_nrandom(s, mean, sdev) -void *s; -double mean, sdev; +double ma_nrandom(void *s, double mean, double sdev) { double ma_Result, v1, v2, r, fac; rstaterec *WITH; @@ -2610,15 +2349,13 @@ static void seedsysrand() } -long ma_rand2(min, max) -long min, max; +long ma_rand2(long min, long max) { if (!sysrstinit) seedsysrand(); return (ma_irandom((void *)sysrstate, min, max)); } - double ma_rrand() { if (!sysrstinit) @@ -2627,8 +2364,7 @@ double ma_rrand() } -double ma_rrand2(min, max) -double min, max; +double ma_rrand2(double min, double max) { if (!sysrstinit) seedsysrand(); @@ -2636,8 +2372,7 @@ double min, max; } -double ma_nrand2(mean, sdev) -double mean, sdev; +double ma_nrand2(double mean, double sdev) { if (!sysrstinit) seedsysrand();