The Semirings package provides a means of encoding and decoding into a format called Semi6, inspired by the graph6 format.
Semi6 encodes a semiring S = (A,M) of order n (two n \times n Cayley tables) as one short ASCII string.
The first byte is n + 63, exactly as in graph6. The payload is a bit-stream: first the upper triangle (diagonal included) of the symmetric table A, then the full table M. Each entry is stored in b = \lceil{\log_2 n\rceil} bits, most-significant bit first. Zero-bits are used for padding until the length is a multiple of 6. The stream is then divided into 6-bit blocks, each block has 63 added, and the resulting bytes (ASCII 63–126) are concatenated. Thus a semiring becomes one short, string that is identical in spirit to graph6, but with a variable‐width per-entry field instead of the single edge-bit used for graphs. That is to say, the b=1 case effectively reduces to the graph6 format (with an additional square table).
The order of the semiring must be between 1 and 63, inclusive.
‣ Semi6String( S ) | ( function ) |
Returns: a string
The function Semi6String encodes a semiring S into a string in the Semi6 format.
‣ Semi6Encode( f, srs[, mode] ) | ( function ) |
If srs is a semiring or list of semirings (as pairs of Cayley tables) and f is a string containing the name of a file or an IO file object, Semi6Encode writes the semirings to the file represented by f in the Semi6 format.
The optional argument mode can be either "w" or "a" (default), which determines the mode in which the file is opened for writing.
‣ SemiringFromSemi6String( str ) | ( function ) |
Returns: a list of Cayley tables
This function takes a string str in the Semi6 format representing a semiring and returns that semiring as a pair of Cayley tables.
‣ Semi6Decode( f[, n] ) | ( function ) |
Returns: a list of Cayley tables, or a list of pairs of Cayley tables
If f is a string containing the name of a file containing encoded semirings or an IO file object, then Semi6Decode returns the semirings encoded in the file as a list of pairs of Cayley tables.
If the optional argument n is given, then Semi6Decode returns the nth semiring encoded in the file as a pair of Cayley tables.
generated by GAPDoc2HTML