__init__.pyi
6.5 kB · python · 108 lines
1from typing import Any, Literal23from numpy.typing import NDArray45class Window:6 """The symmetric window of one ring: every point within a reach, with the norms sieved once."""7 def __init__(self, ring: Literal["Gaussian", "Eisenstein"], radius: int) -> None: ...8 def census(self) -> dict[str, Any]:9 """Counts every class inside."""10 def class_(self, a: int, b: int) -> Literal["Zero", "Unit", "Ramified", "Split", "Inert", "Composite"]:11 """Classifies a point: prime when its norm is a rational prime, or when it is a unit times a rational prime that stays prime."""12 def holds(self, a: int, b: int) -> bool:13 """Returns whether a point lies inside."""14 @staticmethod15 def new(ring: Literal["Gaussian", "Eisenstein"], radius: int) -> Window:16 """Opens the window of a ring out to a reach, sieving every norm inside it."""17 def points(self) -> list[tuple[int, int]]:18 """Lists every point inside, row by row from the bottom left of the bounding square."""19 def radius(self) -> int:20 """Returns the reach."""21 def ring(self) -> Literal["Gaussian", "Eisenstein"]:22 """Returns the ring."""23 @staticmethod24 def from_dict(data: Any) -> Window:25 """Reads plain data into the class."""26 def to_dict(self) -> Any:27 """Returns the value as plain data."""2829class Class:30 """What a point of the ring is."""31 @staticmethod32 def prime(class_: Literal["Zero", "Unit", "Ramified", "Split", "Inert", "Composite"]) -> bool:33 """Returns whether the class is prime."""34 @staticmethod35 def word(class_: Literal["Zero", "Unit", "Ramified", "Split", "Inert", "Composite"]) -> str:36 """Returns the class as a word."""3738class Ring:39 """The two rings of whole numbers in the plane, each a pair (a, b) on its own lattice."""40 @staticmethod41 def associates(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> list[tuple[int, int]]:42 """Returns the unit multiples of a point, the point first, turning anticlockwise."""43 @staticmethod44 def canon(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> tuple[int, int]:45 """Returns the canonical associate of a point: the one with `a > 0` and `b >= 0` on the square lattice, the one with `a > 0` and `0 <= b < a` on the hexagonal, the origin for the origin."""46 @staticmethod47 def conjugate(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> tuple[int, int]:48 """Returns the conjugate: the mirror image in the real axis."""49 @staticmethod50 def count(ring: Literal["Gaussian", "Eisenstein"], radius: int) -> int:51 """Returns the count of points within the reach: the square or the hexagon."""52 @staticmethod53 def div_rem(ring: Literal["Gaussian", "Eisenstein"], z: tuple[int, int], w: tuple[int, int]) -> tuple[tuple[int, int], tuple[int, int]]:54 """Returns the quotient and the remainder of a point by a nonzero point: `z = q w + r` with the norm of `r` below the norm of `w`."""55 @staticmethod56 def fate(ring: Literal["Gaussian", "Eisenstein"], n: int) -> Literal["Zero", "Unit", "Ramified", "Split", "Inert", "Composite"]:57 """Returns the fate of a whole number as a prime of the ring: split, inert or ramified, unit for one, zero for zero, composite otherwise."""58 @staticmethod59 def gaussian_gcd(ring: Literal["Gaussian", "Eisenstein"], z: tuple[int, int], w: tuple[int, int]) -> tuple[int, int]:60 """Returns the greatest common divisor of two points as its canonical associate, by the nearest-point Euclidean algorithm, the origin for two origins."""61 @staticmethod62 def inert(ring: Literal["Gaussian", "Eisenstein"], p: int) -> bool:63 """Returns whether a rational prime stays prime in the ring: 3 mod 4, or 2 mod 3."""64 @staticmethod65 def mul(ring: Literal["Gaussian", "Eisenstein"], arg1: tuple[int, int], arg2: tuple[int, int]) -> tuple[int, int]:66 """Returns the product of two points."""67 @staticmethod68 def named(name: str) -> Literal["Gaussian", "Eisenstein"] | None:69 """Reads a ring from its name."""70 @staticmethod71 def nearest(ring: Literal["Gaussian", "Eisenstein"], x: float, y: float) -> tuple[int, int]:72 """Returns the point nearest a place in the plane."""73 @staticmethod74 def norm(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> int:75 """Returns the norm of a point: its squared length."""76 @staticmethod77 def place(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> tuple[float, float]:78 """Returns the place of a point in the plane, x right and y up, one unit between neighbours."""79 @staticmethod80 def ramified(ring: Literal["Gaussian", "Eisenstein"]) -> int:81 """Returns the one rational prime that ramifies: 2 or 3."""82 @staticmethod83 def reach(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> int:84 """Returns the reach of a point: the ring of the window it sits on, the Chebyshev distance or the hex distance."""85 @staticmethod86 def symmetry(ring: Literal["Gaussian", "Eisenstein"]) -> int:87 """Returns the order of the symmetry of the picture, the units and the mirror: 8 or 12."""88 @staticmethod89 def top(ring: Literal["Gaussian", "Eisenstein"], radius: int) -> int:90 """Returns the largest norm within the reach: 2 r^2 at the square's corner, r^2 at the hexagon's."""91 @staticmethod92 def turn(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> tuple[int, int]:93 """Returns the point turned anticlockwise by one unit: a quarter turn or a sixth."""94 @staticmethod95 def units(ring: Literal["Gaussian", "Eisenstein"]) -> int:96 """Returns the count of units: 4 or 6."""97 @staticmethod98 def whole(ring: Literal["Gaussian", "Eisenstein"], a: int, b: int) -> int | None:99 """Returns the whole number an associate of the point lies on, when one lies on the positive real axis."""100101def classes(ring: Literal["Gaussian", "Eisenstein"], bound: int) -> list[tuple[int, int]]:102 """Lists one point per associate class of the nonzero points of norm at most the bound: canonical associates, in order of norm and then of coordinates."""103104def peak(ring: Literal["Gaussian", "Eisenstein"], limit: int) -> tuple[int, int]:105 """Returns the norm from one through the limit with the most points and that count, the earliest on a tie."""106107def shells(ring: Literal["Gaussian", "Eisenstein"], limit: int) -> list[int]:108 """Counts the points of every norm from zero through the limit, by enumeration: the ring weights of the lattice."""