|
1 | 1 | # |
2 | 2 | # |
3 | 3 | # |
4 | | -from typing import Generic, TypeVar, Iterator, Iterable, Any, Final, Self, Mapping, Sequence |
| 4 | +from typing import ( |
| 5 | + Generic, |
| 6 | + TypeVar, |
| 7 | + Iterator, |
| 8 | + Iterable, |
| 9 | + Any, |
| 10 | + Final, |
| 11 | + Self, |
| 12 | + Mapping, |
| 13 | + Sequence, |
| 14 | + overload, |
| 15 | +) |
5 | 16 | from abc import abstractmethod |
6 | 17 | import enum |
7 | 18 |
|
8 | | - |
9 | 19 | FLINT_VERSION: Final[str] |
10 | 20 | FLINT_RELEASE: Final[int] |
11 | 21 |
|
| 22 | +Telem = TypeVar("Telem", bound=flint_scalar) |
| 23 | +Telem_coerce = TypeVar("Telem_coerce", contravariant=True) |
| 24 | +Tmpoly = TypeVar("Tmpoly", bound=flint_mpoly) |
| 25 | +Tctx = TypeVar("Tctx", bound=flint_mpoly_context) |
12 | 26 |
|
13 | | -Telem = TypeVar('Telem', bound=flint_scalar) |
14 | | -Telem_coerce = TypeVar('Telem_coerce', contravariant=True) |
15 | | -Tmpoly = TypeVar('Tmpoly', bound=flint_mpoly) |
16 | | -Tctx = TypeVar('Tctx', bound=flint_mpoly_context) |
17 | | - |
18 | | -Sctx = TypeVar('Sctx', bound=flint_mpoly_context) |
| 27 | +Sctx = TypeVar("Sctx", bound=flint_mpoly_context) |
19 | 28 |
|
20 | 29 | _str = str |
21 | 30 |
|
22 | | - |
23 | 31 | class flint_elem: |
24 | | - pass |
25 | | - |
| 32 | + def str(self) -> _str: ... |
| 33 | + def repr(self) -> _str: ... |
26 | 34 |
|
27 | 35 | class flint_scalar(flint_elem): |
28 | 36 | def is_zero(self) -> bool: ... |
29 | | - |
| 37 | + def __pos__(self) -> Self: ... |
| 38 | + def __neg__(self) -> Self: ... |
| 39 | + def __add__(self, other: int, /) -> Self: ... |
| 40 | + def __radd__(self, other: int, /) -> Self: ... |
| 41 | + def __sub__(self, other: int, /) -> Self: ... |
| 42 | + def __rsub__(self, other: int, /) -> Self: ... |
| 43 | + def __mul__(self, other: int, /) -> Self: ... |
| 44 | + def __rmul__(self, other: int, /) -> Self: ... |
| 45 | + def __truediv__(self, other: int, /) -> Self: ... |
| 46 | + def __rtruediv__(self, other: int, /) -> Self: ... |
| 47 | + def __pow__(self, other: int, /) -> Self: ... |
| 48 | + def __rpow__(self, other: int, /) -> Self: ... |
30 | 49 |
|
31 | 50 | class flint_poly(flint_elem, Generic[Telem]): |
| 51 | + def str( |
| 52 | + self, ascending: bool = False, var: str = "x", *args: Any, **kwargs: Any |
| 53 | + ) -> str: ... |
32 | 54 | def __iter__(self) -> Iterator[Telem]: ... |
33 | 55 | def __getitem__(self, index: int, /) -> Telem: ... |
| 56 | + def __setitem__(self, index: int, value: Telem | int, /) -> None: ... |
| 57 | + def __len__(self) -> int: ... |
| 58 | + def length(self) -> int: ... |
| 59 | + def degree(self) -> int: ... |
34 | 60 | def coeffs(self) -> list[Telem]: ... |
35 | | - def str(self, ascending: bool = False, var: str = "x", *args: Any, **kwargs: Any): ... |
| 61 | + def __call__(self, other: Telem | int, /) -> Telem: ... |
| 62 | + def __pos__(self) -> Self: ... |
| 63 | + def __neg__(self) -> Self: ... |
| 64 | + def __add__(self, other: Telem | int, /) -> Self: ... |
| 65 | + def __radd__(self, other: Telem | int, /) -> Self: ... |
| 66 | + def __sub__(self, other: Telem | int, /) -> Self: ... |
| 67 | + def __rsub__(self, other: Telem | int, /) -> Self: ... |
| 68 | + def __mul__(self, other: Telem | int, /) -> Self: ... |
| 69 | + def __rmul__(self, other: Telem | int, /) -> Self: ... |
| 70 | + def __truediv__(self, other: Telem | int, /) -> Self: ... |
| 71 | + def __rtruediv__(self, other: Telem | int, /) -> Self: ... |
| 72 | + def __floordiv__(self, other: Telem | int, /) -> Self: ... |
| 73 | + def __rfloordiv__(self, other: Telem | int, /) -> Self: ... |
| 74 | + def __mod__(self, other: Telem | int, /) -> Self: ... |
| 75 | + def __rmod__(self, other: Telem | int, /) -> Self: ... |
| 76 | + def __divmod__(self, other: Telem | int, /) -> tuple[Self, Self]: ... |
| 77 | + def __rdivmod__(self, other: Telem | int, /) -> tuple[Self, Self]: ... |
| 78 | + def __pow__(self, other: int, /) -> Self: ... |
| 79 | + def is_zero(self) -> bool: ... |
| 80 | + def is_one(self) -> bool: ... |
| 81 | + def is_constant(self) -> bool: ... |
| 82 | + def is_gen(self) -> bool: ... |
36 | 83 | def roots(self) -> list[tuple[Telem, int]]: ... |
37 | 84 | # Should be list[arb]: |
38 | 85 | def real_roots(self) -> list[Any]: ... |
39 | 86 | # Should be list[acb]: |
40 | 87 | def complex_roots(self) -> list[Any]: ... |
41 | | - |
| 88 | + def derivative(self) -> Self: ... |
42 | 89 |
|
43 | 90 | class Ordering(enum.Enum): |
44 | 91 | lex = "lex" |
45 | 92 | deglex = "deglex" |
46 | 93 | degrevlex = "degrevlex" |
47 | 94 |
|
48 | | - |
49 | 95 | class flint_mpoly(flint_elem, Generic[Tctx, Telem, Telem_coerce]): |
50 | | - def __init__(self, |
51 | | - val: Self | Telem | Telem_coerce | int | dict[tuple[int, ...], Telem | Telem_coerce | int] | str = 0, |
52 | | - ctx: Tctx | None = None |
| 96 | + def __init__( |
| 97 | + self, |
| 98 | + val: Self |
| 99 | + | Telem |
| 100 | + | Telem_coerce |
| 101 | + | int |
| 102 | + | dict[tuple[int, ...], Telem | Telem_coerce | int] |
| 103 | + | str = 0, |
| 104 | + ctx: Tctx | None = None, |
53 | 105 | ) -> None: ... |
54 | | - |
55 | 106 | def str(self) -> _str: ... |
56 | 107 | def repr(self) -> _str: ... |
57 | | - |
58 | 108 | def context(self) -> Tctx: ... |
59 | | - |
60 | 109 | def degrees(self) -> tuple[int, ...]: ... |
61 | 110 | def total_degree(self) -> int: ... |
62 | | - |
63 | 111 | def leading_coefficient(self) -> Telem: ... |
64 | 112 | def to_dict(self) -> dict[tuple[int, ...], Telem]: ... |
65 | | - |
66 | 113 | def is_one(self) -> bool: ... |
67 | 114 | def is_zero(self) -> bool: ... |
68 | 115 | def is_constant(self) -> bool: ... |
69 | | - |
70 | 116 | def __len__(self) -> int: ... |
71 | 117 | def __getitem__(self, index: tuple[int, ...]) -> Telem: ... |
72 | | - def __setitem__(self, index: tuple[int, ...], coeff: Telem | Telem_coerce | int) -> None: ... |
| 118 | + def __setitem__( |
| 119 | + self, index: tuple[int, ...], coeff: Telem | Telem_coerce | int |
| 120 | + ) -> None: ... |
73 | 121 | def __iter__(self) -> Iterable[tuple[int, ...]]: ... |
74 | 122 | def __contains__(self, index: tuple[int, ...]) -> bool: ... |
75 | | - |
76 | 123 | def coefficient(self, i: int) -> Telem: ... |
77 | 124 | def monomial(self, i: int) -> tuple[int, ...]: ... |
78 | 125 | def terms(self) -> Iterable[tuple[tuple[int, ...], Telem]]: ... |
79 | 126 | def monoms(self) -> list[tuple[int, ...]]: ... |
80 | 127 | def coeffs(self) -> list[Telem]: ... |
81 | | - |
82 | 128 | def __pos__(self) -> Self: ... |
83 | 129 | def __neg__(self) -> Self: ... |
84 | | - def __add__(self, other: Self | Telem | Telem_coerce | int) -> Self: ... |
| 130 | + def __add__(self, other: Telem | Telem_coerce | int) -> Self: ... |
85 | 131 | def __radd__(self, other: Telem | Telem_coerce | int) -> Self: ... |
86 | | - def __sub__(self, other: Self | Telem | Telem_coerce | int) -> Self: ... |
| 132 | + def __sub__(self, other: Telem | Telem_coerce | int) -> Self: ... |
87 | 133 | def __rsub__(self, other: Telem | Telem_coerce | int) -> Self: ... |
88 | | - def __mul__(self, other: Self | Telem | Telem_coerce | int) -> Self: ... |
| 134 | + def __mul__(self, other: Telem | Telem_coerce | int) -> Self: ... |
89 | 135 | def __rmul__(self, other: Telem | Telem_coerce | int) -> Self: ... |
90 | | - def __truediv__(self, other: Self | Telem | Telem_coerce | int) -> Self: ... |
| 136 | + def __truediv__(self, other: Telem | Telem_coerce | int) -> Self: ... |
91 | 137 | def __rtruediv__(self, other: Telem | Telem_coerce | int) -> Self: ... |
92 | | - def __floordiv__(self, other: Self | Telem | Telem_coerce | int) -> Self: ... |
| 138 | + def __floordiv__(self, other: Telem | Telem_coerce | int) -> Self: ... |
93 | 139 | def __rfloordiv__(self, other: Telem | Telem_coerce | int) -> Self: ... |
94 | | - def __mod__(self, other: Self | Telem | Telem_coerce | int) -> Self: ... |
| 140 | + def __mod__(self, other: Telem | Telem_coerce | int) -> Self: ... |
95 | 141 | def __rmod__(self, other: Telem | Telem_coerce | int) -> Self: ... |
96 | | - def __divmod__(self, other: Self | Telem | Telem_coerce | int) -> tuple[Self, Self]: ... |
| 142 | + def __divmod__( |
| 143 | + self, other: Telem | Telem_coerce | int |
| 144 | + ) -> tuple[Self, Self]: ... |
97 | 145 | def __rdivmod__(self, other: Telem | Telem_coerce | int) -> tuple[Self, Self]: ... |
98 | 146 | def __pow__(self, other: Telem | Telem_coerce | int) -> Self: ... |
99 | 147 | def __rpow__(self, other: Telem | Telem_coerce | int) -> Self: ... |
100 | | - |
101 | 148 | def iadd(self, other: Telem | Telem_coerce | int) -> None: ... |
102 | 149 | def isub(self, other: Telem | Telem_coerce | int) -> None: ... |
103 | 150 | def imul(self, other: Telem | Telem_coerce | int) -> None: ... |
104 | | - |
105 | | - def gcd(self, other: Self) -> Self: ... |
106 | 151 | def term_content(self) -> Self: ... |
107 | | - |
108 | 152 | def factor(self) -> tuple[Telem, Sequence[tuple[Self, int]]]: ... |
109 | 153 | def factor_squarefree(self) -> tuple[Telem, Sequence[tuple[Self, int]]]: ... |
110 | | - |
111 | 154 | def sqrt(self) -> Self: ... |
112 | | - |
113 | | - def resultant(self, other: Self, var: _str | int) -> Self: ... |
114 | 155 | def discriminant(self, var: _str | int) -> Self: ... |
115 | | - |
116 | 156 | def deflation_index(self) -> tuple[list[int], list[int]]: ... |
117 | 157 | def deflation(self) -> tuple[Self, list[int]]: ... |
118 | 158 | def deflation_monom(self) -> tuple[Self, list[int], Self]: ... |
119 | | - |
120 | 159 | def inflate(self, N: list[int]) -> Self: ... |
121 | 160 | def deflate(self, N: list[int]) -> Self: ... |
122 | | - |
123 | 161 | def subs(self, mapping: dict[_str | int, Telem | Telem_coerce | int]) -> Self: ... |
124 | | - def compose(self, *args: Self, ctx: Tctx | None = None) -> Self: ... |
125 | 162 | def __call__(self, *args: Telem | Telem_coerce) -> Telem: ... |
126 | | - |
127 | 163 | def derivative(self, var: _str | int) -> Self: ... |
128 | | - |
129 | 164 | def unused_gens(self) -> tuple[_str, ...]: ... |
130 | | - |
131 | 165 | def project_to_context( |
132 | | - self, |
133 | | - other_ctx: Tctx, |
134 | | - mapping: dict[_str | int, _str | int] | None = None |
| 166 | + self, other_ctx: Tctx, mapping: dict[_str | int, _str | int] | None = None |
135 | 167 | ) -> Self: ... |
136 | 168 |
|
137 | | - |
138 | 169 | class flint_mpoly_context(flint_elem, Generic[Tmpoly, Telem, Telem_coerce]): |
139 | | - |
140 | 170 | def nvars(self) -> int: ... |
141 | 171 | def ordering(self) -> Ordering: ... |
142 | | - |
143 | 172 | def gen(self, i: int, /) -> Tmpoly: ... |
144 | 173 | def from_dict(self, d: Mapping[tuple[int, ...], Telem_coerce], /) -> Tmpoly: ... |
145 | 174 | def constant(self, z: Telem_coerce, /) -> Tmpoly: ... |
146 | | - |
147 | 175 | def name(self, i: int, /) -> str: ... |
148 | 176 | def names(self) -> tuple[str]: ... |
149 | 177 | def gens(self) -> tuple[Tmpoly, ...]: ... |
150 | 178 | def variable_to_index(self, var: str, /) -> int: ... |
151 | | - def term(self, coeff: Telem_coerce | None = None, exp_vec: Iterable[int] | None = None) -> Tmpoly: ... |
| 179 | + def term( |
| 180 | + self, coeff: Telem_coerce | None = None, exp_vec: Iterable[int] | None = None |
| 181 | + ) -> Tmpoly: ... |
152 | 182 | def drop_gens(self, gens: Iterable[str | int], /) -> Self: ... |
153 | 183 | def append_gens(self, gens: Iterable[str | int], /) -> Self: ... |
154 | | - def infer_generator_mapping(self, ctx: flint_mpoly_context, /) -> dict[int, int]: ... |
155 | | - |
| 184 | + def infer_generator_mapping( |
| 185 | + self, ctx: flint_mpoly_context, / |
| 186 | + ) -> dict[int, int]: ... |
156 | 187 | @classmethod |
157 | | - def from_context(cls, |
158 | | - ctx: Sctx, |
| 188 | + def from_context( |
| 189 | + cls, |
| 190 | + ctx: flint_mpoly_context, |
159 | 191 | names: str | Iterable[str | tuple[str, int]] | tuple[str, int] | None = None, |
160 | 192 | ordering: Ordering | str = Ordering.lex, |
161 | | - ) -> Sctx: |
162 | | - ... |
163 | | - |
| 193 | + ) -> Self: ... |
164 | 194 |
|
165 | 195 | class flint_mod_mpoly_context(flint_mpoly_context[Tmpoly, Telem, Telem_coerce]): |
166 | 196 | @abstractmethod |
167 | | - def modulus(self) -> int: ... |
168 | | - |
| 197 | + def modulus(self): ... |
169 | 198 |
|
170 | 199 | class flint_series(flint_elem, Generic[Telem]): |
171 | 200 | """Base class for power series.""" |
|
0 commit comments