static Py_complex c_1 = {1., 0.};
-Py_complex c_sum(a,b)
- Py_complex a,b;
+Py_complex c_sum(Py_complex a, Py_complex b)
{
Py_complex r;
r.real = a.real + b.real;
return r;
}
-Py_complex c_diff(a,b)
- Py_complex a,b;
+Py_complex c_diff(Py_complex a, Py_complex b)
{
Py_complex r;
r.real = a.real - b.real;
return r;
}
-Py_complex c_neg(a)
- Py_complex a;
+Py_complex c_neg(Py_complex a)
{
Py_complex r;
r.real = -a.real;
return r;
}
-Py_complex c_prod(a,b)
- Py_complex a,b;
+Py_complex c_prod(Py_complex a, Py_complex b)
{
Py_complex r;
r.real = a.real*b.real - a.imag*b.imag;
return r;
}
-Py_complex c_quot(a,b)
- Py_complex a,b;
+Py_complex c_quot(Py_complex a, Py_complex b)
{
Py_complex r;
double d = b.real*b.real + b.imag*b.imag;
return r;
}
-Py_complex c_pow(a,b)
- Py_complex a,b;
+Py_complex c_pow(Py_complex a, Py_complex b)
{
Py_complex r;
double vabs,len,at,phase;
return r;
}
-static Py_complex c_powu(x, n)
- Py_complex x;
- long n;
+static Py_complex c_powu(Py_complex x, long n)
{
Py_complex r, p;
long mask = 1;
return r;
}
-static Py_complex c_powi(x, n)
- Py_complex x;
- long n;
+static Py_complex c_powi(Py_complex x, long n)
{
Py_complex cn;
}
PyObject *
-PyComplex_FromCComplex(cval)
- Py_complex cval;
+PyComplex_FromCComplex(Py_complex cval)
{
register PyComplexObject *op;
}
PyObject *
-PyComplex_FromDoubles(real, imag)
- double real, imag;
+PyComplex_FromDoubles(double real, double imag)
{
Py_complex c;
c.real = real;
}
double
-PyComplex_RealAsDouble(op)
- PyObject *op;
+PyComplex_RealAsDouble(PyObject *op)
{
if (PyComplex_Check(op)) {
return ((PyComplexObject *)op)->cval.real;
- } else {
+ }
+ else {
return PyFloat_AsDouble(op);
}
}
double
-PyComplex_ImagAsDouble(op)
- PyObject *op;
+PyComplex_ImagAsDouble(PyObject *op)
{
if (PyComplex_Check(op)) {
return ((PyComplexObject *)op)->cval.imag;
- } else {
+ }
+ else {
return 0.0;
}
}
Py_complex
-PyComplex_AsCComplex(op)
- PyObject *op;
+PyComplex_AsCComplex(PyObject *op)
{
Py_complex cv;
if (PyComplex_Check(op)) {
return ((PyComplexObject *)op)->cval;
- } else {
+ }
+ else {
cv.real = PyFloat_AsDouble(op);
cv.imag = 0.;
return cv;
}
static void
-complex_dealloc(op)
- PyObject *op;
+complex_dealloc(PyObject *op)
{
PyObject_DEL(op);
}
static void
-complex_buf_repr(buf, v)
- char *buf;
- PyComplexObject *v;
+complex_buf_repr(char *buf, PyComplexObject *v)
{
if (v->cval.real == 0.)
sprintf(buf, "%.12gj", v->cval.imag);
}
static int
-complex_print(v, fp, flags)
- PyComplexObject *v;
- FILE *fp;
- int flags; /* Not used but required by interface */
+complex_print(PyComplexObject *v, FILE *fp, int flags)
+ /* flags -- not used but required by interface */
{
char buf[100];
complex_buf_repr(buf, v);
}
static PyObject *
-complex_repr(v)
- PyComplexObject *v;
+complex_repr(PyComplexObject *v)
{
char buf[100];
complex_buf_repr(buf, v);
}
static int
-complex_compare(v, w)
- PyComplexObject *v, *w;
+complex_compare(PyComplexObject *v, PyComplexObject *w)
{
-/* Note: "greater" and "smaller" have no meaning for complex numbers,
- but Python requires that they be defined nevertheless. */
+ /* Note: "greater" and "smaller" have no meaning for complex numbers,
+ but Python requires that they be defined nevertheless. */
Py_complex i, j;
i = v->cval;
j = w->cval;
if (i.real == j.real && i.imag == j.imag)
- return 0;
+ return 0;
else if (i.real != j.real)
- return (i.real < j.real) ? -1 : 1;
+ return (i.real < j.real) ? -1 : 1;
else
- return (i.imag < j.imag) ? -1 : 1;
+ return (i.imag < j.imag) ? -1 : 1;
}
static long
-complex_hash(v)
- PyComplexObject *v;
+complex_hash(PyComplexObject *v)
{
double intpart, fractpart;
long x;
}
static PyObject *
-complex_add(v, w)
- PyComplexObject *v;
- PyComplexObject *w;
+complex_add(PyComplexObject *v, PyComplexObject *w)
{
Py_complex result;
PyFPE_START_PROTECT("complex_add", return 0)
}
static PyObject *
-complex_sub(v, w)
- PyComplexObject *v;
- PyComplexObject *w;
+complex_sub(PyComplexObject *v, PyComplexObject *w)
{
Py_complex result;
PyFPE_START_PROTECT("complex_sub", return 0)
}
static PyObject *
-complex_mul(v, w)
- PyComplexObject *v;
- PyComplexObject *w;
+complex_mul(PyComplexObject *v, PyComplexObject *w)
{
Py_complex result;
PyFPE_START_PROTECT("complex_mul", return 0)
}
static PyObject *
-complex_div(v, w)
- PyComplexObject *v;
- PyComplexObject *w;
+complex_div(PyComplexObject *v, PyComplexObject *w)
{
Py_complex quot;
PyFPE_START_PROTECT("complex_div", return 0)
}
static PyObject *
-complex_remainder(v, w)
- PyComplexObject *v;
- PyComplexObject *w;
+complex_remainder(PyComplexObject *v, PyComplexObject *w)
{
Py_complex div, mod;
errno = 0;
static PyObject *
-complex_divmod(v, w)
- PyComplexObject *v;
- PyComplexObject *w;
+complex_divmod(PyComplexObject *v, PyComplexObject *w)
{
Py_complex div, mod;
PyObject *d, *m, *z;
}
static PyObject *
-complex_pow(v, w, z)
- PyComplexObject *v;
- PyObject *w;
- PyComplexObject *z;
+complex_pow(PyComplexObject *v, PyObject *w, PyComplexObject *z)
{
Py_complex p;
Py_complex exponent;
PyErr_SetString(PyExc_ValueError, "complex modulo");
return NULL;
}
-
PyFPE_START_PROTECT("complex_pow", return 0)
errno = 0;
exponent = ((PyComplexObject*)w)->cval;
"0.0 to a negative or complex power");
return NULL;
}
-
return PyComplex_FromCComplex(p);
}
static PyObject *
-complex_neg(v)
- PyComplexObject *v;
+complex_neg(PyComplexObject *v)
{
Py_complex neg;
neg.real = -v->cval.real;
}
static PyObject *
-complex_pos(v)
- PyComplexObject *v;
+complex_pos(PyComplexObject *v)
{
Py_INCREF(v);
return (PyObject *)v;
}
static PyObject *
-complex_abs(v)
- PyComplexObject *v;
+complex_abs(PyComplexObject *v)
{
double result;
PyFPE_START_PROTECT("complex_abs", return 0)
}
static int
-complex_nonzero(v)
- PyComplexObject *v;
+complex_nonzero(PyComplexObject *v)
{
return v->cval.real != 0.0 || v->cval.imag != 0.0;
}
static int
-complex_coerce(pv, pw)
- PyObject **pv;
- PyObject **pw;
+complex_coerce(PyObject **pv, PyObject **pw)
{
Py_complex cval;
cval.imag = 0.;
}
static PyObject *
-complex_int(v)
- PyObject *v;
+complex_int(PyObject *v)
{
PyErr_SetString(PyExc_TypeError,
"can't convert complex to int; use e.g. int(abs(z))");
}
static PyObject *
-complex_long(v)
- PyObject *v;
+complex_long(PyObject *v)
{
PyErr_SetString(PyExc_TypeError,
"can't convert complex to long; use e.g. long(abs(z))");
}
static PyObject *
-complex_float(v)
- PyObject *v;
+complex_float(PyObject *v)
{
PyErr_SetString(PyExc_TypeError,
"can't convert complex to float; use e.g. abs(z)");
}
static PyObject *
-complex_conjugate(self, args)
- PyObject *self;
- PyObject *args;
+complex_conjugate(PyObject *self, PyObject *args)
{
Py_complex c;
if (!PyArg_ParseTuple(args, ":conjugate"))
static PyObject *
-complex_getattr(self, name)
- PyComplexObject *self;
- char *name;
+complex_getattr(PyComplexObject *self, char *name)
{
if (strcmp(name, "real") == 0)
return (PyObject *)PyFloat_FromDouble(self->cval.real);