API Reference

class tmsnets.core.PolynomialNetConstructor[source]

Bases: object

A class implementing algorithms for constructing (t,m,s)-networks using polynomials over finite fields.

Current implementation include Niederreiter algorithm and Rosenbloom-Tsfasman algorithm.

static construct_niederreiter(b, t, m, s, verbose=False)[source]

Constructing (t, m, s)-net via Niederreiter algorithm

Using the galois library, s distinct irreducible polynomials are created over this field, after which the following algorithm is executed to construct each of the generating matrices G[i]:

A polynomial, say pi, with degree deg(pi) = e, is taken. The matrix is divided into (m + e - 1) // e sections by rows, each section containing e rows: the first [0; e), the second [e; 2e), and so on.

Each u-th section corresponds to a linear recurrent sequence a_i(u) of order e*u with the characteristic polynomial pi**u, and the initial elements are defined according to the following rule: • a_i(u) = 0 for i in [0; e*(u-1)). • Among the elements with indices i in [e*(u-1); e*u), at least one element is non-zero.

Next, each number n from 0 to b**m - 1 is converted into its representation vec_b,m(n) as a vector of length m in base b (the digits of the number n in the base-b numeral system). The coordinates of the n-th point are computed as follows: x_n[i] = rnum_b(G[i]*vec_b,m(n)) * b**(-m).

The resulting array of points forms a (t,m,s)-net in base b.

Parameters:
  • b – base of (t, m, s)-net. Using for calculation over GF(b).

  • t – quality measure of (t, m, s)-net.

  • m – the number of points in the (t, m, s)-net is characterized as b^m

  • s – dimension of (t, m, s)-net

static construct_rosenbloom_tsfasman(q, m, s, beta=None)[source]

Constructs a (0, m, s)-network using the Rosenbloom-Tsfasman method.

Due to its combinatorial nature, this method takes a long time to work.

The field GF(q) is created, and the first s elements are taken from it. An exception is raised if s > q.

If beta (a dictionary mapping field elements to real numbers) is specified, a conversion function is created to map field elements to floating-point numbers. By default, beta is None, meaning field elements are used directly.

Next, all possible tuples of coefficients for polynomials of degree up to m - 1 over GF(q) are generated.

Using galois.Poly, the coefficient tuples are converted into polynomials.

For each polynomial, its values and derivatives up to order m - 1 are computed at the first s elements of GF(q).

The coordinates of each point are computed as a weighted sum with weights from q^(-1) to q^(-m).

Parameters:
  • q – base of (0, m, s)-net.

  • m – number of points is q^m.

  • s – dimension of the net.

  • beta – optional mapping from GF(q) elements to float numbers.

Returns:

array of generated points.

static is_prime(n)[source]
static is_prime_power(n)[source]
class tmsnets.core.TMSNet(t, m, s, b, points)[source]

Bases: object

A class for storing, analyzing, and visualizing (t,m,s)-networks.

Parameters:
  • b – base of (t, m, s)-net. Using for calculation over GF(b).

  • t – quality measure of (t, m, s)-net.

  • m – the number of points in the (t, m, s)-net is characterized as b^m

  • s – dimension of (t, m, s)-net

verify() bool[source]

Checks whether a set of points is a (t,m,s)-network.If the check with the initial ‘t’ fails, the function finds the smallest possible value of t for which the points form a valid network and updates self.t.

visualize()[source]

Visualizes network points. Supports both 2D and 3D cases.

tmsnets.core.convert_points_to_fractions(points: ndarray, b: int) ndarray[source]

Converts an array of floating-point coordinates to an array of Fraction objects. This is crucial for exact arithmetic when checking if points fall into b-adic intervals.

Parameters:
  • points – input array (of type numpy.ndarray) of float numbers.

  • b – base of the (t, m, s)-net, necessary for checking whether the input points lie on the boundaries of intervals.

tmsnets.core.generate_D_A_pairs(t: int, m: int, s: int, b: int) Dict[Tuple[int, ...], List[Tuple[int, ...]]][source]

Generates a dictionary that maps each vector D to a list of all possible corresponding vectors A, which define a specific elementary interval for the partition D by specifying the interval index along each dimension. For a given D = (d_1, …, d_s), a vector A = (a_1, …, a_s) satisfies: 0 <= a_j < b^d_j for each j in {1, …, s}.

Parameters:
  • t – quality measure of (t, m, s)-net.

  • m – resolution of the net, controlling the number of points (N = b^m, where b is the base).

  • s – dimension of (t, m, s)-net.

  • b – base of (t, m, s)-net. Using for calculation over GF(b).

tmsnets.core.generate_D_vectors(t: int, m: int, s: int) ndarray[source]

Generates all possible integer vectors D = (d_1, …, d_s) for a (t, m, s)-net. Each vector D defines a partition of the multidimensional cube into elementary intervals for verification and satisfies the following conditions: 1) d_i >= 0 for all i in {1, …, s}, 2) the sum of the coordinates of D satisfies sum(d_i) = m - t for i in {1, …, s}.

Parameters:
  • t – quality measure of (t, m, s)-net.

  • m – resolution of the net, controlling the number of points (N = b^m, where b is the base).

  • s – dimension of (t, m, s)-net.