Skip to content

Commit ce20933

Browse files
committed
fmpz_mat: add type stubs
1 parent 9604c20 commit ce20933

3 files changed

Lines changed: 129 additions & 1 deletion

File tree

src/flint/flint_base/flint_base.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ class flint_poly(flint_elem, Generic[Telem]):
8787
def complex_roots(self) -> list[Any]: ...
8888
def derivative(self) -> Self: ...
8989

90+
class flint_mat(flint_elem, Generic[Telem]):
91+
def nrows(self) -> int: ...
92+
def ncols(self) -> int: ...
93+
def __getitem__(self, index: tuple[int, int], /) -> Telem: ...
94+
def __setitem__(self, index: tuple[int, int], value: Telem | int, /) -> None: ...
95+
def entries(self) -> list[Telem]: ...
96+
def table(self) -> list[list[Telem]]: ...
97+
def tolist(self) -> list[list[Telem]]: ...
98+
def __iter__(self) -> Iterator[Telem]: ...
99+
90100
class Ordering(enum.Enum):
91101
lex = "lex"
92102
deglex = "deglex"

src/flint/types/fmpz_mat.pyi

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
from __future__ import annotations
2+
3+
from collections.abc import Iterable, Iterator, Sequence
4+
from typing import Literal, overload
5+
6+
from flint.flint_base.flint_base import flint_mat
7+
from flint.types.fmpq import fmpq
8+
from flint.types.fmpz import fmpz, ifmpz
9+
from flint.types.fmpz_poly import fmpz_poly
10+
11+
_str = str
12+
13+
ifmpz_mat = fmpz_mat | Sequence[Sequence[ifmpz]]
14+
15+
16+
class fmpz_mat(flint_mat[fmpz]):
17+
@overload
18+
def __init__(self, val: ifmpz_mat, /) -> None: ...
19+
@overload
20+
def __init__(self, m: int, n: int, /) -> None: ...
21+
@overload
22+
def __init__(self, m: int, n: int, entries: Iterable[ifmpz], /) -> None: ...
23+
24+
def __bool__(self) -> bool: ...
25+
def __eq__(self, other: object, /) -> bool: ...
26+
def __ne__(self, other: object, /) -> bool: ...
27+
28+
def __getitem__(self, index: tuple[int, int], /) -> fmpz: ...
29+
def __setitem__(self, index: tuple[int, int], value: ifmpz, /) -> None: ...
30+
def __iter__(self) -> Iterator[fmpz]: ...
31+
def entries(self) -> list[fmpz]: ...
32+
def table(self) -> list[list[fmpz]]: ...
33+
def tolist(self) -> list[list[fmpz]]: ...
34+
35+
def det(self) -> fmpz: ...
36+
def __pos__(self) -> fmpz_mat: ...
37+
def __neg__(self) -> fmpz_mat: ...
38+
def __add__(self, other: fmpz_mat, /) -> fmpz_mat: ...
39+
def __sub__(self, other: fmpz_mat, /) -> fmpz_mat: ...
40+
@overload
41+
def __mul__(self, other: fmpz_mat | ifmpz, /) -> fmpz_mat: ...
42+
@overload
43+
def __mul__(self, other: fmpq, /) -> flint_mat: ...
44+
@overload
45+
def __rmul__(self, other: ifmpz, /) -> fmpz_mat: ...
46+
@overload
47+
def __rmul__(self, other: fmpq, /) -> flint_mat: ...
48+
def __truediv__(self, other: ifmpz, /) -> fmpz_mat: ...
49+
def __pow__(self, exponent: int, modulo: None = None, /) -> fmpz_mat: ...
50+
51+
def is_square(self) -> bool: ...
52+
def is_empty(self) -> bool: ...
53+
def is_zero(self) -> bool: ...
54+
def is_one(self) -> bool: ...
55+
def is_neg_one(self) -> bool: ...
56+
def is_upper_triangular(self) -> bool: ...
57+
def is_lower_triangular(self) -> bool: ...
58+
def is_diagonal(self) -> bool: ...
59+
def is_scalar(self) -> bool: ...
60+
def is_hadamard(self) -> bool: ...
61+
def is_hnf(self) -> bool: ...
62+
def is_snf(self) -> bool: ...
63+
64+
@classmethod
65+
def hadamard(cls, n: int, /) -> fmpz_mat: ...
66+
@classmethod
67+
def randtest(cls, m: int, n: int, bits: int, /) -> fmpz_mat: ...
68+
@classmethod
69+
def randbits(cls, m: int, n: int, bits: int, /) -> fmpz_mat: ...
70+
@classmethod
71+
def randrank(cls, m: int, n: int, rank: int, bits: int, /) -> fmpz_mat: ...
72+
73+
def rank(self) -> int: ...
74+
@overload
75+
def inv(self, integer: Literal[False] = False, /) -> flint_mat: ...
76+
@overload
77+
def inv(self, integer: Literal[True], /) -> fmpz_mat: ...
78+
def transpose(self) -> fmpz_mat: ...
79+
@overload
80+
def solve(self, other: fmpz_mat, integer: Literal[False] = False, /) -> flint_mat: ...
81+
@overload
82+
def solve(self, other: fmpz_mat, integer: Literal[True], /) -> fmpz_mat: ...
83+
def _fflu(self) -> tuple[fmpz_mat, fmpz, list[int], int]: ...
84+
def fflu(self) -> tuple[fmpz_mat, fmpz_mat, fmpz_mat, fmpz_mat]: ...
85+
def rref(self, inplace: bool = False, /) -> tuple[fmpz_mat, fmpz, int]: ...
86+
def nullspace(self) -> tuple[fmpz_mat, int]: ...
87+
@overload
88+
def lll(
89+
self,
90+
transform: Literal[False] = False,
91+
delta: float = 0.99,
92+
eta: float = 0.51,
93+
rep: str = "zbasis",
94+
gram: str = "approx",
95+
/,
96+
) -> fmpz_mat: ...
97+
@overload
98+
def lll(
99+
self,
100+
transform: Literal[True],
101+
delta: float = 0.99,
102+
eta: float = 0.51,
103+
rep: str = "zbasis",
104+
gram: str = "approx",
105+
/,
106+
) -> tuple[fmpz_mat, fmpz_mat]: ...
107+
@overload
108+
def hnf(self, transform: Literal[False] = False, /) -> fmpz_mat: ...
109+
@overload
110+
def hnf(self, transform: Literal[True], /) -> tuple[fmpz_mat, fmpz_mat]: ...
111+
def snf(self) -> fmpz_mat: ...
112+
def charpoly(self) -> fmpz_poly: ...
113+
def minpoly(self) -> fmpz_poly: ...
114+
115+
def str(self, *args: object, **kwargs: object) -> _str: ...
116+
def repr(self) -> _str: ...
117+
def __str__(self) -> _str: ...
118+
def __repr__(self) -> _str: ...

src/flint/types/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pyfiles = [
77
'fmpz_poly.pyi',
88
'fmpz_series.pyi',
99
'fmpz_mpoly.pyi',
10-
# 'fmpz_mat.pyi',
10+
'fmpz_mat.pyi',
1111
'fmpz_vec.pyi',
1212

1313
'fmpq.pyi',

0 commit comments

Comments
 (0)