num.d.ts
69.8 kB · typescript · 1088 lines
1export { default, initSync } from "./pkg/num/mrlyjs_num.js";23/** An rgba color as four bytes. */4export type Color = [number, number, number, number];5/** A tensor: its shape and its flat data as a typed array of its dtype. */6export interface Tensor {7 shape: number[];8 data: Uint8Array | Uint16Array | Uint32Array | Int32Array;9}10/** A cell: the shape, the type bytes, and the flat rgba colors and the tags when present. */11export interface Cell {12 shape: number[];13 types: Uint8Array | Uint16Array | Uint32Array | Int32Array;14 colors?: Uint8Array;15 tags?: Uint8Array | Uint16Array | Uint32Array | Int32Array;16}17/** A hex cell: a flat cell with its projection, orientation and start row. */18export interface Cell6d {19 cell: Cell;20 projection: "Iso" | "Pro" | "Cut";21 orientation: "Horizontal" | "Vertical";22 start: number;23}24/** A color inside plain data, serde's form. */25export interface ColorData {26 r: number;27 g: number;28 b: number;29 a: number;30}31/** A tensor inside plain data, serde's form. */32export interface TensorData {33 shape: number[];34 data: { U8: number[] } | { U16: number[] } | { U32: number[] } | { I32: number[] };35}36/** A cell inside plain data, serde's form. */37export interface CellData {38 types: TensorData;39 colors?: number[][];40 tags?: TensorData;41}42/** A hex cell inside plain data, serde's form. */43export interface Cell6dData {44 cell: { cell: CellData };45 projection: "Iso" | "Pro" | "Cut";46 orientation: "Horizontal" | "Vertical";47 start: number;48}49/** A seeded random stream, opened from a number or a bigint seed. */50export class Rng {51 constructor(seed: number | bigint | string);52 free(): void;53 /** Draws a float at or above zero and below one. */54 unit(): number;55 /** Draws an integer below n, or zero when n is zero. */56 below(n: number): number;57 /** Draws an integer between lo and hi inclusive, or lo when hi is not above lo. */58 range(lo: number, hi: number): number;59 /** Draws a fair coin flip. */60 boolean(): boolean;61 /** Returns true with probability p. */62 chance(p: number): boolean;63 /** Draws amount distinct indices below length, or every index when amount is larger. */64 sample_indices(length: number, amount: number): Uint32Array;65 /** Draws one item of the array, the same draw as Rust's choice. */66 choice<T>(items: ArrayLike<T>): T;67 /** Shuffles the array in place, the same permutation as Rust's shuffle. */68 shuffle<T>(items: T[]): void;69}70export declare namespace apollonian {71 /** The bilinear form `B(u, v) = (sum u)(sum v) - 2 sum u v` that the reflection preserves. */72 export function form(u: ArrayLike<number | bigint>, v: ArrayLike<number | bigint>): string;73 /** The box the packing is drawn in: one period of the strip, or the box of the circle that contains a bounded packing. */74 export function frame(p: apollonian.Packing): Float64Array;75 /** Grows the named packing to the curvature cap, one circle per node of the reflection tree and the root quadruple excluded, so `circles.len()` is the census `N(T)`. On the strip only the two root swaps that replace a line are taken, which are exactly the two that stay inside one period. */76 export function grow(name: string, cap: number | bigint): apollonian.Packing;77 /** Whether the circle is the Ford circle over its own tangency point: curvature `2 b^2` and abscissa `2 a b` at the reduced `a/b`. */78 export function is_ford(c: apollonian.Circle): boolean;79 /** Whether the circle has positive curvature and is tangent to the line `y = 0`, which in these coordinates reads `k > 0` and `k y = 1`: the curvature guard is what excludes the line `y = 1`, which is `(0, 0, 1)`. */80 export function on_line(c: apollonian.Circle): boolean;81 /** Reflects the circle at the seat through the other three, `v' = 2(v_1 + v_2 + v_3) - v` on all three coordinates at once, which is the second root of the Descartes quadratic and needs no square root. */82 export function reflect(q: apollonian.Circle[], at: number): apollonian.Circle;83 /** The named root quadruple: `strip` is the two lines a unit apart holding the circles at `0` and `1`, and the rest are bounded packings named by their four curvatures. */84 export function root(name: string): apollonian.Circle[];85 /** Reads the Farey stack of the order against the packing: the nodes lit inside the open period against the tangency points of the line-tangent circles of curvature at most `2 Q^2`, and the brightness `floor(Q/b)` summed on the nodes against `Q(Q + 1)/2`. Off the strip there is no line and every count is zero. */86 export function shadow(p: apollonian.Packing, order: number): apollonian.Shadow;87 /** Whether the quadruple carries all six exact invariants: Descartes `B(k, k) = 0`, the position half `B(k, kx) = B(k, ky) = B(kx, ky) = 0`, and the frame `B(kx, kx) = B(ky, ky) = -4`. */88 export function sound(q: apollonian.Circle[]): boolean;89 /** The quadruple with the circle at the seat replaced by its reflection. */90 export function swap(q: apollonian.Circle[], at: number): apollonian.Circle[];91 /** The tangency points on the line `y = 0`, ascending: one per circle of the packing with `k y = 1`, the root excluded. Empty off the strip. */92 export function touches(p: apollonian.Packing): apollonian.Touch[];93 /** The most circles one growth makes before it gives up. */94 export function CIRCLE_CAP(): number;95 /** The largest curvature a packing is grown to. */96 export function CURVATURE_CAP(): bigint;97 /** The deepest the Farey stack is read against a packing. */98 export function ORDER_CAP(): number;99 /** The root quadruples on offer: the strip first, then the bounded packings named by their curvatures. */100 export function ROOTS(): string[];101 export interface CircleData {102 /** The curvature. */103 k: number;104 /** The curvature times the centre's abscissa. */105 x: number;106 /** The curvature times the centre's ordinate. */107 y: number;108 }109 /** A circle in the integer coordinates `(k, k x, k y)`: a line is `k = 0` with `(k x, k y)` its outward unit normal, and the curvature is negative on the circle that contains a bounded packing. */110 export class Circle {111 private constructor();112 free(): void;113 /** Reads the Circle from its plain data. */114 static from(data: CircleData): Circle;115 /** Writes the Circle as plain data. */116 toJSON(): CircleData;117 /** The curvature. */118 get k(): bigint;119 set k(value: number | bigint);120 /** The curvature times the centre's abscissa. */121 get x(): bigint;122 set x(value: number | bigint);123 /** The curvature times the centre's ordinate. */124 get y(): bigint;125 set y(value: number | bigint);126 /** The centre, none on a line. */127 centre(): [number, number] | undefined;128 /** Whether the circle is a line. */129 is_line(): boolean;130 /** The radius, none on a line. */131 radius(): number | undefined;132 }133 /** A packing grown from its root in exact integers. */134 export interface Packing {135 /** The root quadruple the growth started from. */136 root: apollonian.CircleData[];137 /** Whether the root carries a line, so the packing is the strip and the growth keeps one period. */138 strip: boolean;139 /** The curvature the growth stopped at. */140 cap: number;141 /** The circles the growth made, the root excluded, in curvature order. */142 circles: apollonian.CircleData[];143 /** The quadruples the growth made, the root counted. */144 quads: number;145 /** The quadruples that failed one of the six invariants. */146 broken: number;147 /** The circles centred outside the open period, which the strip must have none of. */148 strayed: number;149 }150 /** The Farey stack read against the packing's tangency points. */151 export interface Shadow {152 /** The depth the stack is read at. */153 order: number;154 /** The curvature a circle of denominator the order carries, twice the order squared. */155 reach: number;156 /** Whether the packing was grown far enough to carry every node of that depth. */157 covered: boolean;158 /** The stack's nodes inside the open period. */159 nodes: number;160 /** The packing's tangency points of denominator at most the order. */161 touched: number;162 /** The nodes no tangency point rests on, plus the tangency points no node lights. */163 missed: number;164 /** The circles below the reach tangent to the line that are not Ford circles. */165 offford: number;166 /** The brightness of the period summed node by node, the node `0/1` on the period's edge counted. */167 bright: bigint;168 /** The closed form that brightness lands on, `Q(Q + 1)/2`. */169 want: bigint;170 }171 /** A tangency point on the line `y = 0`: the reduced fraction the circle rests at and the curvature it carries. */172 export interface Touch {173 /** The numerator of the reduced fraction. */174 num: number;175 /** The denominator of the reduced fraction. */176 den: number;177 /** The curvature of the circle resting there, which the Ford identification forces to be `2 den^2`. */178 k: number;179 }180}181export declare namespace automaton {182 /** The relative rounding allowance the double-precision matrix ladder charges against the scale it carries. */183 export function ROUNDING(): number;184 export type AutomatonData = Record<string, unknown>;185 /** A memory design read as a matrix ladder: the rule, the transfer matrix on its `(k-1)`-window states, and the peel depth its Dirichlet series is continued from. */186 export class Automaton {187 /** Builds the ladder of a rule, choosing the peel depth. */188 constructor(rule: memory.Rule);189 free(): void;190 /** Reads the Automaton from its plain data. */191 static from(data: AutomatonData): Automaton;192 /** Writes the Automaton as plain data. */193 toJSON(): AutomatonData;194 /** Returns the abscissa `alpha = log_q rho`, with `rho` the exact Perron root of [`crate::num::memory::perron`]. */195 abscissa(): number;196 /** Returns the base `q = 2^D`. */197 base(): bigint;198 /** Returns the matrix Lyndon cofactor `Z_W(s) = det(I - q^(-s) T) zeta_W(s)` and the bound it is known to. */199 cofactor(s: zeta.Complex, tolerance: number): [zeta.Complex, number];200 /** Returns the coefficients `c_0 .. c_n` of `det(I - x T) = sum c_i x^i`, the ladder denominator read as a polynomial in `x = q^(-s)`. */201 denominator(): Float64Array;202 /** Returns the transfer matrix `T = Gamma_0` the ladder runs on, the transpose of [`crate::num::memory::transfer`], entry `(u', u)` counting the letters carrying `u` to `u'`. */203 matrix(): Float64Array[];204 /** Returns the peel depth `P`. */205 peel(): number;206 /** Returns the pole spacing `2 pi / log q`. */207 period(): number;208 /** Returns the Collatz-Wielandt bracket `(low, high)` of the Perron root of the transfer matrix, the ratios the ladder divides with. */209 perron(): [number, number];210 /** Returns the residue of `zeta_W` at a simple pole `w0` of the resolvent and the bound it is known to. */211 residue(w0: zeta.Complex, tolerance: number): [zeta.Complex, number];212 /** Returns the rule. */213 rule(): memory.Rule;214 /** Returns the state count `q^(k-1)`. */215 states(): number;216 /** Builds the ladder at an explicit peel depth, at least the rule width and at least two. */217 static with_peel(rule: memory.Rule, peel: number): automaton.Automaton;218 /** Returns `zeta_W(s)` and the bound it is known to. */219 zeta(s: zeta.Complex, tolerance: number): [zeta.Complex, number];220 }221}222export declare namespace blend {223 /** Adds two sequences term by term over their shared length. */224 export function add(a: (string | number | bigint)[], b: (string | number | bigint)[]): string[];225 /** Convolves two sequences, keeping the exact prefix their shared length affords. */226 export function cauchy(a: (string | number | bigint)[], b: (string | number | bigint)[]): string[];227 /** Returns the monic characteristic polynomial of a recurrence, highest power first. */228 export function characteristic(coefficients: ([string | number | bigint, string | number | bigint])[]): [string, string][];229 /** Keeps every step-th term from the offset onward. */230 export function decimate(a: (string | number | bigint)[], step: number, offset: number): string[];231 /** Returns the first differences of a sequence, one term shorter. */232 export function delta(a: (string | number | bigint)[]): string[];233 /** Returns the largest positive real root of a recurrence's characteristic polynomial, the growth rate, or a not-a-number where no real root lands. */234 export function growth(coefficients: ([string | number | bigint, string | number | bigint])[]): number;235 /** Multiplies two sequences term by term over their shared length. */236 export function hadamard(a: (string | number | bigint)[], b: (string | number | bigint)[]): string[];237 /** Finds the smallest linear constant-coefficient recurrence that fits every supplied term. */238 export function recurrence(terms: (string | number | bigint)[]): [string, string][] | undefined;239 /** Multiplies every term of a sequence by the factor. */240 export function scale(a: (string | number | bigint)[], factor: string | number | bigint): string[];241 /** Drops the first terms of a sequence. */242 export function shift(a: (string | number | bigint)[], count: number): string[];243 /** Returns the partial sums of a sequence. */244 export function sigma(a: (string | number | bigint)[]): string[];245 /** Subtracts the second sequence from the first over their shared length. */246 export function sub(a: (string | number | bigint)[], b: (string | number | bigint)[]): string[];247}248export declare namespace boolean {249 /** Reports whether the packed function outputs one on exactly half of its inputs. */250 export function is_balanced(code: string | number | bigint, n: number): boolean;251 /** Returns how far the packed function sits from every affine function, zero when it is one. */252 export function nonlinearity(code: string | number | bigint, n: number): bigint;253 /** Returns the mean chance that flipping one input bit flips the output, 0.5 at full avalanche. */254 export function sac(code: string | number | bigint, n: number): number;255 /** Returns the Walsh spectrum of an n-input boolean function packed as a truth-table code. */256 export function walsh_spectrum(code: string | number | bigint, n: number): BigInt64Array;257}258export declare namespace design {259 /** Returns the digits a bitmask names inside the base, ascending. */260 export function digits_of(mask: number, base: number | bigint): BigUint64Array;261 /** Returns the density echo, the sum of mu(n) A_F(n)/n over the whole numbers up to each grid point divided by x to the exponent, sieving the Mobius values to the largest element. */262 export function echo_series(values: ArrayLike<number | bigint>, log_x: ArrayLike<number>, exponent: number): Float64Array;263 /** Returns the elements of the digit design below the base raised to the depth, ascending: the whole numbers of at most that many base digits, every digit drawn from the set and the leading digit nonzero. */264 export function elements(base: number | bigint, digits: ArrayLike<number | bigint>, depth: number): BigUint64Array;265 /** Returns the log grid uniform over the span of the elements, from the log of the first to the log of the last. */266 export function log_grid(values: ArrayLike<number | bigint>, samples: number): Float64Array;267 /** Returns the running median of the power over a window of the given width, the window clamped at the ends. */268 export function median_floor(power: ArrayLike<number>, width: number): Float64Array;269 /** Returns the running design Mobius meter, the partial sums of the Mobius values along the elements. */270 export function meter(mu: ArrayLike<number>): BigInt64Array;271 /** Returns the distance from the ordinate to the nearest entry of the list, infinite when the list is empty. */272 export function nearest(value: number, list: ArrayLike<number>): number;273 /** Returns the bins inside the band that rise above both neighbours and clear the score threshold, strongest first. */274 export function peaks(gamma: ArrayLike<number>, score: ArrayLike<number>, band: [number, number], threshold: number): Uint32Array;275 /** Returns the design's pole lattice below the top, the ordinates 2 pi j over log q of the poles its Dirichlet series carries. */276 export function pole_lattice(base: number | bigint, top: number): Float64Array;277 /** Reads the running meter at every point of the log grid and divides by x to the exponent. */278 export function resample(values: ArrayLike<number | bigint>, running: ArrayLike<number | bigint>, exponent: number, log_x: ArrayLike<number>): Float64Array;279 /** Returns the power over its local median floor, the score a peak is read against. */280 export function score(power: ArrayLike<number>, width: number): Float64Array;281 /** Returns the count of elements the design holds at the depth, the length [`elements`] returns without building them. */282 export function size(digits: ArrayLike<number | bigint>, depth: number): string;283 /** Returns the frequency axis and the power spectrum of the series: the mean removed, a Hann window laid on, a real transform taken, and bin j read as the ordinate 2 pi j over the log range. */284 export function spectrum(log_x: ArrayLike<number>, series: ArrayLike<number>): [Float64Array, Float64Array];285 /** Returns the root mean square of the upper half of the series, the size the echo and the meter are compared at. */286 export function upper_rms(series: ArrayLike<number>): number;287 /** The ordinates of the first fourteen nontrivial zeros of the Riemann zeta function, the imaginary parts of the zeros on the critical line in ascending order. */288 export function ZETA_ORDINATES(): Float64Array;289}290export declare namespace factor {291 /** Returns the sum of the proper divisors of the number, its divisor sum less itself, zero for zero and for one. */292 export function aliquot(number: number): number;293 /** Returns whether two numbers share no divisor above one. */294 export function coprime(a: number, b: number): boolean;295 /** Builds every divisor of a wide number from its factorization, ascending, empty for zero. */296 export function divisors(number: number | bigint): BigUint64Array;297 /** Returns the factorial of the number, the product of one through it, erring past thirty-four. */298 export function factorial(number: number): string;299 /** Returns the prime and exponent pairs of the number in ascending primes, by trial division on the six-step wheel. */300 export function factorize(number: number): [number, number][];301 /** Returns the prime and exponent pairs of a wide number in ascending primes, by trial division on the six-step wheel. */302 export function factorize_wide(number: number | bigint): [bigint, number][];303 /** Returns the greatest common divisor of two numbers by the Euclidean algorithm, zero for two zeroes. */304 export function gcd(a: string | number | bigint, b: string | number | bigint): string;305 /** Returns the least common multiple of two numbers, zero when either side is zero. */306 export function lcm(a: number, b: number): number;307 /** Returns the Mobius value of the number: zero for zero or a squared factor, else minus one to the count of primes. */308 export function mobius(number: number): number;309 /** Sieves the Mobius values of zero through the limit in one pass. */310 export function mobius_sieve(limit: number): Int8Array;311 /** Returns the radical of the number, the product of its distinct primes, zero for zero and one for one. */312 export function radical(number: number): number;313 /** Reduces a fraction to its lowest terms, a zero numerator and denominator reading as zero over one. */314 export function reduce(numerator: string | number | bigint, denominator: string | number | bigint): [string, string];315 /** Returns the sum of every divisor of the number raised to the power, so power zero counts them. */316 export function sigma(number: number, power: number): string;317 /** Returns whether no prime squares into the number, true for one and false for zero. */318 export function squarefree(number: number): boolean;319 /** Returns the Euler totient of the number from its factorization, zero for zero and one for one. */320 export function totient(number: number): number;321 /** Sieves the Euler totients of zero through n in one pass, the run beside the single value. */322 export function totients(n: number): BigUint64Array;323 /** Returns the divisor sum with a periodic rhythm painted on each divisor, zero for zero and for an empty rhythm. */324 export function twisted(number: number, rhythm: ArrayLike<number>): bigint;325}326export declare namespace fft {327 /** Circularly convolves a size-square field on the torus by a kernel of the same shape through fft2 both ways. */328 export function convolve(field: ArrayLike<number>, kernel: ArrayLike<number>, size: number): Float64Array;329 /** Convolves a size-square field on the torus by a kernel already transformed by fft2, the inverse scaled back by size squared. */330 export function convolve_with(field: ArrayLike<number>, kernel_re: ArrayLike<number>, kernel_im: ArrayLike<number>, size: number): Float64Array;331 /** Lays an odd-side mask into a size-square kernel with the mask centre at index (0, 0) and negative offsets wrapped; the cell at offset (dr, dc) lands at (-dr, -dc) modulo size, so convolving a field by the kernel reads at every site the mask-weighted sum over its neighbours, the neighbour count the life step counts. */332 export function embed_kernel(mask: ArrayLike<number>, side: number, size: number): Float64Array;333 /** Returns the centred magnitude spectrum of a size-square field through log(1 + magnitude), the DC bin included at the centre. */334 export function log_spectrum(field: ArrayLike<number>, size: number): Float64Array;335 /** Returns the magnitudes of a square field's transform, shifted so zero frequency sits at the centre. */336 export function magnitude_spectrum(field: ArrayLike<number>, size: number): Float64Array;337 /** Finds the ring past the centre where a radial profile peaks, a tie broken at the smaller ring; zero when the profile holds no ring past ring 0. */338 export function peak_ring(profile: ArrayLike<number>): number;339 /** Reads the wavelength in cells at a radial profile's peak, size over the peak ring with a tie broken at the smaller ring; zero when the profile holds no ring past ring 0. */340 export function peak_wavelength(profile: ArrayLike<number>, size: number): number;341 /** Averages a centred size-square spectrum over rings of integer radius from the centre bin, a bin joining the ring its distance rounds to, rings 0 through size over two; ring k holds the frequencies near k cycles per field. */342 export function radial_profile(spectrum: ArrayLike<number>, size: number): Float64Array;343 /** Transforms a real size-square field forward by fft2, returning the real and imaginary parts. */344 export function transform(field: ArrayLike<number>, size: number): [Float64Array, Float64Array];345}346export declare namespace gauss {347 /** 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. */348 export function classes(ring: gauss.Ring, bound: number | bigint): [bigint, bigint][];349 /** Returns the norm from one through the limit with the most points and that count, the earliest on a tie. */350 export function peak(ring: gauss.Ring, limit: number): [number, number];351 /** Counts the points of every norm from zero through the limit, by enumeration: the ring weights of the lattice. */352 export function shells(ring: gauss.Ring, limit: number): Uint32Array;353 /** The tallies of a window: every class counted and the share of primes. */354 export interface Census {355 /** The count of points. */356 points: number;357 /** The count of primes. */358 primes: number;359 /** The split primes. */360 split: number;361 /** The inert primes. */362 inert: number;363 /** The ramified primes. */364 ramified: number;365 /** The units. */366 units: number;367 /** The composites. */368 composites: number;369 /** The primes over the points. */370 density: number;371 }372 /** What a point of the ring is. */373 export type Class = "Zero" | "Unit" | "Ramified" | "Split" | "Inert" | "Composite";374 export const Class: {375 /** Returns whether the class is prime. */376 prime(class_: gauss.Class): boolean;377 /** Returns the class as a word. */378 word(class_: gauss.Class): string;379 };380 /** The two rings of whole numbers in the plane, each a pair (a, b) on its own lattice. */381 export type Ring = "Gaussian" | "Eisenstein";382 export const Ring: {383 /** Returns the unit multiples of a point, the point first, turning anticlockwise. */384 associates(ring: gauss.Ring, a: number | bigint, b: number | bigint): [bigint, bigint][];385 /** 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. */386 canon(ring: gauss.Ring, a: number | bigint, b: number | bigint): [bigint, bigint];387 /** Returns the conjugate: the mirror image in the real axis. */388 conjugate(ring: gauss.Ring, a: number | bigint, b: number | bigint): [bigint, bigint];389 /** Returns the count of points within the reach: the square or the hexagon. */390 count(ring: gauss.Ring, radius: number | bigint): number;391 /** 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`. */392 div_rem(ring: gauss.Ring, z: [number | bigint, number | bigint], w: [number | bigint, number | bigint]): [[bigint, bigint], [bigint, bigint]];393 /** 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. */394 fate(ring: gauss.Ring, n: number | bigint): gauss.Class;395 /** Returns the greatest common divisor of two points as its canonical associate, by the nearest-point Euclidean algorithm, the origin for two origins. */396 gaussian_gcd(ring: gauss.Ring, z: [number | bigint, number | bigint], w: [number | bigint, number | bigint]): [bigint, bigint];397 /** Returns whether a rational prime stays prime in the ring: 3 mod 4, or 2 mod 3. */398 inert(ring: gauss.Ring, p: number | bigint): boolean;399 /** Returns the product of two points. */400 mul(ring: gauss.Ring, arg1: [number | bigint, number | bigint], arg2: [number | bigint, number | bigint]): [bigint, bigint];401 /** Reads a ring from its name. */402 named(name: string): gauss.Ring | undefined;403 /** Returns the point nearest a place in the plane. */404 nearest(ring: gauss.Ring, x: number, y: number): [bigint, bigint];405 /** Returns the norm of a point: its squared length. */406 norm(ring: gauss.Ring, a: number | bigint, b: number | bigint): bigint;407 /** Returns the place of a point in the plane, x right and y up, one unit between neighbours. */408 place(ring: gauss.Ring, a: number | bigint, b: number | bigint): [number, number];409 /** Returns the one rational prime that ramifies: 2 or 3. */410 ramified(ring: gauss.Ring): bigint;411 /** Returns the reach of a point: the ring of the window it sits on, the Chebyshev distance or the hex distance. */412 reach(ring: gauss.Ring, a: number | bigint, b: number | bigint): bigint;413 /** Returns the order of the symmetry of the picture, the units and the mirror: 8 or 12. */414 symmetry(ring: gauss.Ring): number;415 /** Returns the largest norm within the reach: 2 r^2 at the square's corner, r^2 at the hexagon's. */416 top(ring: gauss.Ring, radius: number | bigint): bigint;417 /** Returns the point turned anticlockwise by one unit: a quarter turn or a sixth. */418 turn(ring: gauss.Ring, a: number | bigint, b: number | bigint): [bigint, bigint];419 /** Returns the count of units: 4 or 6. */420 units(ring: gauss.Ring): number;421 /** Returns the whole number an associate of the point lies on, when one lies on the positive real axis. */422 whole(ring: gauss.Ring, a: number | bigint, b: number | bigint): bigint | undefined;423 };424 export type WindowData = Record<string, unknown>;425 /** The symmetric window of one ring: every point within a reach, with the norms sieved once. */426 export class Window {427 /** Opens the window of a ring out to a reach, sieving every norm inside it. */428 constructor(ring: gauss.Ring, radius: number | bigint);429 free(): void;430 /** Reads the Window from its plain data. */431 static from(data: WindowData): Window;432 /** Writes the Window as plain data. */433 toJSON(): WindowData;434 /** Counts every class inside. */435 census(): gauss.Census;436 /** Classifies a point: prime when its norm is a rational prime, or when it is a unit times a rational prime that stays prime. */437 class(a: number | bigint, b: number | bigint): gauss.Class;438 /** Returns whether a point lies inside. */439 holds(a: number | bigint, b: number | bigint): boolean;440 /** Lists every point inside, row by row from the bottom left of the bounding square. */441 points(): [bigint, bigint][];442 /** Returns the reach. */443 radius(): bigint;444 /** Returns the ring. */445 ring(): gauss.Ring;446 }447}448export declare namespace ladder {449 /** Returns the Lyndon cofactor `Z(s) = zeta_F(s) (1 - k q^(-s))` and the bound it is known to. */450 export function cofactor(design: ladder.Design, s: zeta.Complex, tolerance: number): [zeta.Complex, number];451 /** Returns the residue of `zeta_F` at `s_(m,j) = alpha - m + 2 pi i j / log q` and the bound it is known to. */452 export function residue(design: ladder.Design, m: number, j: number | bigint, tolerance: number): [zeta.Complex, number];453 /** Returns `zeta_F(s)` and the bound it is known to. */454 export function zeta(design: ladder.Design, s: zeta.Complex, tolerance: number): [zeta.Complex, number];455 /** The relative rounding allowance the double-precision ladder charges against the scale it carries. */456 export function ROUNDING(): number;457 export type DesignData = Record<string, unknown>;458 /** A digit design: the base `q`, the digit set `F` its elements are written with, and the peel depth `P` its ladder starts at. */459 export class Design {460 /** Builds a design on the base and the digit set, choosing the peel depth. */461 constructor(base: number | bigint, digits: ArrayLike<number | bigint>);462 free(): void;463 /** Reads the Design from its plain data. */464 static from(data: DesignData): Design;465 /** Writes the Design as plain data. */466 toJSON(): DesignData;467 /** Returns the abscissa `alpha = log_q k`. */468 abscissa(): number;469 /** Returns the base. */470 base(): bigint;471 /** Returns the digit set, ascending. */472 digits(): BigUint64Array;473 /** Returns the peel depth. */474 peel(): number;475 /** Returns the pole spacing `2 pi / log q`. */476 period(): number;477 /** Returns the pole `s_(m,j) = alpha - m + 2 pi i j / log q`. */478 pole(m: number, j: number | bigint): zeta.Complex;479 /** Builds a design at an explicit peel depth, at least two. */480 static with_peel(base: number | bigint, digits: ArrayLike<number | bigint>, peel: number): ladder.Design;481 }482}483export declare namespace lattice {484 /** Counts the ordered pairs of coprime coordinates between one and n: twice the totient sum less one. */485 export function coprime_pairs(n: number): bigint;486 /** Walks the Farey sequence of the order by the Stern-Brocot mediant recurrence from zero over one to one over one: every reduced fraction with denominator at most the order, ascending. */487 export function farey(order: number): lattice.Node[];488 /** Lists the grid crossings of a window's nodes, row-major over the ascending axis nodes. */489 export function grid(n: number): lattice.Node2d[];490 /** Counts the nodes window n lights that window n minus one lacked: two at window one, phi of n after. */491 export function new_nodes(n: number): bigint;492 /** Estimates pi from visibility: the density of coprime pairs in the n-by-n window tends to six over pi squared. */493 export function pi_estimate(n: number): number;494 /** Recovers the constant the dimension hides from the visible count of the window, pi at an even dimension and zeta of the dimension at an odd one. */495 export function recovered(n: number, dimension: number): number;496 /** The density the visible count of a window in the dimension walks to, one over zeta of the dimension. */497 export function visible_density(dimension: number): number;498 /** The rational factor r with zeta of the dimension equal to r times pi to the dimension, read off the Bernoulli fraction; none at an odd dimension or past twelve. */499 export function zeta_factor(dimension: number): number | undefined;500 /** The value zeta takes at a whole argument above one, the exact Bernoulli form at an even one and the Euler-Maclaurin sum at an odd one. */501 export function zeta_whole(s: number): number;502 /** A visible node: a reduced fraction and the brightness a stack of scales one through the window gives it. */503 export interface Node {504 /** The numerator, coprime to the denominator. */505 num: number;506 /** The denominator. */507 den: number;508 /** The count of scales putting a line here: the floor of the window over the denominator. */509 brightness: number;510 }511 /** A grid crossing of two visible nodes, its brightness the separable product. */512 export interface Node2d {513 /** The horizontal node. */514 x: lattice.Node;515 /** The vertical node. */516 y: lattice.Node;517 /** The product of the two axis brightnesses. */518 brightness: number;519 }520}521export declare namespace memory {522 /** Returns the count of allowed windows `card W`, the bits the code sets inside its window range. */523 export function allowed_windows(rule: memory.Rule): number;524 /** Returns the accepted words of the level as cell indices of the `2^L` grid, `x` from bit `0` of every digit, `y` from bit `1`, `z` from bit `2`, coarsest digit first. */525 export function cells(rule: memory.Rule, level: number): BigUint64Array;526 /** Returns `N_W(L)`, the count of accepted words, for `L = 1 ..= levels`, and stops early on the level whose count overruns a `u64`. */527 export function counts(rule: memory.Rule, levels: number): BigUint64Array;528 /** Returns the growth exponent `log_2 rho`, the growth per digit of the accepted word count. */529 export function exponent(rule: memory.Rule): number;530 /** Returns the memory number `kappa(W) = log_2(card W) / k - log_2 rho`, the bits a digit spends on memory. */531 export function kappa(rule: memory.Rule): number;532 /** Returns the Perron root of the transfer matrix, the count's growth per level. */533 export function perron(rule: memory.Rule): number;534 /** Returns the transfer matrix on the `(k - 1)`-windows: entry `(s, t)` is one when the window that overlaps state `s` onto state `t` is allowed. */535 export function transfer(rule: memory.Rule): BigUint64Array[];536 /** The largest digit span a rule may read, so its code fits a `u64`. */537 export function SPAN(): number;538 /** The sweep cap of the power iteration. */539 export function SWEEPS(): number;540 /** The absolute `l^1` move of the normalised iterate that stops the power iteration, counted only when it holds over three consecutive sweeps. */541 export function TOLERANCE(): number;542 export interface RuleData {543 /** The dimension `D`, one to three. */544 dimension: number;545 /** The window width `k`, at least one. */546 width: number;547 /** The window code, bit `w` set when window `w` is allowed. */548 code: number;549 }550 /** A rule on `k` consecutive digits of a design word. */551 export class Rule {552 /** Builds a rule from its dimension, its width and its code. */553 constructor(dimension: number, width: number, code: number | bigint);554 free(): void;555 /** Reads the Rule from its plain data. */556 static from(data: RuleData): Rule;557 /** Writes the Rule as plain data. */558 toJSON(): RuleData;559 /** The dimension `D`, one to three. */560 get dimension(): number;561 set dimension(value: number);562 /** The window width `k`, at least one. */563 get width(): number;564 set width(value: number);565 /** The window code, bit `w` set when window `w` is allowed. */566 get code(): bigint;567 set code(value: number | bigint);568 /** Returns whether a word, coarsest digit first, is accepted. */569 accepts(word: ArrayLike<number>): boolean;570 /** Returns whether the window is allowed, and false for any window out of range. */571 allowed(window: number): boolean;572 /** Returns the letters that stand in at least one allowed window. */573 alphabet(): Uint32Array;574 /** Returns the count of rules of this shape, `2^(2^(k D))`. */575 codes(): string;576 /** Returns the rule that allows every window. */577 static full(dimension: number, width: number): memory.Rule;578 /** Returns the letter count `2^D`, the digit vectors of the cube's corners. */579 letters(): number;580 /** Returns the state count `2^((k - 1) D)`, the windows of one digit less that the transfer matrix runs on. */581 states(): number;582 /** Returns the window count `2^(k D)`. */583 windows(): number;584 }585}586export declare namespace morse {587 /** Returns the run-boundary word, one wherever a letter differs from the next. */588 export function boundary(word: ArrayLike<number>): Uint8Array;589 /** Exclusive-ors two grids of the same length, site by site. */590 export function difference(a: ArrayLike<number>, b: ArrayLike<number>): Uint8Array;591 /** Builds the first letters of the Thue-Morse word by the digit rule. */592 export function digits(length: number): Uint8Array;593 /** Builds the period-doubling word by the substitution `1 -> 10`, `0 -> 11`, from the seed 1. */594 export function doubling(length: number): Uint8Array;595 /** Counts the sites where two grids of the same length differ. */596 export function faults(a: ArrayLike<number>, b: ArrayLike<number>): number;597 /** Tests a grid against the Kronecker power of its own corner tile. */598 export function fold(grid: ArrayLike<number>, side: number, number: number): morse.Fold;599 /** Returns the Thue-Morse letter at the place, the parity of its binary digit sum. */600 export function letter(place: number | bigint): number;601 /** Builds a lift as a row-major sign grid of the side, zero for plus one and one for minus one. */602 export function lift(kind: morse.Lift, side: number): Uint8Array;603 /** Folds a tile of the side into its Kronecker power at the level, one bit per site. */604 export function power(tile: ArrayLike<number>, number: number, level: number): Uint8Array;605 /** Repeats a tile until it fills a grid of the side. */606 export function repeat(tile: ArrayLike<number>, number: number, side: number): Uint8Array;607 /** Returns the lengths of the maximal blocks of one repeated letter, in order. */608 export function runs(word: ArrayLike<number>): Uint32Array;609 /** Returns the substitution stage after the rounds, a word of length two to the rounds. */610 export function stage(rounds: number): Uint8Array;611 /** Builds the first letters of the Thue-Morse word by the substitution `0 -> 01`, `1 -> 10`. */612 export function substitution(length: number): Uint8Array;613 /** Blows a grid up by the scale, every site becoming a scale-by-scale block. */614 export function upsample(grid: ArrayLike<number>, side: number, scale: number): Uint8Array;615 /** Lists the lifts in the order the gallery draws them. */616 export function LIFTS(): morse.Lift[];617 /** The verdict on whether a grid is the Kronecker power of its own corner tile. */618 export interface Fold {619 /** The corner tile the test folds, row major. */620 tile: number[];621 /** The side of the tile. */622 number: number;623 /** The count of tile factors the side asks for. */624 level: number;625 /** Whether the grid is that tile's Kronecker power. */626 folds: boolean;627 /** The count of sites where the grid and the power differ. */628 faults: number;629 /** The first differing site in row-major order, when there is one. */630 first?: [number, number];631 }632 /** The four ways the word lifts from a line to the plane, one sign at every site. */633 export type Lift = "Parity" | "And" | "Xor" | "Sum";634 export const Lift: {635 /** Returns every Lift in canonical order. */636 all(): morse.Lift[];637 /** Returns the sign at a site, zero for plus one and one for minus one. */638 at(lift: morse.Lift, i: number | bigint, j: number | bigint): number;639 /** Returns the lift's formula, written the way the page prints it. */640 formula(lift: morse.Lift): string;641 };642}643export declare namespace prime {644 /** Reads the prime count against x over ln x and li at evenly spaced points from two up to the top, at most the given count of them, the top always last. */645 export function chart(top: number, bins: number): prime.Reading[];646 /** Returns whether every number from zero through the limit is prime, the finished sieve read flag by flag. */647 export function flags(limit: number): boolean[];648 /** Returns the count of unordered pairs of primes summing to the number, zero below four. */649 export function goldbach(number: number): number;650 /** Returns the count of prime pairs at every even number from four up to the top, one entry per even number. */651 export function goldbach_record(top: number): Uint32Array;652 /** Returns whether the number is prime, by trial division on the six-step wheel. */653 export function is_prime(number: number): boolean;654 /** Reads a wide number as a pile of stones, its rectangles built from the divisors of its factorization. */655 export function pile(number: number | bigint): prime.Pile;656 /** Returns the count of primes at or below n. */657 export function prime_count(n: number): number;658 /** Returns the smallest prime at or above the number. */659 export function prime_from(number: number): number;660 /** Returns the primes up to the limit, the finished sieve read as a list. */661 export function primes(limit: number): Uint32Array;662 /** Returns every rectangle of the number as a pair of sides, the shorter first, ascending: the divisors at or below the root. */663 export function rectangles(number: number): [number, number][];664 /** Returns every pair of primes summing to the number, odd numbers included, the smaller first, ascending. */665 export function splits(number: number): [number, number][];666 /** Returns the smallest pair of positive sides whose squares sum to the number, when one exists. */667 export function squares(number: number): [number, number] | undefined;668 /** Returns one prime object for every prime up to and including the limit. */669 export function study(limit: number): prime.Prime[];670 /** A number as a pile of stones: its prime factors, whether it is prime, and every rectangle the stones make. */671 export interface Pile {672 /** The count of stones. */673 number: number;674 /** The prime and exponent pairs, ascending. */675 factors: [number, number][];676 /** Whether the stones make a single row and nothing else. */677 prime: boolean;678 /** Every rectangle as a pair of sides, the shorter first, ascending. */679 rectangles: [number, number][];680 }681 /** The prime object: one prime with its rank, the step behind it and the shapes it makes. */682 export interface Prime {683 /** The prime itself. */684 value: number;685 /** The one-based rank in the prime sequence, so two has index one. */686 index: number;687 /** The distance from the previous prime, zero for two. */688 gap: number;689 /** The twin flag: whether a prime sits exactly two away on either side, false for two. */690 twin: boolean;691 /** The two positive sides whose squares sum to the prime, when they exist. */692 squares?: [number, number];693 }694 /** One reading of the prime count against its two smooth guesses. */695 export interface Reading {696 /** The point on the number line. */697 x: number;698 /** The count of primes up to it. */699 pi: number;700 /** The guess x over ln x. */701 ratio: number;702 /** The logarithmic integral. */703 li: number;704 }705 export type SieveData = Record<string, unknown>;706 /** The sieve of Eratosthenes taken one prime at a time, each number remembering which prime struck it. */707 export class Sieve {708 /** Starts a sieve over zero through the limit with every number untouched; it is done at once when no prime has its square inside. */709 constructor(limit: number);710 free(): void;711 /** Reads the Sieve from its plain data. */712 static from(data: SieveData): Sieve;713 /** Writes the Sieve as plain data. */714 toJSON(): SieveData;715 /** Returns the count of numbers marked prime so far. */716 count(): number;717 /** Returns whether every number is settled. */718 done(): boolean;719 /** Runs the sieve to the end. */720 finish(): void;721 /** Returns the count of primes used so far. */722 rank(): number;723 /** Uses the next prime: marks it prime, strikes its untouched multiples from its square with its rank plus one, and returns it; zero once done. */724 step(): number;725 /** Returns the count of numbers the last step struck. */726 struck(): number;727 /** Returns the type of every number from zero: zero untouched, one prime, and one past the rank of the prime that struck it. */728 types(): Uint8Array;729 }730}731export declare namespace radix {732 /** Returns the flowsnake as a radix design: base `3 + omega` of norm seven on the hexagonal lattice, the full residue system, code `127`. */733 export function flowsnake(): radix.Radix;734 /** Returns the Sierpinski gasket as a radix design: base `2` on the hexagonal lattice, three of the four residues, code `7`. */735 export function gasket(): radix.Radix;736 /** Returns the Koch curve as a radix design: base `3` on the hexagonal lattice, digits `0, 1, 2 + omega, 2`, twists `1, e^(i pi/3), e^(-i pi/3), 1`. */737 export function koch(): radix.Radix;738 /** Returns the terdragon as a radix design: base `2 + omega` on the hexagonal lattice, the full residue system, code `7`, twisted by `1, omega, 1`. */739 export function terdragon(): radix.Radix;740 /** Returns the plane design of a cell code as a radix design: base the rational integer `m`, of norm `m^2`, on the square lattice, no twist, digits the box residues `{x + y i : 0 <= x, y < m}`. */741 export function tile(m: number | bigint, code: string | number | bigint): radix.Radix;742 /** Returns the twindragon as a radix design: base `1 + i` on the square lattice, the full residue system, code `3`. */743 export function twindragon(): radix.Radix;744 export type BaseData = Record<string, unknown>;745 /** The base of a radix design: a ring and an element of norm at least two, the scale every word is read against. */746 export class Base {747 /** Fixes a base in a ring. */748 constructor(ring: gauss.Ring, value: [number | bigint, number | bigint]);749 free(): void;750 /** Reads the Base from its plain data. */751 static from(data: BaseData): Base;752 /** Writes the Base as plain data. */753 toJSON(): BaseData;754 /** Returns the index in the canonical residue system of the class of a point. */755 class(z: [number | bigint, number | bigint]): number;756 /** Returns whether two points are congruent modulo the base. */757 congruent(z: [number | bigint, number | bigint], w: [number | bigint, number | bigint]): boolean;758 /** Returns the symmetry group of the base as permutations of the canonical residue indices: every unit multiplication, and every unit times conjugation when the conjugate of the base is an associate of the base. */759 group(): Uint32Array[];760 /** Returns whether the conjugate of the base is an associate of the base, which is when the mirror joins the symmetry group. */761 mirrored(): boolean;762 /** Returns the norm `q` of the base: the count of residue classes and the square of the scale. */763 norm(): bigint;764 /** Returns the base raised to a level. */765 power(level: number): [bigint, bigint];766 /** Returns the canonical complete residue system modulo the base: the `q` representatives of least norm, ties broken by argument in `[0, 2 pi)`. */767 residues(): [bigint, bigint][];768 /** Returns the ring. */769 ring(): gauss.Ring;770 /** Returns the base element. */771 value(): [bigint, bigint];772 }773 export type RadixData = Record<string, unknown>;774 /** A radix design: a digit set inside one ring, placed by a base with a unit twist per digit. */775 export class Radix {776 /** Builds a design from a base, a digit list and a unit twist per digit. */777 constructor(base: radix.Base, digits: ([number | bigint, number | bigint])[], twists: ([number | bigint, number | bigint])[]);778 free(): void;779 /** Reads the Radix from its plain data. */780 static from(data: RadixData): Radix;781 /** Writes the Radix as plain data. */782 toJSON(): RadixData;783 /** Returns the base. */784 base(): radix.Base;785 /** Returns whether every digit is the canonical representative of its class. */786 canonical(): boolean;787 /** Returns the code of the classes the digits occupy, which names the design only when the digits are the canonical representatives. */788 code(): string;789 /** Returns the digits. */790 digits(): [bigint, bigint][];791 /** Returns the similarity dimension `log |F| / log sqrt(q)`, the ratio of the digit count to the scale of the base. */792 dimension(): number;793 /** Returns the count of distinct level-`L` points: the glue count, which is the fill exactly when no two words name one point. */794 distinct(level: number): number;795 /** Returns the count of words of a level, `|F|^L`. */796 fill(level: number): string;797 /** Builds an untwisted design from a code over the canonical residue system, bit `i` of the code selecting residue `i`. */798 static from_code(base: radix.Base, code: string | number | bigint): radix.Radix;799 /** Returns the level-`L` points in the plane, the scaled words divided by `b^L`. */800 plane(level: number): [number, number][];801 /** Returns the ring. */802 ring(): gauss.Ring;803 /** Returns the digit count `|F|`. */804 size(): number;805 /** Returns the twists. */806 twists(): [bigint, bigint][];807 /** Returns the design with the twists named by their index in the unit list, the units in turning order from one. */808 with_twists(units: ArrayLike<number>): radix.Radix;809 /** Returns the level-`L` points in exact ring coordinates scaled by `b^L`. */810 words(level: number): [bigint, bigint][];811 }812}813export declare namespace series {814 /** Returns the Basel sum of the reciprocal squares over n terms, walking to pi squared over six. */815 export function basel(n: number): number;816 /** Builds the first Bernoulli numbers as exact reduced fractions on the minus one half convention. */817 export function bernoulli(count: number): [string, string][];818 /** Returns the Dirichlet beta value, the alternating odd-denominator sum averaged over its last two partial sums. */819 export function beta(s: number, terms: number): number;820 /** Returns the powers of two up to the limit. */821 export function binary(limit: number): Uint32Array;822 /** Returns the distinct Catalan numbers up to the limit. */823 export function catalan(limit: number): Uint32Array;824 /** Returns the mod-three rhythm of the number: zero, one, minus one. */825 export function chi3(number: number): number;826 /** Returns the mod-four rhythm of the number: zero, one, zero, minus one. */827 export function chi4(number: number): number;828 /** Returns the mod-eight rhythm of the number, the discriminant minus-eight character: one on one and three, minus one on five and seven, zero on the evens. */829 export function chi8(number: number): number;830 /** Returns the L-series partial sum with a periodic rhythm painted on the terms. */831 export function dirichlet(s: number, rhythm: ArrayLike<number>, terms: number): number;832 /** Returns one plus one over n raised to the n, walking to the natural base. */833 export function e_partial(n: number): number;834 /** Returns the harmonic sum of n terms less the logarithm of n, walking to the Euler-Mascheroni constant. */835 export function euler_gamma_partial(n: number): number;836 /** Returns the Euler product of zeta, one over one minus p to the minus s over the primes up to the limit. */837 export function euler_product(s: number, limit: number): number;838 /** Returns the even numbers up to the limit. */839 export function evens(limit: number): Uint32Array;840 /** Returns the distinct Fibonacci numbers up to the limit. */841 export function fibonacci(limit: number): Uint32Array;842 /** Returns the partial harmonic sum, the reciprocals of one through the term count. */843 export function harmonic(terms: number): number;844 /** Returns the Dirichlet lambda value, one minus two to the minus s times zeta. */845 export function lambda(s: number, terms: number): number;846 /** Returns the Leibniz alternating sum of the odd reciprocals over n terms, walking to pi over four. */847 export function leibniz(n: number): number;848 /** Returns the logarithmic integral of a positive x by the Ramanujan series, the smooth count of the primes below x. */849 export function li(x: number): number;850 /** Returns the Mertens function at n, the Mobius values of one through n summed. */851 export function mertens(n: number): bigint;852 /** Returns the odd numbers up to the limit. */853 export function odds(limit: number): Uint32Array;854 /** Counts the lattice points of the dimension-cube of the limit whose coordinates share no divisor, by Mobius inversion. */855 export function visible(limit: number, dimension: number): string;856 /** Returns the Wallis product taken to n paired factors, four k squared over four k squared less one, walking to pi over two. */857 export function wallis_half_pi(n: number): number;858 /** Returns the Wallis product of one minus one over the odd squares taken to n factors, walking to pi over four. */859 export function wallis_quarter_pi(factors: number): number;860 /** Returns the zeta value above one, the partial sum closed by its Euler-Maclaurin tail. */861 export function zeta(s: number, terms: number): number;862 /** The Apery constant, the value zeta takes at three. */863 export function APERY(): number;864 /** The Basel constant, pi squared over six, the value zeta takes at two. */865 export function BASEL(): number;866 /** The Catalan constant, the value the Dirichlet beta function takes at two. */867 export function CATALAN(): number;868 /** The Euler constant, the limit of the harmonic sum less the logarithm. */869 export function EULER(): number;870 /** The visible density, six over pi squared, the share of lattice pairs that are coprime. */871 export function VISIBLE(): number;872}873export declare namespace sieve {874 /** Returns the cells the word leaves, the product of its letters' fills, one punctured tile a letter. */875 export function cells(word: ArrayLike<number | bigint>, dimension: number): string;876 /** Returns the box exponent the word reads at its own scale, the logarithm of its cells over the logarithm of its side, which walks up to the dimension on a schedule of distinct growing letters and stands still on any schedule that reuses its letters. */877 export function exponent(word: ArrayLike<number | bigint>, dimension: number): number;878 /** Returns the constant schedule, one odd side repeated to the count of levels, whose limit set is the fixed-ratio carpet. */879 export function flat_word(side: number | bigint, levels: number): BigUint64Array;880 /** Returns the punctures the word makes, one per surviving cell at every level. */881 export function holes(word: ArrayLike<number | bigint>, dimension: number): string;882 /** Returns the limit the word's schedule walks to in the given dimension, when the word names a schedule at all. */883 export function limit(word: ArrayLike<number | bigint>, dimension: number): number | undefined;884 /** Returns the classical Wallis schedule, the odd sides three, five, seven and on, to the count of levels. */885 export function odd_word(levels: number): BigUint64Array;886 /** Lists every puncture the word makes in the given dimension: its corner along each axis and then its side, all in units of the word's finest cell, so a level-one hole is the widest block in the list. */887 export function punctures(word: ArrayLike<number | bigint>, dimension: number): BigUint64Array;888 /** Builds the plane sieve the word spells as a raster: its side, then one byte a site, row by row, one where the site survives and zero where a level punched it out. */889 export function raster(word: ArrayLike<number | bigint>): [number, Uint8Array];890 /** Returns the share of the whole the word leaves, the product of one minus the inverse of each letter's site count, exact as a product of the letters' fills. */891 export function ratio(word: ArrayLike<number | bigint>, dimension: number): number;892 /** Returns the side of the word, the product of its letters' sides. */893 export function side(word: ArrayLike<number | bigint>): string;894 /** Returns the limit of the solid Wallis sieve's surviving volume, the product of one minus n to the minus three over the odd n from three, in closed form. */895 export function solid_limit(): number;896 /** The limit of the plane Wallis sieve's surviving area, pi over four. */897 export function PLANE_LIMIT(): number;898}899export declare namespace spiral {900 /** Reads the quadratic a k^2 + b k + c, a at least one, over the sheet the odd side wide: every value from one through the top, its cell, the prime hits and the opening streak. */901 export function diagonal(lattice: spiral.Lattice, side: number, a: number | bigint, b: number | bigint, c: number | bigint): spiral.Diagonal;902 /** Returns the level of a number in a base, the count of its digits less one, so zero below the base and one at the base itself. */903 export function level_of(n: number | bigint, base: number | bigint): number;904 /** Marks every number from zero through the limit: one when marked, minus one for a Mobius value of minus one, else zero. */905 export function marks(mark: spiral.Mark, limit: number): Int8Array;906 /** Winds one to the top on the square spiral and lays a square tile on every cell, the snail. */907 export function snail(base: number | bigint, top: number | bigint, growth: spiral.Growth): spiral.Snail;908 /** The readout of one quadratic a k^2 + b k + c across a sheet: where it lands and how often on a prime. */909 export interface Diagonal {910 /** The count of numbers the sheet holds. */911 top: number;912 /** The count of primes among them. */913 primes: number;914 /** The primes as a share of the numbers. */915 density: number;916 /** The values of the quadratic inside the sheet, k counting up from zero. */917 values: number[];918 /** The cell of each value. */919 cells: [number, number][];920 /** Whether each value is prime. */921 hit: boolean[];922 /** The count of values that are prime. */923 hits: number;924 /** The count of primes before the first composite. */925 streak: number;926 /** The hits as a share of the values, zero when the quadratic misses the sheet. */927 share: number;928 }929 /** Which cells of the square winding grow into a tile. */930 export type Growth = "Prime" | "Every";931 export const Growth: {932 /** Returns every Growth in canonical order. */933 all(): spiral.Growth[];934 };935 /** The two lattices a spiral of the whole numbers is wound on, one at the centre and two to its right. */936 export type Lattice = "Square" | "Hex";937 export const Lattice: {938 /** Returns every Lattice in canonical order. */939 all(): spiral.Lattice[];940 /** Returns the count of numbers a sheet the odd side wide holds: the side squared, or the hexagon of that many cells across. */941 count(lattice: spiral.Lattice, side: number): number;942 /** Returns the number at a cell, one at the origin. */943 n(lattice: spiral.Lattice, x: number | bigint, y: number | bigint): bigint;944 /** Returns the outermost ring of a sheet the odd side wide, half the side rounded down. */945 radius(lattice: spiral.Lattice, side: number): number;946 /** Returns the ring a number sits on, zero for one. */947 ring(lattice: spiral.Lattice, n: number | bigint): bigint;948 /** Returns the ring of a cell: the larger of the coordinates on the square, the hex distance on the hexagon. */949 ring_of(lattice: spiral.Lattice, x: number | bigint, y: number | bigint): bigint;950 /** Returns the cell of a number: x right and y up on the square, axial q and r on the hexagon. */951 xy(lattice: spiral.Lattice, n: number | bigint): [bigint, bigint];952 };953 /** What a cell is painted for. */954 export type Mark = "Prime" | "Twin" | "Squarefree" | "Mobius";955 export const Mark: {956 /** Returns every Mark in canonical order. */957 all(): spiral.Mark[];958 };959 /** The snail: every tile of the winding, the tallies, the area drawn and the box filled. */960 export interface Snail {961 /** The base every tile side is a power of. */962 base: number;963 /** Every tile, in the order one, two, three and on. */964 tiles: spiral.Tile[];965 /** The count of primes at or below the top. */966 primes: number;967 /** The count of tiles at each level, from zero up. */968 levels: number[];969 /** The sum of the tile areas, a tile counted once wherever it overlaps another. */970 area: bigint;971 /** The lower-left corner of the box the tiles fill. */972 low: [number, number];973 /** The upper-right corner of the box the tiles fill. */974 high: [number, number];975 }976 /** One tile of the snail: the number it stands for, its level, the side of its square, whether the number is prime, and the lower-left corner it is laid at. */977 export interface Tile {978 /** The number the tile stands for. */979 n: number;980 /** The level the design is grown to. */981 level: number;982 /** The side of the tile, the base raised to the level. */983 side: number;984 /** Whether the number is prime. */985 prime: boolean;986 /** The x of the lower-left corner. */987 x: number;988 /** The y of the lower-left corner. */989 y: number;990 }991}992export declare namespace zeta {993 /** The smooth window on [1, 2]: exp(4 - 1/((u - 1)(2 - u))) inside, zero outside, every derivative vanishing at the ends and a peak of one at u = 3/2. */994 export function bump(u: number): number;995 /** Returns the first four Riemann-Siegel corrections at the fractional part p: the kernel and its derivatives by central differences with one Richardson step. */996 export function corrections(p: number): Float64Array;997 /** Returns the Riemann-Siegel kernel, the cosine ratio that leads the remainder, in the form that stays finite at its removable points. */998 export function kernel(p: number): number;999 /** Returns the Mellin transform of the bump at a complex s, the integral of bump(u) u^(s - 1) over [1, 2], by a 4096-node midpoint rule. */1000 export function mellin(s: zeta.Complex): zeta.Complex;1001 /** Returns the main term of the smoothed novelty: six over pi squared times the bump's transform at two. */1002 export function novelty_main(): number;1003 /** Sums the waves of the zeros at log y: twice the real part of the coefficients times y to the minus i gamma, the smoothed error over y to the three halves that the zeros predict. */1004 export function novelty_wave(gammas: ArrayLike<number>, coef: zeta.Complex[], log_y: number): number;1005 /** Returns the von Mangoldt explicit formula at x over the zeros at the given ordinates and their mirrors: x less the sum of x to the rho over rho, less ln two pi, less half the ln of one minus x to the minus two. */1006 export function psi_formula(x: number, gammas: ArrayLike<number>): number;1007 /** Returns the Chebyshev staircase at every whole number from one to x: the sum of ln p over the prime powers up to each. */1008 export function psi_stair(x: number): Float64Array;1009 /** Returns a positive real base raised to a complex exponent. */1010 export function raise(base: number, exponent: zeta.Complex): zeta.Complex;1011 /** Returns the sharp novelty error at y: y squared times the totient sum over the scales from 1 over y to 2 over y, both ends in, less nine over pi squared, from the prefix sums of the totients, which must reach 2 over y. */1012 export function sharp_novelty(prefix: ArrayLike<number | bigint>, y: number): number;1013 /** Returns the smoothed novelty error at y: y squared times the totients weighed by the bump at n y, less the main term given; the totients must reach 2 over y. */1014 export function smoothed_novelty(phi: ArrayLike<number | bigint>, y: number, main: number): number;1015 /** The t where the walk hands over from Euler-Maclaurin to Riemann-Siegel. */1016 export function JOIN(): number;1017 export interface ComplexData {1018 /** The real part. */1019 re: number;1020 /** The imaginary part. */1021 im: number;1022 }1023 /** A complex number: a real and an imaginary part. */1024 export class Complex {1025 /** Builds a complex number from its parts. */1026 constructor(re: number, im: number);1027 free(): void;1028 /** Reads the Complex from its plain data. */1029 static from(data: ComplexData): Complex;1030 /** Writes the Complex as plain data. */1031 toJSON(): ComplexData;1032 /** The real part. */1033 get re(): number;1034 set re(value: number);1035 /** The imaginary part. */1036 get im(): number;1037 set im(value: number);1038 /** Returns the modulus. */1039 abs(): number;1040 /** Returns the principal argument. */1041 arg(): number;1042 /** Returns the default Complex. */1043 static default(): zeta.Complex;1044 /** Returns the exponential. */1045 exp(): zeta.Complex;1046 /** Returns the principal logarithm. */1047 ln(): zeta.Complex;1048 /** Returns a unit complex number at the given angle. */1049 static turn(angle: number): zeta.Complex;1050 }1051 export type LineData = Record<string, unknown>;1052 /** The critical line: the Bernoulli numbers and the Euler-Maclaurin weights the two engines share, built once. */1053 export class Line {1054 /** Builds the line: the even Bernoulli numbers through the fourteenth and their Euler-Maclaurin weights. */1055 constructor();1056 free(): void;1057 /** Reads the Line from its plain data. */1058 static from(data: LineData): Line;1059 /** Writes the Line as plain data. */1060 toJSON(): LineData;1061 /** Counts the zeros on the line below t. */1062 count(t: number): number;1063 /** Returns the default Line. */1064 static default(): zeta.Line;1065 /** Returns Z(t) from the Euler-Maclaurin value turned onto the real axis. */1066 exact(t: number): number;1067 /** Returns the n-th Gram point, where theta is n pi, by Newton from the right. */1068 gram(n: number | bigint): number;1069 /** Returns zeta at one half plus i t by the complex Euler-Maclaurin sum: t plus ten terms and seven Bernoulli corrections. */1070 maclaurin(t: number): zeta.Complex;1071 /** Returns the wave coefficient of every zero at the given ordinates: F(rho) zeta(rho - 1) over zeta'(rho) at rho one half plus i gamma, F the Mellin transform of the bump. */1072 novelty_coefficients(gammas: ArrayLike<number>): zeta.Complex[];1073 /** Returns zeta and its derivative together at any complex s but one, by the same Euler-Maclaurin sum: the modulus of t plus ten terms and seven Bernoulli corrections, each term differentiated in s. */1074 pair(s: zeta.Complex): [zeta.Complex, zeta.Complex];1075 /** Returns zeta on the line and Z(t) together, from the engine that serves the t. */1076 point(t: number): [zeta.Complex, number];1077 /** Returns the largest gap between the two engines over the t range on a grid. */1078 seam(t0: number, t1: number, steps: number): number;1079 /** Returns Z(t) by the Riemann-Siegel formula: the main sum and the first four corrections. */1080 siegel(t: number): number;1081 /** Returns the Riemann-Siegel theta: the argument of gamma at one quarter plus i t over two, less t ln pi over two, by Stirling's series after a shift of ten. */1082 theta(t: number): number;1083 /** Returns Z(t): Euler-Maclaurin below the join, Riemann-Siegel above. */1084 z(t: number): number;1085 /** Returns the first zeros on the line: sign changes of Z between Gram points, refined by bisection on Euler-Maclaurin to a billionth. */1086 zeros(count: number): Float64Array;1087 }1088}