FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Modules/clinic/mathintegermodule.c.h at 3.15 · python/cpython · GitHub
python
cpython
Repository navigation
Code
Issues
5k+
(5k+)
Pull requests
2.4k
(2.4k)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Modules
/
clinic
/
mathintegermodule.c.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
159 lines (130 loc) · 4.24 KB
Breadcrumbs
cpython
/
Modules
/
clinic
/
mathintegermodule.c.h
Copy path
File metadata and controls
159 lines (130 loc) · 4.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*[clinic input]
preserve
[clinic start generated code]*/
#include
"pycore_modsupport.h"
// _PyArg_CheckPositional()
PyDoc_STRVAR
(
math_integer_gcd__doc__
,
"gcd($module, /, *integers)\n"
"--\n"
"\n"
"Greatest Common Divisor."
);
#define
MATH_INTEGER_GCD_METHODDEF
\
{"gcd", _PyCFunction_CAST(math_integer_gcd), METH_FASTCALL, math_integer_gcd__doc__},
static
PyObject
*
math_integer_gcd_impl
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
args_length
);
static
PyObject
*
math_integer_gcd
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
nargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
const
*
__clinic_args
;
Py_ssize_t
args_length
;
__clinic_args
=
args
;
args_length
=
nargs
;
return_value
=
math_integer_gcd_impl
(
module
,
__clinic_args
,
args_length
);
return
return_value
;
}
PyDoc_STRVAR
(
math_integer_lcm__doc__
,
"lcm($module, /, *integers)\n"
"--\n"
"\n"
"Least Common Multiple."
);
#define
MATH_INTEGER_LCM_METHODDEF
\
{"lcm", _PyCFunction_CAST(math_integer_lcm), METH_FASTCALL, math_integer_lcm__doc__},
static
PyObject
*
math_integer_lcm_impl
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
args_length
);
static
PyObject
*
math_integer_lcm
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
nargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
const
*
__clinic_args
;
Py_ssize_t
args_length
;
__clinic_args
=
args
;
args_length
=
nargs
;
return_value
=
math_integer_lcm_impl
(
module
,
__clinic_args
,
args_length
);
return
return_value
;
}
PyDoc_STRVAR
(
math_integer_isqrt__doc__
,
"isqrt($module, n, /)\n"
"--\n"
"\n"
"Return the integer part of the square root of the input."
);
#define
MATH_INTEGER_ISQRT_METHODDEF
\
{"isqrt", (PyCFunction)math_integer_isqrt, METH_O, math_integer_isqrt__doc__},
PyDoc_STRVAR
(
math_integer_factorial__doc__
,
"factorial($module, n, /)\n"
"--\n"
"\n"
"Find n!."
);
#define
MATH_INTEGER_FACTORIAL_METHODDEF
\
{"factorial", (PyCFunction)math_integer_factorial, METH_O, math_integer_factorial__doc__},
PyDoc_STRVAR
(
math_integer_perm__doc__
,
"perm($module, n, k=None, /)\n"
"--\n"
"\n"
"Number of ways to choose k items from n items without repetition and with order.\n"
"\n"
"Evaluates to n! / (n - k)! when k <= n and evaluates\n"
"to zero when k > n.\n"
"\n"
"If k is not specified or is None, then k defaults to n\n"
"and the function returns n!.\n"
"\n"
"Raises ValueError if either of the arguments are negative."
);
#define
MATH_INTEGER_PERM_METHODDEF
\
{"perm", _PyCFunction_CAST(math_integer_perm), METH_FASTCALL, math_integer_perm__doc__},
static
PyObject
*
math_integer_perm_impl
(
PyObject
*
module
,
PyObject
*
n
,
PyObject
*
k
);
static
PyObject
*
math_integer_perm
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
nargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
n
;
PyObject
*
k
=
Py_None
;
if
(!
_PyArg_CheckPositional
(
"perm"
,
nargs
,
1
,
2
)) {
goto
exit
;
}
n
=
args
[
0
];
if
(
nargs
<
2
) {
goto
skip_optional
;
}
k
=
args
[
1
];
skip_optional
:
return_value
=
math_integer_perm_impl
(
module
,
n
,
k
);
exit
:
return
return_value
;
}
PyDoc_STRVAR
(
math_integer_comb__doc__
,
"comb($module, n, k, /)\n"
"--\n"
"\n"
"Number of ways to choose k items from n items without repetition and without order.\n"
"\n"
"Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates\n"
"to zero when k > n.\n"
"\n"
"Also called the binomial coefficient because it is equivalent\n"
"to the coefficient of k-th term in polynomial expansion of the\n"
"expression (1 + x)**n.\n"
"\n"
"Raises ValueError if either of the arguments are negative."
);
#define
MATH_INTEGER_COMB_METHODDEF
\
{"comb", _PyCFunction_CAST(math_integer_comb), METH_FASTCALL, math_integer_comb__doc__},
static
PyObject
*
math_integer_comb_impl
(
PyObject
*
module
,
PyObject
*
n
,
PyObject
*
k
);
static
PyObject
*
math_integer_comb
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
nargs
)
{
PyObject
*
return_value
=
NULL
;
PyObject
*
n
;
PyObject
*
k
;
if
(!
_PyArg_CheckPositional
(
"comb"
,
nargs
,
2
,
2
)) {
goto
exit
;
}
n
=
args
[
0
];
k
=
args
[
1
];
return_value
=
math_integer_comb_impl
(
module
,
n
,
k
);
exit
:
return
return_value
;
}
/*[clinic end generated code: output=34697570c923a3af input=a9049054013a1b77]*/
Back
|
FazBrowse Home
|
New Git URL