diff options
-rw-r--r-- | Modules/cmathmodule.c | 112 | ||||
-rw-r--r-- | Objects/complexobject.c | 80 |
2 files changed, 96 insertions, 96 deletions
diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 9c28623..2f22bfc 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -29,137 +29,137 @@ /* First, the C functions that do the real work */ /* constants */ -static complex c_1 = {1., 0.}; -static complex c_half = {0.5, 0.}; -static complex c_i = {0., 1.}; -static complex c_i2 = {0., 0.5}; -static complex c_mi = {0., -1.}; -static complex c_pi2 = {M_PI/2., 0.}; +static Py_complex c_1 = {1., 0.}; +static Py_complex c_half = {0.5, 0.}; +static Py_complex c_i = {0., 1.}; +static Py_complex c_i2 = {0., 0.5}; +static Py_complex c_mi = {0., -1.}; +static Py_complex c_pi2 = {M_PI/2., 0.}; /* forward declarations */ -staticforward complex c_log(); -staticforward complex c_prodi(); -staticforward complex c_sqrt(); +staticforward Py_complex c_log(); +staticforward Py_complex c_prodi(); +staticforward Py_complex c_sqrt(); -static complex c_acos(x) - complex x; +static Py_complex c_acos(x) + Py_complex x; { return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i, c_sqrt(c_diff(c_1,c_prod(x,x)))))))); } -static complex c_acosh(x) - complex x; +static Py_complex c_acosh(x) + Py_complex x; { return c_log(c_sum(x,c_prod(c_i, c_sqrt(c_diff(c_1,c_prod(x,x)))))); } -static complex c_asin(x) - complex x; +static Py_complex c_asin(x) + Py_complex x; { return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x), c_sqrt(c_diff(c_1,c_prod(x,x))))))); } -static complex c_asinh(x) - complex x; +static Py_complex c_asinh(x) + Py_complex x; { return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x))); } -static complex c_atan(x) - complex x; +static Py_complex c_atan(x) + Py_complex x; { return c_prod(c_i2,c_log(c_quot(c_sum(c_i,x),c_diff(c_i,x)))); } -static complex c_atanh(x) - complex x; +static Py_complex c_atanh(x) + Py_complex x; { return c_prod(c_half,c_log(c_quot(c_sum(c_1,x),c_diff(c_1,x)))); } -static complex c_cos(x) - complex x; +static Py_complex c_cos(x) + Py_complex x; { - complex r; + Py_complex r; r.real = cos(x.real)*cosh(x.imag); r.imag = -sin(x.real)*sinh(x.imag); return r; } -static complex c_cosh(x) - complex x; +static Py_complex c_cosh(x) + Py_complex x; { - complex r; + Py_complex r; r.real = cos(x.imag)*cosh(x.real); r.imag = sin(x.imag)*sinh(x.real); return r; } -static complex c_exp(x) - complex x; +static Py_complex c_exp(x) + Py_complex x; { - complex r; + Py_complex r; double l = exp(x.real); r.real = l*cos(x.imag); r.imag = l*sin(x.imag); return r; } -static complex c_log(x) - complex x; +static Py_complex c_log(x) + Py_complex x; { - complex r; + Py_complex r; double l = hypot(x.real,x.imag); r.imag = atan2(x.imag, x.real); r.real = log(l); return r; } -static complex c_log10(x) - complex x; +static Py_complex c_log10(x) + Py_complex x; { - complex r; + Py_complex r; double l = hypot(x.real,x.imag); r.imag = atan2(x.imag, x.real)/log(10.); r.real = log10(l); return r; } -static complex c_prodi(x) - complex x; +static Py_complex c_prodi(x) + Py_complex x; { - complex r; + Py_complex r; r.real = -x.imag; r.imag = x.real; return r; } -static complex c_sin(x) - complex x; +static Py_complex c_sin(x) + Py_complex x; { - complex r; + Py_complex r; r.real = sin(x.real)*cosh(x.imag); r.imag = cos(x.real)*sinh(x.imag); return r; } -static complex c_sinh(x) - complex x; +static Py_complex c_sinh(x) + Py_complex x; { - complex r; + Py_complex r; r.real = cos(x.imag)*sinh(x.real); r.imag = sin(x.imag)*cosh(x.real); return r; } -static complex c_sqrt(x) - complex x; +static Py_complex c_sqrt(x) + Py_complex x; { - complex r; + Py_complex r; double s,d; if (x.real == 0. && x.imag == 0.) r = x; @@ -182,10 +182,10 @@ static complex c_sqrt(x) return r; } -static complex c_tan(x) - complex x; +static Py_complex c_tan(x) + Py_complex x; { - complex r; + Py_complex r; double sr,cr,shi,chi; double rs,is,rc,ic; double d; @@ -203,10 +203,10 @@ static complex c_tan(x) return r; } -static complex c_tanh(x) - complex x; +static Py_complex c_tanh(x) + Py_complex x; { - complex r; + Py_complex r; double si,ci,shr,chr; double rs,is,rc,ic; double d; @@ -242,9 +242,9 @@ math_error() static object * math_1(args, func) object *args; - complex (*func) FPROTO((complex)); + Py_complex (*func) FPROTO((Py_complex)); { - complex x; + Py_complex x; if (!PyArg_ParseTuple(args, "D", &x)) return NULL; errno = 0; diff --git a/Objects/complexobject.c b/Objects/complexobject.c index d49c6d3..0217467 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -56,48 +56,48 @@ extern double pow PROTO((double, double)); /* elementary operations on complex numbers */ static int c_error; -static complex c_1 = {1., 0.}; +static Py_complex c_1 = {1., 0.}; -complex c_sum(a,b) - complex a,b; +Py_complex c_sum(a,b) + Py_complex a,b; { - complex r; + Py_complex r; r.real = a.real + b.real; r.imag = a.imag + b.imag; return r; } -complex c_diff(a,b) - complex a,b; +Py_complex c_diff(a,b) + Py_complex a,b; { - complex r; + Py_complex r; r.real = a.real - b.real; r.imag = a.imag - b.imag; return r; } -complex c_neg(a) - complex a; +Py_complex c_neg(a) + Py_complex a; { - complex r; + Py_complex r; r.real = -a.real; r.imag = -a.imag; return r; } -complex c_prod(a,b) - complex a,b; +Py_complex c_prod(a,b) + Py_complex a,b; { - complex r; + Py_complex r; r.real = a.real*b.real - a.imag*b.imag; r.imag = a.real*b.imag + a.imag*b.real; return r; } -complex c_quot(a,b) - complex a,b; +Py_complex c_quot(a,b) + Py_complex a,b; { - complex r; + Py_complex r; double d = b.real*b.real + b.imag*b.imag; if (d == 0.) c_error = 1; @@ -106,10 +106,10 @@ complex c_quot(a,b) return r; } -complex c_pow(a,b) - complex a,b; +Py_complex c_pow(a,b) + Py_complex a,b; { - complex r; + Py_complex r; double vabs,len,at,phase; if (b.real == 0. && b.imag == 0.) { r.real = 1.; @@ -136,12 +136,12 @@ complex c_pow(a,b) return r; } -static complex c_powu(x, n) - complex x; +static Py_complex c_powu(x, n) + Py_complex x; long n; { - complex r = c_1; - complex p = x; + Py_complex r = c_1; + Py_complex p = x; long mask = 1; while (mask > 0 && n >= mask) { if (n & mask) @@ -152,11 +152,11 @@ static complex c_powu(x, n) return r; } -static complex c_powi(x, n) - complex x; +static Py_complex c_powi(x, n) + Py_complex x; long n; { - complex cn; + Py_complex cn; if (n > 100 || n < -100) { cn.real = (double) n; @@ -171,7 +171,7 @@ static complex c_powi(x, n) } PyObject * -PyComplex_FromCComplex(complex cval) +PyComplex_FromCComplex(Py_complex cval) { register complexobject *op = (complexobject *) malloc(sizeof(complexobject)); if (op == NULL) @@ -184,7 +184,7 @@ PyComplex_FromCComplex(complex cval) PyObject * PyComplex_FromDoubles(double real, double imag) { - complex c; + Py_complex c; c.real = real; c.imag = imag; return PyComplex_FromCComplex(c); @@ -208,9 +208,9 @@ PyComplex_ImagAsDouble(PyObject *op) { } } -complex +Py_complex PyComplex_AsCComplex(PyObject *op) { - complex cv; + Py_complex cv; if (PyComplex_Check(op)) { return ((PyComplexObject *)op)->cval; } else { @@ -266,8 +266,8 @@ complex_compare(v, w) { /* Note: "greater" and "smaller" have no meaning for complex numbers, but Python requires that they be defined nevertheless. */ - complex i = v->cval; - complex j = w->cval; + Py_complex i = v->cval; + Py_complex j = w->cval; if (i.real == j.real && i.imag == j.imag) return 0; else if (i.real != j.real) @@ -348,7 +348,7 @@ complex_div(v, w) complexobject *v; complexobject *w; { - complex quot; + Py_complex quot; c_error = 0; quot = c_quot(v->cval,w->cval); if (c_error == 1) { @@ -365,8 +365,8 @@ complex_pow(v, w, z) object *w; complexobject *z; { - complex p; - complex exponent; + Py_complex p; + Py_complex exponent; long int_exponent; if ((object *)z!=None) { @@ -394,7 +394,7 @@ static object * complex_neg(v) complexobject *v; { - complex neg; + Py_complex neg; neg.real = -v->cval.real; neg.imag = -v->cval.imag; return newcomplexobject(neg); @@ -427,7 +427,7 @@ complex_coerce(pv, pw) object **pv; object **pw; { - complex cval; + Py_complex cval; cval.imag = 0.; if (is_intobject(*pw)) { cval.real = (double)getintvalue(*pw); @@ -485,7 +485,7 @@ complex_new(self, args) object *self; object *args; { - complex cval; + Py_complex cval; cval.imag = 0.; if (!PyArg_ParseTuple(args, "d|d", &cval.real, &cval.imag)) @@ -497,7 +497,7 @@ static object * complex_conjugate(self) object *self; { - complex c = ((complexobject *)self)->cval; + Py_complex c = ((complexobject *)self)->cval; c.imag = -c.imag; return newcomplexobject(c); } @@ -513,7 +513,7 @@ complex_getattr(self, name) complexobject *self; char *name; { - complex cval; + Py_complex cval; if (strcmp(name, "real") == 0) return (object *)newfloatobject(self->cval.real); else if (strcmp(name, "imag") == 0) |