Skip to content

Commit c6e2290

Browse files
committed
Added Doc strings -- by Chris Petrilli.
1 parent 13fdf5e commit c6e2290

2 files changed

Lines changed: 216 additions & 67 deletions

File tree

Modules/cmathmodule.c

Lines changed: 119 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,38 +48,74 @@ static Py_complex c_acos(x)
4848
c_sqrt(c_diff(c_1,c_prod(x,x))))))));
4949
}
5050

51+
static char c_acos_doc [] =
52+
"acos(x)\n\
53+
\n\
54+
Return the arc cosine of x.";
55+
56+
5157
static Py_complex c_acosh(x)
5258
Py_complex x;
5359
{
5460
return c_log(c_sum(x,c_prod(c_i,
5561
c_sqrt(c_diff(c_1,c_prod(x,x))))));
5662
}
5763

64+
static char c_acosh_doc [] =
65+
"acosh(x)\n\
66+
\n\
67+
Return the hyperbolic cosine of x.";
68+
69+
5870
static Py_complex c_asin(x)
5971
Py_complex x;
6072
{
6173
return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),
6274
c_sqrt(c_diff(c_1,c_prod(x,x)))))));
6375
}
6476

77+
static char c_asin_doc [] =
78+
"asin(x)\n\
79+
\n\
80+
Return the arc sine of x.";
81+
82+
6583
static Py_complex c_asinh(x)
6684
Py_complex x;
6785
{
6886
return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));
6987
}
7088

89+
static char c_asinh_doc [] =
90+
"asinh(x)\n\
91+
\n\
92+
Return the hyperbolic arc sine of x.";
93+
94+
7195
static Py_complex c_atan(x)
7296
Py_complex x;
7397
{
7498
return c_prod(c_i2,c_log(c_quot(c_sum(c_i,x),c_diff(c_i,x))));
7599
}
76100

101+
static char c_atan_doc [] =
102+
"atan(x)\n\
103+
\n\
104+
Return the arc tangent of x.";
105+
106+
77107
static Py_complex c_atanh(x)
78108
Py_complex x;
79109
{
80110
return c_prod(c_half,c_log(c_quot(c_sum(c_1,x),c_diff(c_1,x))));
81111
}
82112

113+
static char c_atanh_doc [] =
114+
"atanh(x)\n\
115+
\n\
116+
Return the hyperbolic arc tangent of x.";
117+
118+
83119
static Py_complex c_cos(x)
84120
Py_complex x;
85121
{
@@ -89,6 +125,12 @@ static Py_complex c_cos(x)
89125
return r;
90126
}
91127

128+
static char c_cos_doc [] =
129+
"cos(x)\n\
130+
\n\
131+
Return the cosine of x.";
132+
133+
92134
static Py_complex c_cosh(x)
93135
Py_complex x;
94136
{
@@ -98,6 +140,12 @@ static Py_complex c_cosh(x)
98140
return r;
99141
}
100142

143+
static char c_cosh_doc [] =
144+
"cosh(x)\n\
145+
\n\
146+
Return the hyperbolic cosine of x.";
147+
148+
101149
static Py_complex c_exp(x)
102150
Py_complex x;
103151
{
@@ -108,6 +156,12 @@ static Py_complex c_exp(x)
108156
return r;
109157
}
110158

159+
static char c_exp_doc [] =
160+
"exp(x)\n\
161+
\n\
162+
Return the exponential value e**x.";
163+
164+
111165
static Py_complex c_log(x)
112166
Py_complex x;
113167
{
@@ -118,6 +172,12 @@ static Py_complex c_log(x)
118172
return r;
119173
}
120174

175+
static char c_log_doc [] =
176+
"log(x)\n\
177+
\n\
178+
Return the natural logarithm of x.";
179+
180+
121181
static Py_complex c_log10(x)
122182
Py_complex x;
123183
{
@@ -128,6 +188,13 @@ static Py_complex c_log10(x)
128188
return r;
129189
}
130190

191+
static char c_log10_doc [] =
192+
"log10(x)\n\
193+
\n\
194+
Return the base-10 logarithm of x.";
195+
196+
197+
/* internal function not available from Python */
131198
static Py_complex c_prodi(x)
132199
Py_complex x;
133200
{
@@ -137,6 +204,7 @@ static Py_complex c_prodi(x)
137204
return r;
138205
}
139206

207+
140208
static Py_complex c_sin(x)
141209
Py_complex x;
142210
{
@@ -146,6 +214,12 @@ static Py_complex c_sin(x)
146214
return r;
147215
}
148216

217+
static char c_sin_doc [] =
218+
"sin(x)\n\
219+
\n\
220+
Return the sine of x.";
221+
222+
149223
static Py_complex c_sinh(x)
150224
Py_complex x;
151225
{
@@ -155,6 +229,12 @@ static Py_complex c_sinh(x)
155229
return r;
156230
}
157231

232+
static char c_sinh_doc [] =
233+
"sinh(x)\n\
234+
\n\
235+
Return the hyperbolic sine of x.";
236+
237+
158238
static Py_complex c_sqrt(x)
159239
Py_complex x;
160240
{
@@ -181,6 +261,12 @@ static Py_complex c_sqrt(x)
181261
return r;
182262
}
183263

264+
static char c_sqrt_doc [] =
265+
"sqrt(x)\n\
266+
\n\
267+
Return the square root of x.";
268+
269+
184270
static Py_complex c_tan(x)
185271
Py_complex x;
186272
{
@@ -202,6 +288,12 @@ static Py_complex c_tan(x)
202288
return r;
203289
}
204290

291+
static char c_tan_doc [] =
292+
"tan(x)\n\
293+
\n\
294+
Return the tangent of x.";
295+
296+
205297
static Py_complex c_tanh(x)
206298
Py_complex x;
207299
{
@@ -223,6 +315,11 @@ static Py_complex c_tanh(x)
223315
return r;
224316
}
225317

318+
static char c_tanh_doc [] =
319+
"tanh(x)\n\
320+
\n\
321+
Return the hyperbolic tangent of x.";
322+
226323

227324
/* And now the glue to make them available from Python: */
228325

@@ -281,23 +378,28 @@ FUNC1(cmath_tan, c_tan)
281378
FUNC1(cmath_tanh, c_tanh)
282379

283380

381+
static char module_doc [] =
382+
"This module is always available. It provides access to mathematical\n\
383+
functions for complex numbers.";
384+
385+
284386
static PyMethodDef cmath_methods[] = {
285-
{"acos", cmath_acos, 1},
286-
{"acosh", cmath_acosh, 1},
287-
{"asin", cmath_asin, 1},
288-
{"asinh", cmath_asinh, 1},
289-
{"atan", cmath_atan, 1},
290-
{"atanh", cmath_atanh, 1},
291-
{"cos", cmath_cos, 1},
292-
{"cosh", cmath_cosh, 1},
293-
{"exp", cmath_exp, 1},
294-
{"log", cmath_log, 1},
295-
{"log10", cmath_log10, 1},
296-
{"sin", cmath_sin, 1},
297-
{"sinh", cmath_sinh, 1},
298-
{"sqrt", cmath_sqrt, 1},
299-
{"tan", cmath_tan, 1},
300-
{"tanh", cmath_tanh, 1},
387+
{"acos", cmath_acos, 1, c_acos_doc},
388+
{"acosh", cmath_acosh, 1, c_acosh_doc},
389+
{"asin", cmath_asin, 1, c_asin_doc},
390+
{"asinh", cmath_asinh, 1, c_asinh_doc},
391+
{"atan", cmath_atan, 1, c_atan_doc},
392+
{"atanh", cmath_atanh, 1, c_atanh_doc},
393+
{"cos", cmath_cos, 1, c_cos_doc},
394+
{"cosh", cmath_cosh, 1, c_cosh_doc},
395+
{"exp", cmath_exp, 1, c_exp_doc},
396+
{"log", cmath_log, 1, c_log_doc},
397+
{"log10", cmath_log10, 1, c_log10_doc},
398+
{"sin", cmath_sin, 1, c_sin_doc},
399+
{"sinh", cmath_sinh, 1, c_sinh_doc},
400+
{"sqrt", cmath_sqrt, 1, c_sqrt_doc},
401+
{"tan", cmath_tan, 1, c_tan_doc},
402+
{"tanh", cmath_tanh, 1, c_tanh_doc},
301403
{NULL, NULL} /* sentinel */
302404
};
303405

@@ -306,7 +408,7 @@ initcmath()
306408
{
307409
PyObject *m, *d, *v;
308410

309-
m = Py_InitModule("cmath", cmath_methods);
411+
m = Py_InitModule3("cmath", cmath_methods, module_doc);
310412
d = PyModule_GetDict(m);
311413
PyDict_SetItemString(d, "pi",
312414
v = PyFloat_FromDouble(atan(1.0) * 4.0));

0 commit comments

Comments
 (0)