Mechanical edits just so I can read it.
This commit is contained in:
parent
273ad453f5
commit
14e26408f3
|
@ -28,10 +28,6 @@ static Py_complex c_1 = {1., 0.};
|
||||||
static Py_complex c_half = {0.5, 0.};
|
static Py_complex c_half = {0.5, 0.};
|
||||||
static Py_complex c_i = {0., 1.};
|
static Py_complex c_i = {0., 1.};
|
||||||
static Py_complex c_i2 = {0., 0.5};
|
static Py_complex c_i2 = {0., 0.5};
|
||||||
#if 0
|
|
||||||
static Py_complex c_mi = {0., -1.};
|
|
||||||
static Py_complex c_pi2 = {M_PI/2., 0.};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* forward declarations */
|
/* forward declarations */
|
||||||
staticforward Py_complex c_log(Py_complex);
|
staticforward Py_complex c_log(Py_complex);
|
||||||
|
@ -39,19 +35,21 @@ staticforward Py_complex c_prodi(Py_complex);
|
||||||
staticforward Py_complex c_sqrt(Py_complex);
|
staticforward Py_complex c_sqrt(Py_complex);
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_acos(Py_complex x)
|
static Py_complex
|
||||||
|
c_acos(Py_complex x)
|
||||||
{
|
{
|
||||||
return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,
|
return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,
|
||||||
c_sqrt(c_diff(c_1,c_prod(x,x))))))));
|
c_sqrt(c_diff(c_1,c_prod(x,x))))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_acos_doc[] =
|
static char c_acos_doc[] =
|
||||||
"acos(x)\n\
|
"acos(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the arc cosine of x.";
|
"Return the arc cosine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_acosh(Py_complex x)
|
static Py_complex
|
||||||
|
c_acosh(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex z;
|
Py_complex z;
|
||||||
z = c_sqrt(c_half);
|
z = c_sqrt(c_half);
|
||||||
|
@ -61,12 +59,13 @@ static Py_complex c_acosh(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_acosh_doc[] =
|
static char c_acosh_doc[] =
|
||||||
"acosh(x)\n\
|
"acosh(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the hyperbolic arccosine of x.";
|
"Return the hyperbolic arccosine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_asin(Py_complex x)
|
static Py_complex
|
||||||
|
c_asin(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex z;
|
Py_complex z;
|
||||||
z = c_sqrt(c_half);
|
z = c_sqrt(c_half);
|
||||||
|
@ -76,12 +75,13 @@ static Py_complex c_asin(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_asin_doc[] =
|
static char c_asin_doc[] =
|
||||||
"asin(x)\n\
|
"asin(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the arc sine of x.";
|
"Return the arc sine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_asinh(Py_complex x)
|
static Py_complex
|
||||||
|
c_asinh(Py_complex x)
|
||||||
{
|
{
|
||||||
/* Break up long expression for WATCOM */
|
/* Break up long expression for WATCOM */
|
||||||
Py_complex z;
|
Py_complex z;
|
||||||
|
@ -90,34 +90,37 @@ static Py_complex c_asinh(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_asinh_doc[] =
|
static char c_asinh_doc[] =
|
||||||
"asinh(x)\n\
|
"asinh(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the hyperbolic arc sine of x.";
|
"Return the hyperbolic arc sine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_atan(Py_complex x)
|
static Py_complex
|
||||||
|
c_atan(Py_complex x)
|
||||||
{
|
{
|
||||||
return c_prod(c_i2,c_log(c_quot(c_sum(c_i,x),c_diff(c_i,x))));
|
return c_prod(c_i2,c_log(c_quot(c_sum(c_i,x),c_diff(c_i,x))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_atan_doc[] =
|
static char c_atan_doc[] =
|
||||||
"atan(x)\n\
|
"atan(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the arc tangent of x.";
|
"Return the arc tangent of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_atanh(Py_complex x)
|
static Py_complex
|
||||||
|
c_atanh(Py_complex x)
|
||||||
{
|
{
|
||||||
return c_prod(c_half,c_log(c_quot(c_sum(c_1,x),c_diff(c_1,x))));
|
return c_prod(c_half,c_log(c_quot(c_sum(c_1,x),c_diff(c_1,x))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_atanh_doc[] =
|
static char c_atanh_doc[] =
|
||||||
"atanh(x)\n\
|
"atanh(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the hyperbolic arc tangent of x.";
|
"Return the hyperbolic arc tangent of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_cos(Py_complex x)
|
static Py_complex
|
||||||
|
c_cos(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
r.real = cos(x.real)*cosh(x.imag);
|
r.real = cos(x.real)*cosh(x.imag);
|
||||||
|
@ -126,12 +129,13 @@ static Py_complex c_cos(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_cos_doc[] =
|
static char c_cos_doc[] =
|
||||||
"cos(x)\n\
|
"cos(x)\n"
|
||||||
\n\
|
"n"
|
||||||
Return the cosine of x.";
|
"Return the cosine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_cosh(Py_complex x)
|
static Py_complex
|
||||||
|
c_cosh(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
r.real = cos(x.imag)*cosh(x.real);
|
r.real = cos(x.imag)*cosh(x.real);
|
||||||
|
@ -140,12 +144,13 @@ static Py_complex c_cosh(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_cosh_doc[] =
|
static char c_cosh_doc[] =
|
||||||
"cosh(x)\n\
|
"cosh(x)\n"
|
||||||
\n\
|
"n"
|
||||||
Return the hyperbolic cosine of x.";
|
"Return the hyperbolic cosine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_exp(Py_complex x)
|
static Py_complex
|
||||||
|
c_exp(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
double l = exp(x.real);
|
double l = exp(x.real);
|
||||||
|
@ -155,12 +160,13 @@ static Py_complex c_exp(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_exp_doc[] =
|
static char c_exp_doc[] =
|
||||||
"exp(x)\n\
|
"exp(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the exponential value e**x.";
|
"Return the exponential value e**x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_log(Py_complex x)
|
static Py_complex
|
||||||
|
c_log(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
double l = hypot(x.real,x.imag);
|
double l = hypot(x.real,x.imag);
|
||||||
|
@ -170,12 +176,13 @@ static Py_complex c_log(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_log_doc[] =
|
static char c_log_doc[] =
|
||||||
"log(x)\n\
|
"log(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the natural logarithm of x.";
|
"Return the natural logarithm of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_log10(Py_complex x)
|
static Py_complex
|
||||||
|
c_log10(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
double l = hypot(x.real,x.imag);
|
double l = hypot(x.real,x.imag);
|
||||||
|
@ -185,13 +192,14 @@ static Py_complex c_log10(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_log10_doc[] =
|
static char c_log10_doc[] =
|
||||||
"log10(x)\n\
|
"log10(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the base-10 logarithm of x.";
|
"Return the base-10 logarithm of x.";
|
||||||
|
|
||||||
|
|
||||||
/* internal function not available from Python */
|
/* internal function not available from Python */
|
||||||
static Py_complex c_prodi(Py_complex x)
|
static Py_complex
|
||||||
|
c_prodi(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
r.real = -x.imag;
|
r.real = -x.imag;
|
||||||
|
@ -200,7 +208,8 @@ static Py_complex c_prodi(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_sin(Py_complex x)
|
static Py_complex
|
||||||
|
c_sin(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
r.real = sin(x.real) * cosh(x.imag);
|
r.real = sin(x.real) * cosh(x.imag);
|
||||||
|
@ -209,12 +218,13 @@ static Py_complex c_sin(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_sin_doc[] =
|
static char c_sin_doc[] =
|
||||||
"sin(x)\n\
|
"sin(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the sine of x.";
|
"Return the sine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_sinh(Py_complex x)
|
static Py_complex
|
||||||
|
c_sinh(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
r.real = cos(x.imag) * sinh(x.real);
|
r.real = cos(x.imag) * sinh(x.real);
|
||||||
|
@ -223,12 +233,13 @@ static Py_complex c_sinh(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_sinh_doc[] =
|
static char c_sinh_doc[] =
|
||||||
"sinh(x)\n\
|
"sinh(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the hyperbolic sine of x.";
|
"Return the hyperbolic sine of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_sqrt(Py_complex x)
|
static Py_complex
|
||||||
|
c_sqrt(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
double s,d;
|
double s,d;
|
||||||
|
@ -254,12 +265,13 @@ static Py_complex c_sqrt(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_sqrt_doc[] =
|
static char c_sqrt_doc[] =
|
||||||
"sqrt(x)\n\
|
"sqrt(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the square root of x.";
|
"Return the square root of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_tan(Py_complex x)
|
static Py_complex
|
||||||
|
c_tan(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
double sr,cr,shi,chi;
|
double sr,cr,shi,chi;
|
||||||
|
@ -280,12 +292,13 @@ static Py_complex c_tan(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_tan_doc[] =
|
static char c_tan_doc[] =
|
||||||
"tan(x)\n\
|
"tan(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the tangent of x.";
|
"Return the tangent of x.";
|
||||||
|
|
||||||
|
|
||||||
static Py_complex c_tanh(Py_complex x)
|
static Py_complex
|
||||||
|
c_tanh(Py_complex x)
|
||||||
{
|
{
|
||||||
Py_complex r;
|
Py_complex r;
|
||||||
double si,ci,shr,chr;
|
double si,ci,shr,chr;
|
||||||
|
@ -306,9 +319,9 @@ static Py_complex c_tanh(Py_complex x)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char c_tanh_doc[] =
|
static char c_tanh_doc[] =
|
||||||
"tanh(x)\n\
|
"tanh(x)\n"
|
||||||
\n\
|
"\n"
|
||||||
Return the hyperbolic tangent of x.";
|
"Return the hyperbolic tangent of x.";
|
||||||
|
|
||||||
|
|
||||||
/* And now the glue to make them available from Python: */
|
/* And now the glue to make them available from Python: */
|
||||||
|
@ -367,43 +380,26 @@ FUNC1(cmath_tanh, c_tanh)
|
||||||
|
|
||||||
|
|
||||||
static char module_doc[] =
|
static char module_doc[] =
|
||||||
"This module is always available. It provides access to mathematical\n\
|
"This module is always available. It provides access to mathematical\n"
|
||||||
functions for complex numbers.";
|
"functions for complex numbers.";
|
||||||
|
|
||||||
|
|
||||||
static PyMethodDef cmath_methods[] = {
|
static PyMethodDef cmath_methods[] = {
|
||||||
{"acos", cmath_acos,
|
{"acos", cmath_acos, METH_VARARGS, c_acos_doc},
|
||||||
METH_VARARGS, c_acos_doc},
|
{"acosh", cmath_acosh, METH_VARARGS, c_acosh_doc},
|
||||||
{"acosh", cmath_acosh,
|
{"asin", cmath_asin, METH_VARARGS, c_asin_doc},
|
||||||
METH_VARARGS, c_acosh_doc},
|
{"asinh", cmath_asinh, METH_VARARGS, c_asinh_doc},
|
||||||
{"asin", cmath_asin,
|
{"atan", cmath_atan, METH_VARARGS, c_atan_doc},
|
||||||
METH_VARARGS, c_asin_doc},
|
{"atanh", cmath_atanh, METH_VARARGS, c_atanh_doc},
|
||||||
{"asinh", cmath_asinh,
|
{"cos", cmath_cos, METH_VARARGS, c_cos_doc},
|
||||||
METH_VARARGS, c_asinh_doc},
|
{"cosh", cmath_cosh, METH_VARARGS, c_cosh_doc},
|
||||||
{"atan", cmath_atan,
|
{"exp", cmath_exp, METH_VARARGS, c_exp_doc},
|
||||||
METH_VARARGS, c_atan_doc},
|
{"log", cmath_log, METH_VARARGS, c_log_doc},
|
||||||
{"atanh", cmath_atanh,
|
{"log10", cmath_log10, METH_VARARGS, c_log10_doc},
|
||||||
METH_VARARGS, c_atanh_doc},
|
{"sin", cmath_sin, METH_VARARGS, c_sin_doc},
|
||||||
{"cos", cmath_cos,
|
{"sinh", cmath_sinh, METH_VARARGS, c_sinh_doc},
|
||||||
METH_VARARGS, c_cos_doc},
|
{"sqrt", cmath_sqrt, METH_VARARGS, c_sqrt_doc},
|
||||||
{"cosh", cmath_cosh,
|
{"tan", cmath_tan, METH_VARARGS, c_tan_doc},
|
||||||
METH_VARARGS, c_cosh_doc},
|
{"tanh", cmath_tanh, METH_VARARGS, c_tanh_doc},
|
||||||
{"exp", cmath_exp,
|
|
||||||
METH_VARARGS, c_exp_doc},
|
|
||||||
{"log", cmath_log,
|
|
||||||
METH_VARARGS, c_log_doc},
|
|
||||||
{"log10", cmath_log10,
|
|
||||||
METH_VARARGS, c_log10_doc},
|
|
||||||
{"sin", cmath_sin,
|
|
||||||
METH_VARARGS, c_sin_doc},
|
|
||||||
{"sinh", cmath_sinh,
|
|
||||||
METH_VARARGS, c_sinh_doc},
|
|
||||||
{"sqrt", cmath_sqrt,
|
|
||||||
METH_VARARGS, c_sqrt_doc},
|
|
||||||
{"tan", cmath_tan,
|
|
||||||
METH_VARARGS, c_tan_doc},
|
|
||||||
{"tanh", cmath_tanh,
|
|
||||||
METH_VARARGS, c_tanh_doc},
|
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue