code
stringlengths
17
6.64M
def BIBD_from_PBD(PBD, v, k, check=True, base_cases=None): '\n Return a `(v,k,1)`-BIBD from a `(r,K)`-PBD where `r=(v-1)/(k-1)`.\n\n This is Theorem 7.20 from [Stinson2004]_.\n\n INPUT:\n\n - ``v,k`` -- integers.\n\n - ``PBD`` -- A PBD on `r=(v-1)/(k-1)` points, such that for any block of\n ``PBD`` of size `s` there must exist a `((k-1)s+1,k,1)`-BIBD.\n\n - ``check`` (boolean) -- whether to check that output is correct before\n returning it. As this is expected to be useless (but we are cautious\n guys), you may want to disable it whenever you want speed. Set to ``True``\n by default.\n\n - ``base_cases`` -- caching system, for internal use.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.bibd import PBD_4_5_8_9_12\n sage: from sage.combinat.designs.bibd import BIBD_from_PBD\n sage: from sage.combinat.designs.bibd import is_pairwise_balanced_design\n sage: PBD = PBD_4_5_8_9_12(17) # needs sage.schemes\n sage: bibd = is_pairwise_balanced_design(BIBD_from_PBD(PBD,52,4),52,[4]) # needs sage.schemes\n ' if (base_cases is None): base_cases = {} r = ((v - 1) // (k - 1)) bibd = [] for X in PBD: n = len(X) N = (((k - 1) * n) + 1) if (not ((n, k) in base_cases)): base_cases[(n, k)] = _relabel_bibd(balanced_incomplete_block_design(N, k), N) for XX in base_cases[(n, k)]: if ((N - 1) in XX): continue bibd.append([(X[(x // (k - 1))] + ((x % (k - 1)) * r)) for x in XX]) for x in range(r): bibd.append(([(x + (i * r)) for i in range((k - 1))] + [(v - 1)])) if check: assert is_pairwise_balanced_design(bibd, v, [k]) return bibd
def _relabel_bibd(B, n, p=None): '\n Relabels the BIBD on `n` points and blocks of size k such that\n `\\{0,...,k-2,n-1\\},\\{k-1,...,2k-3,n-1\\},...,\\{n-k,...,n-2,n-1\\}` are blocks\n of the BIBD.\n\n INPUT:\n\n - ``B`` -- a list of blocks.\n\n - ``n`` (integer) -- number of points.\n\n - ``p`` (optional) -- the point that will be labeled with `n-1`.\n\n EXAMPLES::\n\n sage: designs.balanced_incomplete_block_design(40,4).blocks() # indirect doctest # needs sage.schemes\n [[0, 1, 2, 12], [0, 3, 6, 9], [0, 4, 8, 10],\n [0, 5, 7, 11], [0, 13, 26, 39], [0, 14, 25, 28],\n [0, 15, 27, 38], [0, 16, 22, 32], [0, 17, 23, 34],\n ...\n ' if (p is None): p = (n - 1) found = 0 last = (n - 1) d = {} for X in B: if (last in X): for x in X: if (x == last): continue d[x] = found found += 1 if (found == (n - 1)): break d[p] = (n - 1) return [[d[x] for x in X] for X in B]
def PBD_4_5_8_9_12(v, check=True): '\n Return a `(v,\\{4,5,8,9,12\\})`-PBD on `v` elements.\n\n A `(v,\\{4,5,8,9,12\\})`-PBD exists if and only if `v\\equiv 0,1 \\pmod 4`. The\n construction implemented here appears page 168 in [Stinson2004]_.\n\n INPUT:\n\n - ``v`` -- an integer congruent to `0` or `1` modulo `4`.\n\n - ``check`` (boolean) -- whether to check that output is correct before\n returning it. As this is expected to be useless (but we are cautious\n guys), you may want to disable it whenever you want speed. Set to ``True``\n by default.\n\n EXAMPLES::\n\n sage: designs.balanced_incomplete_block_design(40,4).blocks() # indirect doctest # needs sage.schemes\n [[0, 1, 2, 12], [0, 3, 6, 9], [0, 4, 8, 10],\n [0, 5, 7, 11], [0, 13, 26, 39], [0, 14, 25, 28],\n [0, 15, 27, 38], [0, 16, 22, 32], [0, 17, 23, 34],\n ...\n\n Check that :trac:`16476` is fixed::\n\n sage: from sage.combinat.designs.bibd import PBD_4_5_8_9_12\n sage: for v in (0,1,4,5,8,9,12,13,16,17,20,21,24,25): # needs sage.schemes\n ....: _ = PBD_4_5_8_9_12(v)\n ' if ((v % 4) not in [0, 1]): raise ValueError if (v <= 1): PBD = [] elif (v <= 12): PBD = [list(range(v))] elif ((v == 13) or (v == 28)): PBD = v_4_1_BIBD(v, check=False) elif (v == 29): TD47 = transversal_design(4, 7)._blocks four_more_sets = [([28] + [((i * 7) + j) for j in range(7)]) for i in range(4)] PBD = (TD47 + four_more_sets) elif (v == 41): TD59 = transversal_design(5, 9) PBD = (([[x for x in X if (x < 41)] for X in TD59] + [[((i * 9) + j) for j in range(9)] for i in range(4)]) + [[36, 37, 38, 39, 40]]) elif (v == 44): TD59 = transversal_design(5, 9) PBD = (([[x for x in X if (x < 44)] for X in TD59] + [[((i * 9) + j) for j in range(9)] for i in range(4)]) + [[36, 37, 38, 39, 40, 41, 42, 43]]) elif (v == 45): TD59 = transversal_design(5, 9)._blocks PBD = (TD59 + [[((i * 9) + j) for j in range(9)] for i in range(5)]) elif (v == 48): TD4_12 = transversal_design(4, 12)._blocks PBD = (TD4_12 + [[((i * 12) + j) for j in range(12)] for i in range(4)]) elif (v == 49): TD4_12 = transversal_design(4, 12)._blocks BIBD_13_4 = v_4_1_BIBD(13) for i in range(4): for B in BIBD_13_4: TD4_12.append([(((i * 12) + x) if (x != 12) else 48) for x in B]) PBD = TD4_12 else: (t, u) = _get_t_u(v) TD = transversal_design(5, t) TD = [[x for x in X if (x < ((4 * t) + u))] for X in TD] for B in [list(range((t * i), (t * (i + 1)))) for i in range(4)]: TD.extend(_PBD_4_5_8_9_12_closure([B])) if (u > 1): TD.extend(_PBD_4_5_8_9_12_closure([list(range((4 * t), ((4 * t) + u)))])) PBD = TD if check: assert is_pairwise_balanced_design(PBD, v, [4, 5, 8, 9, 12]) return PBD
def _PBD_4_5_8_9_12_closure(B): '\n Makes sure all blocks of `B` have size in `\\{4,5,8,9,12\\}`.\n\n This is a helper function for :func:`PBD_4_5_8_9_12`. Given that\n `\\{4,5,8,9,12\\}` is PBD-closed, any block of size not in `\\{4,5,8,9,12\\}`\n can be decomposed further.\n\n EXAMPLES::\n\n sage: designs.balanced_incomplete_block_design(40,4).blocks() # indirect doctest # needs sage.schemes\n [[0, 1, 2, 12], [0, 3, 6, 9], [0, 4, 8, 10],\n [0, 5, 7, 11], [0, 13, 26, 39], [0, 14, 25, 28],\n [0, 15, 27, 38], [0, 16, 22, 32], [0, 17, 23, 34],\n ...\n ' BB = [] for X in B: if (len(X) not in [4, 5, 8, 9, 12]): PBD = PBD_4_5_8_9_12(len(X), check=False) X = [[X[i] for i in XX] for XX in PBD] BB.extend(X) else: BB.append(X) return BB
def _get_t_u(v): '\n Return the parameters of table 7.1 from [Stinson2004]_.\n\n INPUT:\n\n - ``v`` (integer)\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.bibd import _get_t_u\n sage: _get_t_u(20)\n (5, 0)\n ' v = int(v) global table_7_1 d = table_7_1[(v % 48)] s = (v // 48) if (s < d['s']): raise RuntimeError('This should not have happened.') t = ((12 * s) + d['t']) u = d['u'] return (t, u)
def v_5_1_BIBD(v, check=True): '\n Return a `(v,5,1)`-BIBD.\n\n This method follows the construction from [ClaytonSmith]_.\n\n INPUT:\n\n - ``v`` (integer)\n\n .. SEEALSO::\n\n * :func:`balanced_incomplete_block_design`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.bibd import v_5_1_BIBD\n sage: i = 0\n sage: while i<200: # needs sage.libs.pari sage.schemes\n ....: i += 20\n ....: _ = v_5_1_BIBD(i+1)\n ....: _ = v_5_1_BIBD(i+5)\n\n TESTS:\n\n Check that the needed difference families are there::\n\n sage: for v in [21,41,61,81,141,161,281]: # needs sage.libs.pari\n ....: assert designs.difference_family(v,5,existence=True)\n ....: _ = designs.difference_family(v,5)\n ' v = int(v) assert (v > 1) assert (((v % 20) == 5) or ((v % 20) == 1)) if (((v % 5) == 0) and (((v // 5) % 4) == 1) and is_prime_power((v // 5))): bibd = BIBD_5q_5_for_q_prime_power((v // 5)) elif (v in [21, 41, 61, 81, 141, 161, 281]): from .difference_family import difference_family (G, D) = difference_family(v, 5) bibd = BIBD_from_difference_family(G, D, check=False) elif (v == 165): bibd = BIBD_from_PBD(v_5_1_BIBD(41, check=False), 165, 5, check=False) elif (v == 181): bibd = BIBD_from_PBD(v_5_1_BIBD(45, check=False), 181, 5, check=False) elif (v in (201, 285, 301, 401, 421, 425)): bibd = BIBD_from_TD(v, 5) elif (((v - 1) // 4) in [80, 81, 85, 86, 90, 91, 95, 96, 110, 111, 115, 116, 120, 121, 250, 251, 255, 256, 260, 261, 265, 266, 270, 271]): r = ((v - 1) // 4) if (r <= 96): (k, t, u) = (5, 16, (r - 80)) elif (r <= 121): (k, t, u) = (10, 11, (r - 110)) else: (k, t, u) = (10, 25, (r - 250)) bibd = BIBD_from_PBD(PBD_from_TD(k, t, u), v, 5, check=False) else: (r, s, t, u) = _get_r_s_t_u(v) bibd = BIBD_from_PBD(PBD_from_TD(5, t, u), v, 5, check=False) if check: assert is_pairwise_balanced_design(bibd, v, [5]) return bibd
def _get_r_s_t_u(v): '\n Implements the table from [ClaytonSmith]_\n\n Return the parameters ``r,s,t,u`` associated with an integer ``v``.\n\n INPUT:\n\n - ``v`` (integer)\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.bibd import _get_r_s_t_u\n sage: _get_r_s_t_u(25)\n (6, 0, 1, 1)\n ' r = int(((v - 1) / 4)) s = (r // 150) x = (r % 150) if (x == 0): (t, u) = (((30 * s) - 5), 25) elif (x == 1): (t, u) = (((30 * s) - 5), 26) elif (x <= 21): (t, u) = (((30 * s) + 1), (x - 5)) elif (x == 25): (t, u) = (((30 * s) + 5), 0) elif (x == 26): (t, u) = (((30 * s) + 5), 1) elif (x == 30): (t, u) = (((30 * s) + 5), 5) elif (x <= 51): (t, u) = (((30 * s) + 5), (x - 25)) elif (x <= 121): (t, u) = (((30 * s) + 11), (x - 55)) elif (x <= 146): (t, u) = (((30 * s) + 25), (x - 125)) return (r, s, t, u)
def PBD_from_TD(k, t, u): '\n Return a `(kt,\\{k,t\\})`-PBD if `u=0` and a `(kt+u,\\{k,k+1,t,u\\})`-PBD otherwise.\n\n This is theorem 23 from [ClaytonSmith]_. The PBD is obtained from the blocks\n a truncated `TD(k+1,t)`, to which are added the blocks corresponding to the\n groups of the TD. When `u=0`, a `TD(k,t)` is used instead.\n\n INPUT:\n\n - ``k,t,u`` -- integers such that `0\\leq u \\leq t`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.bibd import PBD_from_TD\n sage: from sage.combinat.designs.bibd import is_pairwise_balanced_design\n sage: PBD = PBD_from_TD(2,2,1); PBD\n [[0, 2, 4], [0, 3], [1, 2], [1, 3, 4], [0, 1], [2, 3]]\n sage: is_pairwise_balanced_design(PBD,2*2+1,[2,3])\n True\n\n ' from .orthogonal_arrays import transversal_design TD = transversal_design((k + bool(u)), t, check=False) TD = [[x for x in X if (x < ((k * t) + u))] for X in TD] for i in range(k): TD.append(list(range((t * i), ((t * i) + t)))) if (u >= 2): TD.append(list(range((k * t), ((k * t) + u)))) return TD
def BIBD_5q_5_for_q_prime_power(q): '\n Return a `(5q,5,1)`-BIBD with `q\\equiv 1\\pmod 4` a prime power.\n\n See Theorem 24 [ClaytonSmith]_.\n\n INPUT:\n\n - ``q`` (integer) -- a prime power such that `q\\equiv 1\\pmod 4`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.bibd import BIBD_5q_5_for_q_prime_power\n sage: for q in [25, 45, 65, 85, 125, 145, 185, 205, 305, 405, 605]: # long time\n ....: _ = BIBD_5q_5_for_q_prime_power(q/5)\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField if (((q % 4) != 1) or (not is_prime_power(q))): raise ValueError('q is not a prime power or q%4!=1.') d = ((q - 1) // 4) B = [] F = FiniteField(q, 'x') a = F.primitive_element() L = {b: i for (i, b) in enumerate(F)} for b in L: B.append([((i * q) + L[b]) for i in range(5)]) for i in range(5): for j in range(d): B.append([((i * q) + L[b]), ((((i + 1) % 5) * q) + L[((a ** j) + b)]), ((((i + 1) % 5) * q) + L[((- (a ** j)) + b)]), ((((i + 4) % 5) * q) + L[((a ** (j + d)) + b)]), ((((i + 4) % 5) * q) + L[((- (a ** (j + d))) + b)])]) return B
def BIBD_from_arc_in_desarguesian_projective_plane(n, k, existence=False): '\n Return a `(n,k,1)`-BIBD from a maximal arc in a projective plane.\n\n This function implements a construction from Denniston [Denniston69]_, who\n describes a maximal :meth:`arc\n <sage.combinat.designs.bibd.BalancedIncompleteBlockDesign.arc>` in a\n :func:`Desarguesian Projective Plane\n <sage.combinat.designs.block_design.DesarguesianProjectivePlaneDesign>` of\n order `2^k`. From two powers of two `n,q` with `n<q`, it produces a\n `((n-1)(q+1)+1,n,1)`-BIBD.\n\n INPUT:\n\n - ``n,k`` (integers) -- must be powers of two (among other restrictions).\n\n - ``existence`` (boolean) -- whether to return the BIBD obtained through\n this construction (default), or to merely indicate with a boolean return\n value whether this method *can* build the requested BIBD.\n\n EXAMPLES:\n\n A `(232,8,1)`-BIBD::\n\n sage: from sage.combinat.designs.bibd import BIBD_from_arc_in_desarguesian_projective_plane\n sage: from sage.combinat.designs.bibd import BalancedIncompleteBlockDesign\n sage: D = BIBD_from_arc_in_desarguesian_projective_plane(232,8) # needs sage.libs.gap sage.modules sage.rings.finite_rings\n sage: BalancedIncompleteBlockDesign(232,D) # needs sage.libs.gap sage.modules sage.rings.finite_rings\n (232,8,1)-Balanced Incomplete Block Design\n\n A `(120,8,1)`-BIBD::\n\n sage: D = BIBD_from_arc_in_desarguesian_projective_plane(120,8) # needs sage.libs.gap sage.modules sage.rings.finite_rings\n sage: BalancedIncompleteBlockDesign(120,D) # needs sage.libs.gap sage.modules sage.rings.finite_rings\n (120,8,1)-Balanced Incomplete Block Design\n\n Other parameters::\n\n sage: all(BIBD_from_arc_in_desarguesian_projective_plane(n,k,existence=True)\n ....: for n,k in\n ....: [(120, 8), (232, 8), (456, 8), (904, 8), (496, 16),\n ....: (976, 16), (1936, 16), (2016, 32), (4000, 32), (8128, 64)])\n True\n\n Of course, not all can be built this way::\n\n sage: BIBD_from_arc_in_desarguesian_projective_plane(7,3,existence=True)\n False\n sage: BIBD_from_arc_in_desarguesian_projective_plane(7,3)\n Traceback (most recent call last):\n ...\n ValueError: This function cannot produce a (7,3,1)-BIBD\n\n REFERENCE:\n\n .. [Denniston69] \\R. H. F. Denniston,\n Some maximal arcs in finite projective planes.\n Journal of Combinatorial Theory 6, no. 3 (1969): 317-319.\n :doi:`10.1016/S0021-9800(69)80095-5`\n\n ' q = (((n - 1) // (k - 1)) - 1) if ((k % 2) or (q % 2) or (q <= k) or (n != (((k - 1) * (q + 1)) + 1)) or (not is_prime_power(k)) or (not is_prime_power(q))): if existence: return False raise ValueError('This function cannot produce a ({},{},1)-BIBD'.format(n, k)) if existence: return True n = k from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF from sage.libs.gap.libgap import libgap from sage.matrix.constructor import Matrix K = GF(q, 'a') one = K.one() GO = libgap.GeneralOrthogonalGroup((- 1), 2, q) M = libgap.InvariantQuadraticForm(GO)['matrix'] M = Matrix(M) M = M.change_ring(K) Q = (lambda xx, yy: (((M[(0, 0)] * (xx ** 2)) + (((M[(0, 1)] + M[(1, 0)]) * xx) * yy)) + (M[(1, 1)] * (yy ** 2)))) K_iter = list(K) log_n = is_prime_power(n, get_data=True)[1] C = [(x, y, one) for x in K_iter for y in K_iter if (Q(x, y).polynomial().degree() < log_n)] from sage.combinat.designs.block_design import DesarguesianProjectivePlaneDesign return DesarguesianProjectivePlaneDesign(q).trace(C)._blocks
class PairwiseBalancedDesign(GroupDivisibleDesign): "\n Pairwise Balanced Design (PBD)\n\n A Pairwise Balanced Design, or `(v,K,\\lambda)`-PBD, is a collection\n `\\mathcal B` of blocks defined on a set `X` of size `v`, such that any block\n pair of points `p_1,p_2\\in X` occurs in exactly `\\lambda` blocks of\n `\\mathcal B`. Besides, for every block `B\\in \\mathcal B` we must have\n `|B|\\in K`.\n\n INPUT:\n\n - ``points`` -- the underlying set. If ``points`` is an integer `v`, then\n the set is considered to be `\\{0, ..., v-1\\}`.\n\n - ``blocks`` -- collection of blocks\n\n - ``K`` -- list of integers of which the sizes of the blocks must be\n elements. Set to ``None`` (automatic guess) by default.\n\n - ``lambd`` (integer) -- value of `\\lambda`, set to `1` by default.\n\n - ``check`` (boolean) -- whether to check that the design is a `PBD` with\n the right parameters.\n\n - ``copy`` -- (use with caution) if set to ``False`` then ``blocks`` must be\n a list of lists of integers. The list will not be copied but will be\n modified in place (each block is sorted, and the whole list is\n sorted). Your ``blocks`` object will become the instance's internal data.\n\n " def __init__(self, points, blocks, K=None, lambd=1, check=True, copy=True, **kwds): '\n Constructor\n\n EXAMPLES::\n\n sage: designs.balanced_incomplete_block_design(13,3) # indirect doctest\n (13,3,1)-Balanced Incomplete Block Design\n\n ' try: i = int(points) except TypeError: pass else: points = list(range(i)) GroupDivisibleDesign.__init__(self, points, [[x] for x in points], blocks, K=K, lambd=lambd, check=check, copy=copy, **kwds) def __repr__(self): '\n Return a string describing the PBD\n\n EXAMPLES::\n\n sage: designs.balanced_incomplete_block_design(13,3) # indirect doctest\n (13,3,1)-Balanced Incomplete Block Design\n ' bsizes = list(frozenset(self.block_sizes())) return 'Pairwise Balanced Design on {} points with sets of sizes in {}'.format(self.num_points(), bsizes)
class BalancedIncompleteBlockDesign(PairwiseBalancedDesign): "\n Balanced Incomplete Block Design (BIBD)\n\n INPUT:\n\n - ``points`` -- the underlying set. If ``points`` is an integer `v`, then\n the set is considered to be `\\{0, ..., v-1\\}`.\n\n - ``blocks`` -- collection of blocks\n\n - ``k`` (integer) -- size of the blocks. Set to ``None`` (automatic guess)\n by default.\n\n - ``lambd`` (integer) -- value of `\\lambda`, set to `1` by default.\n\n - ``check`` (boolean) -- whether to check that the design is a `PBD` with\n the right parameters.\n\n - ``copy`` -- (use with caution) if set to ``False`` then ``blocks`` must be\n a list of lists of integers. The list will not be copied but will be\n modified in place (each block is sorted, and the whole list is\n sorted). Your ``blocks`` object will become the instance's internal data.\n\n EXAMPLES::\n\n sage: b=designs.balanced_incomplete_block_design(9,3); b\n (9,3,1)-Balanced Incomplete Block Design\n " def __init__(self, points, blocks, k=None, lambd=1, check=True, copy=True, **kwds): '\n Constructor\n\n EXAMPLES::\n\n sage: b=designs.balanced_incomplete_block_design(9,3); b\n (9,3,1)-Balanced Incomplete Block Design\n ' PairwiseBalancedDesign.__init__(self, points, blocks, K=([k] if (k is not None) else None), lambd=lambd, check=check, copy=copy, **kwds) def __repr__(self): '\n A string to describe self\n\n EXAMPLES::\n\n sage: b=designs.balanced_incomplete_block_design(9,3); b\n (9,3,1)-Balanced Incomplete Block Design\n ' v = self.num_points() k = (len(self._blocks[0]) if self._blocks else 0) l = self._lambd return '({},{},{})-Balanced Incomplete Block Design'.format(v, k, l) def arc(self, s=2, solver=None, verbose=0, *, integrality_tolerance=0.001): '\n Return the ``s``-arc with maximum cardinality.\n\n A `s`-arc is a subset of points in a BIBD that intersects each block on\n at most `s` points. It is one possible generalization of independent set\n for graphs.\n\n A simple counting shows that the cardinality of a `s`-arc is at most\n `(s-1) * r + 1` where `r` is the number of blocks incident to any point.\n A `s`-arc in a BIBD with cardinality `(s-1) * r + 1` is called maximal\n and is characterized by the following property: it is not empty and each\n block either contains `0` or `s` points of this arc. Equivalently, the\n trace of the BIBD on these points is again a BIBD (with block size `s`).\n\n For more informations, see :wikipedia:`Arc_(projective_geometry)`.\n\n INPUT:\n\n - ``s`` - (default to ``2``) the maximum number of points from the arc\n in each block\n\n - ``solver`` -- (default: ``None``) Specify a Mixed Integer Linear\n Programming (MILP) solver to be used. If set to ``None``, the default\n one is used. For more information on MILP solvers and which default\n solver is used, see the method :meth:`solve\n <sage.numerical.mip.MixedIntegerLinearProgram.solve>` of the class\n :class:`MixedIntegerLinearProgram\n <sage.numerical.mip.MixedIntegerLinearProgram>`.\n\n - ``verbose`` -- integer (default: ``0``). Sets the level of\n verbosity. Set to 0 by default, which means quiet.\n\n - ``integrality_tolerance`` -- parameter for use with MILP solvers over\n an inexact base ring; see\n :meth:`MixedIntegerLinearProgram.get_values`.\n\n EXAMPLES::\n\n sage: # needs sage.schemes\n sage: B = designs.balanced_incomplete_block_design(21, 5)\n sage: a2 = B.arc(); a2 # random\n [5, 9, 10, 12, 15, 20]\n sage: len(a2)\n 6\n sage: a4 = B.arc(4); a4 # random\n [0, 1, 2, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20]\n sage: len(a4)\n 16\n\n The `2`-arc and `4`-arc above are maximal. One can check that they\n intersect the blocks in either 0 or `s` points. Or equivalently that the\n traces are again BIBD::\n\n sage: r = (21-1)//(5-1)\n sage: 1 + r*1\n 6\n sage: 1 + r*3\n 16\n\n sage: B.trace(a2).is_t_design(2, return_parameters=True) # needs sage.schemes\n (True, (2, 6, 2, 1))\n sage: B.trace(a4).is_t_design(2, return_parameters=True) # needs sage.schemes\n (True, (2, 16, 4, 1))\n\n Some other examples which are not maximal::\n\n sage: # needs sage.numerical.mip\n sage: B = designs.balanced_incomplete_block_design(25, 4)\n sage: a2 = B.arc(2)\n sage: r = (25-1)//(4-1)\n sage: len(a2), 1 + r\n (8, 9)\n sage: sa2 = set(a2)\n sage: set(len(sa2.intersection(b)) for b in B.blocks())\n {0, 1, 2}\n sage: B.trace(a2).is_t_design(2)\n False\n\n sage: # needs sage.numerical.mip\n sage: a3 = B.arc(3)\n sage: len(a3), 1 + 2*r\n (15, 17)\n sage: sa3 = set(a3)\n sage: set(len(sa3.intersection(b)) for b in B.blocks()) == set([0,3])\n False\n sage: B.trace(a3).is_t_design(3)\n False\n\n TESTS:\n\n Test consistency with relabeling::\n\n sage: b = designs.balanced_incomplete_block_design(7,3) # needs sage.schemes\n sage: b.relabel(list("abcdefg")) # needs sage.schemes\n sage: set(b.arc()).issubset(b.ground_set()) # needs sage.schemes\n True\n ' s = int(s) if (s <= 0): return [] elif (s >= max(self.block_sizes())): return self._points[:] from sage.numerical.mip import MixedIntegerLinearProgram p = MixedIntegerLinearProgram(solver=solver) b = p.new_variable(binary=True) p.set_objective(p.sum((b[i] for i in range(len(self._points))))) for i in self._blocks: p.add_constraint((p.sum((b[k] for k in i)) <= s)) p.solve(log=verbose) values = p.get_values(b, convert=bool, tolerance=integrality_tolerance) return [self._points[i] for (i, j) in values.items() if j]
def tdesign_params(t, v, k, L): "\n Return the design's parameters: `(t, v, b, r , k, L)`. Note that `t` must be\n given.\n\n EXAMPLES::\n\n sage: BD = BlockDesign(7, [[0,1,2],[0,3,4],[0,5,6],[1,3,5],[1,4,6],[2,3,6],[2,4,5]])\n sage: from sage.combinat.designs.block_design import tdesign_params\n sage: tdesign_params(2,7,3,1)\n (2, 7, 7, 3, 3, 1)\n " x = binomial(v, t) y = binomial(k, t) b = divmod((L * x), y)[0] x = binomial((v - 1), (t - 1)) y = binomial((k - 1), (t - 1)) r = integer_floor(((L * x) / y)) return (t, v, b, r, k, L)
def are_hyperplanes_in_projective_geometry_parameters(v, k, lmbda, return_parameters=False): '\n Return ``True`` if the parameters ``(v,k,lmbda)`` are the one of hyperplanes in\n a (finite Desarguesian) projective space.\n\n In other words, test whether there exists a prime power ``q`` and an integer\n ``d`` greater than two such that:\n\n - `v = (q^{d+1}-1)/(q-1) = q^d + q^{d-1} + ... + 1`\n - `k = (q^d - 1)/(q-1) = q^{d-1} + q^{d-2} + ... + 1`\n - `lmbda = (q^{d-1}-1)/(q-1) = q^{d-2} + q^{d-3} + ... + 1`\n\n If it exists, such a pair ``(q,d)`` is unique.\n\n INPUT:\n\n - ``v,k,lmbda`` (integers)\n\n OUTPUT:\n\n - a boolean or, if ``return_parameters`` is set to ``True`` a pair\n ``(True, (q,d))`` or ``(False, (None,None))``.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.block_design import are_hyperplanes_in_projective_geometry_parameters\n sage: are_hyperplanes_in_projective_geometry_parameters(40, 13, 4)\n True\n sage: are_hyperplanes_in_projective_geometry_parameters(40, 13, 4,\n ....: return_parameters=True)\n (True, (3, 3))\n sage: PG = designs.ProjectiveGeometryDesign(3, 2, GF(3)) # needs sage.combinat\n sage: PG.is_t_design(return_parameters=True) # needs sage.combinat\n (True, (2, 40, 13, 4))\n\n sage: are_hyperplanes_in_projective_geometry_parameters(15, 3, 1)\n False\n sage: are_hyperplanes_in_projective_geometry_parameters(15, 3, 1,\n ....: return_parameters=True)\n (False, (None, None))\n\n TESTS::\n\n sage: sgp = lambda q,d: ((q**(d+1)-1)//(q-1), (q**d-1)//(q-1), (q**(d-1)-1)//(q-1))\n sage: for q in [3,4,5,7,8,9,11]:\n ....: for d in [2,3,4,5]:\n ....: v,k,l = sgp(q,d)\n ....: assert are_hyperplanes_in_projective_geometry_parameters(v,k,l,True) == (True, (q,d))\n ....: assert are_hyperplanes_in_projective_geometry_parameters(v+1,k,l) is False\n ....: assert are_hyperplanes_in_projective_geometry_parameters(v-1,k,l) is False\n ....: assert are_hyperplanes_in_projective_geometry_parameters(v,k+1,l) is False\n ....: assert are_hyperplanes_in_projective_geometry_parameters(v,k-1,l) is False\n ....: assert are_hyperplanes_in_projective_geometry_parameters(v,k,l+1) is False\n ....: assert are_hyperplanes_in_projective_geometry_parameters(v,k,l-1) is False\n ' import sage.arith.all as arith q1 = Integer((v - k)) q2 = Integer((k - lmbda)) if ((lmbda <= 0) or (q1 < 4) or (q2 < 2) or (not q1.is_prime_power()) or (not q2.is_prime_power())): return ((False, (None, None)) if return_parameters else False) (p1, e1) = q1.factor()[0] (p2, e2) = q2.factor()[0] k = arith.gcd(e1, e2) d = (e1 // k) q = (p1 ** k) if (((e2 // k) != (d - 1)) or (lmbda != (((q ** (d - 1)) - 1) // (q - 1)))): return ((False, (None, None)) if return_parameters else False) return ((True, (q, d)) if return_parameters else True)
def ProjectiveGeometryDesign(n, d, F, algorithm=None, point_coordinates=True, check=True): '\n Return a projective geometry design.\n\n The projective geometry design `PG_d(n,q)` has for points the lines of\n `\\GF{q}^{n+1}`, and for blocks the `(d+1)`-dimensional subspaces of\n `\\GF{q}^{n+1}`, each of which contains `\\frac {|\\GF{q}|^{d+1}-1} {|\\GF{q}|-1}` lines.\n It is a `2`-design with parameters\n\n .. MATH::\n\n v = \\binom{n+1}{1}_q,\\ k = \\binom{d+1}{1}_q,\\ \\lambda =\n \\binom{n-1}{d-1}_q\n\n where the `q`-binomial coefficient `\\binom{m}{r}_q` is defined by\n\n .. MATH::\n\n \\binom{m}{r}_q = \\frac{(q^m - 1)(q^{m-1} - 1) \\cdots (q^{m-r+1}-1)}\n {(q^r-1)(q^{r-1}-1)\\cdots (q-1)}\n\n .. SEEALSO::\n\n :func:`AffineGeometryDesign`\n\n INPUT:\n\n - ``n`` -- the projective dimension\n\n - ``d`` -- the dimension of the subspaces which make up the blocks.\n\n - ``F`` -- a finite field or a prime power.\n\n - ``algorithm`` -- set to ``None`` by default, which results in using Sage\'s\n own implementation. In order to use GAP\'s implementation instead (i.e. its\n ``PGPointFlatBlockDesign`` function) set ``algorithm="gap"``. Note that\n GAP\'s "design" package must be available in this case, and that it can be\n installed with the ``gap_packages`` spkg.\n\n - ``point_coordinates`` -- ``True`` by default. Ignored and assumed to be ``False`` if\n ``algorithm="gap"``. If ``True``, the ground set is indexed by coordinates\n in `\\GF{q}^{n+1}`. Otherwise the ground set is indexed by integers.\n\n - ``check`` -- (optional, default to ``True``) whether to check the output.\n\n EXAMPLES:\n\n The set of `d`-dimensional subspaces in a `n`-dimensional projective space\n forms `2`-designs (or balanced incomplete block designs)::\n\n sage: PG = designs.ProjectiveGeometryDesign(4, 2, GF(2)); PG # needs sage.combinat\n Incidence structure with 31 points and 155 blocks\n sage: PG.is_t_design(return_parameters=True) # needs sage.combinat\n (True, (2, 31, 7, 7))\n\n sage: PG = designs.ProjectiveGeometryDesign(3, 1, GF(4)) # needs sage.combinat\n sage: PG.is_t_design(return_parameters=True) # needs sage.combinat\n (True, (2, 85, 5, 1))\n\n Check with ``F`` being a prime power::\n\n sage: PG = designs.ProjectiveGeometryDesign(3, 2, 4); PG\n Incidence structure with 85 points and 85 blocks\n\n Use coordinates::\n\n sage: PG = designs.ProjectiveGeometryDesign(2, 1, GF(3))\n sage: PG.blocks()[0]\n [(1, 0, 0), (1, 0, 1), (1, 0, 2), (0, 0, 1)]\n\n Use indexing by integers::\n\n sage: PG = designs.ProjectiveGeometryDesign(2, 1, GF(3), point_coordinates=0)\n sage: PG.blocks()[0]\n [0, 1, 2, 12]\n\n Check that the constructor using gap also works::\n\n sage: BD = designs.ProjectiveGeometryDesign(2, 1, GF(2), algorithm="gap") # optional - gap_package_design\n sage: BD.is_t_design(return_parameters=True) # optional - gap_package_design\n (True, (2, 7, 3, 1))\n ' try: q = int(F) except TypeError: q = F.cardinality() else: from sage.rings.finite_rings.finite_field_constructor import GF F = GF(q) if (algorithm is None): from sage.matrix.echelon_matrix import reduced_echelon_matrix_iterator points = {p: i for (i, p) in enumerate(reduced_echelon_matrix_iterator(F, 1, (n + 1), copy=True, set_immutable=True))} blocks = [] for m1 in reduced_echelon_matrix_iterator(F, (d + 1), (n + 1), copy=False): b = [] for m2 in reduced_echelon_matrix_iterator(F, 1, (d + 1), copy=False): m = (m2 * m1) m.echelonize() m.set_immutable() b.append(points[m]) blocks.append(b) B = BlockDesign(len(points), blocks, name='ProjectiveGeometryDesign', check=check) if point_coordinates: B.relabel({i: p[0] for (p, i) in points.items()}) elif (algorithm == 'gap'): libgap.load_package('design') D = libgap.PGPointFlatBlockDesign(n, F.order(), d) v = D['v'].sage() gblcks = D['blocks'].sage() gB = [] for b in gblcks: gB.append([(x - 1) for x in b]) B = BlockDesign(v, gB, name='ProjectiveGeometryDesign', check=check) if check: from sage.combinat.q_analogues import q_binomial q = F.cardinality() if (not B.is_t_design(t=2, v=q_binomial((n + 1), 1, q), k=q_binomial((d + 1), 1, q), l=q_binomial((n - 1), (d - 1), q))): raise RuntimeError('error in ProjectiveGeometryDesign construction. Please e-mail sage-devel@googlegroups.com') return B
def DesarguesianProjectivePlaneDesign(n, point_coordinates=True, check=True): '\n Return the Desarguesian projective plane of order ``n`` as a 2-design.\n\n The Desarguesian projective plane of order `n` can also be defined as the\n projective plane over a field of order `n`. For more information, have a\n look at :wikipedia:`Projective_plane`.\n\n INPUT:\n\n - ``n`` -- an integer which must be a power of a prime number\n\n - ``point_coordinates`` -- (boolean) whether to label the points with their\n homogeneous coordinates (default) or with integers.\n\n - ``check`` -- (boolean) Whether to check that output is correct before\n returning it. As this is expected to be useless (but we are cautious\n guys), you may want to disable it whenever you want speed. Set to\n ``True`` by default.\n\n .. SEEALSO::\n\n :func:`ProjectiveGeometryDesign`\n\n EXAMPLES::\n\n sage: designs.DesarguesianProjectivePlaneDesign(2)\n (7,3,1)-Balanced Incomplete Block Design\n sage: designs.DesarguesianProjectivePlaneDesign(3)\n (13,4,1)-Balanced Incomplete Block Design\n sage: designs.DesarguesianProjectivePlaneDesign(4)\n (21,5,1)-Balanced Incomplete Block Design\n sage: designs.DesarguesianProjectivePlaneDesign(5)\n (31,6,1)-Balanced Incomplete Block Design\n sage: designs.DesarguesianProjectivePlaneDesign(6)\n Traceback (most recent call last):\n ...\n ValueError: the order of a finite field must be a prime power\n\n ' K = FiniteField(n, 'a') n2 = (n ** 2) relabel = {x: i for (i, x) in enumerate(K)} Kiter = relabel affine_plane = (lambda x, y: (relabel[x] + (n * relabel[y]))) line_infinity = (lambda x: (n2 + relabel[x])) point_infinity = (n2 + n) blcks = [] for s in Kiter: for a in Kiter: blcks.append([affine_plane(((s * y) + a), y) for y in Kiter]) blcks[(- 1)].append(line_infinity(s)) for a in Kiter: blcks.append([affine_plane(x, a) for x in Kiter]) blcks[(- 1)].append(point_infinity) blcks.append(range(n2, ((n2 + n) + 1))) if check: from .designs_pyx import is_projective_plane if (not is_projective_plane(blcks)): raise RuntimeError('There is a problem in the function DesarguesianProjectivePlane') from .bibd import BalancedIncompleteBlockDesign B = BalancedIncompleteBlockDesign(((n2 + n) + 1), blcks, check=check) if point_coordinates: zero = K.zero() one = K.one() d = {affine_plane(x, y): (x, y, one) for x in Kiter for y in Kiter} d.update({line_infinity(x): (x, one, zero) for x in Kiter}) d[(n2 + n)] = (one, zero, zero) B.relabel(d) return B
def q3_minus_one_matrix(K): "\n Return a companion matrix in `GL(3, K)` whose multiplicative order is `q^3 - 1`.\n\n This function is used in :func:`HughesPlane`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.block_design import q3_minus_one_matrix\n sage: m = q3_minus_one_matrix(GF(3))\n sage: m.multiplicative_order() == 3**3 - 1\n True\n\n sage: m = q3_minus_one_matrix(GF(4, 'a'))\n sage: m.multiplicative_order() == 4**3 - 1\n True\n\n sage: m = q3_minus_one_matrix(GF(5))\n sage: m.multiplicative_order() == 5**3 - 1\n True\n\n sage: m = q3_minus_one_matrix(GF(9, 'a'))\n sage: m.multiplicative_order() == 9**3 - 1\n True\n " q = K.cardinality() M = MatrixSpace(K, 3) if q.is_prime(): from sage.rings.finite_rings.conway_polynomials import conway_polynomial try: (a, b, c, _) = conway_polynomial(q, 3) except RuntimeError: pass else: return M([0, 0, (- a), 1, 0, (- b), 0, 1, (- c)]) m = M() m[(1, 0)] = m[(2, 1)] = K.one() while True: m[(0, 2)] = K._random_nonzero_element() m[(1, 2)] = K.random_element() m[(2, 2)] = K.random_element() if (m.multiplicative_order() == ((q ** 3) - 1)): return m
def normalize_hughes_plane_point(p, q): "\n Return the normalized form of point ``p`` as a 3-tuple.\n\n In the Hughes projective plane over the finite field `K`, all triples `(xk,\n yk, zk)` with `k \\in K` represent the same point (where the multiplication\n is over the nearfield built from `K`). This function chooses a canonical\n representative among them.\n\n This function is used in :func:`HughesPlane`.\n\n INPUT:\n\n - ``p`` -- point with the coordinates `(x,y,z)` (a list, a vector, a tuple...)\n\n - ``q`` -- cardinality of the underlying finite field\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.block_design import normalize_hughes_plane_point\n sage: K = FiniteField(9,'x')\n sage: x = K.gen()\n sage: normalize_hughes_plane_point((x, x + 1, x), 9)\n (1, x, 1)\n sage: normalize_hughes_plane_point(vector((x,x,x)), 9)\n (1, 1, 1)\n sage: zero = K.zero()\n sage: normalize_hughes_plane_point((2*x + 2, zero, zero), 9)\n (1, 0, 0)\n sage: one = K.one()\n sage: normalize_hughes_plane_point((2*x, one, zero), 9)\n (2*x, 1, 0)\n " for i in [2, 1, 0]: if p[i].is_one(): return tuple(p) elif (not p[i].is_zero()): k = (~ p[i]) if k.is_square(): return ((p[0] * k), (p[1] * k), (p[2] * k)) else: return (((p[0] * k) ** q), ((p[1] * k) ** q), ((p[2] * k) ** q))
def HughesPlane(q2, check=True): '\n Return the Hughes projective plane of order ``q2``.\n\n Let `q` be an odd prime, the Hughes plane of order `q^2` is a finite\n projective plane of order `q^2` introduced by D. Hughes in [Hu57]_. Its\n construction is as follows.\n\n Let `K = GF(q^2)` be a finite field with `q^2` elements and `F = GF(q)\n \\subset K` be its unique subfield with `q` elements. We define a twisted\n multiplication on `K` as\n\n .. MATH::\n\n x \\circ y =\n \\begin{cases}\n x\\ y & \\text{if y is a square in K}\\\\\n x^q\\ y & \\text{otherwise}\n \\end{cases}\n\n The points of the Hughes plane are the triples `(x, y, z)` of points in `K^3\n \\backslash \\{0,0,0\\}` up to the equivalence relation `(x,y,z) \\sim (x \\circ\n k, y \\circ k, z \\circ k)` where `k \\in K`.\n\n For `a = 1` or `a \\in (K \\backslash F)` we define a block `L(a)` as the set of\n triples `(x,y,z)` so that `x + a \\circ y + z = 0`. The rest of the blocks\n are obtained by letting act the group `GL(3, F)` by its standard action.\n\n For more information, see :wikipedia:`Hughes_plane` and [We07].\n\n .. SEEALSO::\n\n :func:`DesarguesianProjectivePlaneDesign` to build the Desarguesian\n projective planes\n\n INPUT:\n\n - ``q2`` -- an even power of an odd prime number\n\n - ``check`` -- (boolean) Whether to check that output is correct before\n returning it. As this is expected to be useless (but we are cautious\n guys), you may want to disable it whenever you want speed. Set to\n ``True`` by default.\n\n EXAMPLES::\n\n sage: H = designs.HughesPlane(9); H\n (91,10,1)-Balanced Incomplete Block Design\n\n We prove in the following computations that the Desarguesian plane ``H`` is\n not Desarguesian. Let us consider the two triangles `(0,1,10)` and `(57, 70,\n 59)`. We show that the intersection points `D_{0,1} \\cap D_{57,70}`,\n `D_{1,10} \\cap D_{70,59}` and `D_{10,0} \\cap D_{59,57}` are on the same line\n while `D_{0,70}`, `D_{1,59}` and `D_{10,57}` are not concurrent::\n\n sage: blocks = H.blocks()\n sage: line = lambda p,q: next(b for b in blocks if p in b and q in b)\n\n sage: b_0_1 = line(0, 1)\n sage: b_1_10 = line(1, 10)\n sage: b_10_0 = line(10, 0)\n sage: b_57_70 = line(57, 70)\n sage: b_70_59 = line(70, 59)\n sage: b_59_57 = line(59, 57)\n\n sage: set(b_0_1).intersection(b_57_70)\n {2}\n sage: set(b_1_10).intersection(b_70_59)\n {73}\n sage: set(b_10_0).intersection(b_59_57)\n {60}\n\n sage: line(2, 73) == line(73, 60)\n True\n\n sage: b_0_57 = line(0, 57)\n sage: b_1_70 = line(1, 70)\n sage: b_10_59 = line(10, 59)\n\n sage: p = set(b_0_57).intersection(b_1_70)\n sage: q = set(b_1_70).intersection(b_10_59)\n sage: p == q\n False\n\n TESTS:\n\n Some wrong input::\n\n sage: designs.HughesPlane(5)\n Traceback (most recent call last):\n ...\n EmptySetError: No Hughes plane of non-square order exists.\n\n sage: designs.HughesPlane(16)\n Traceback (most recent call last):\n ...\n EmptySetError: No Hughes plane of even order exists.\n\n Check that it works for non-prime `q`::\n\n sage: designs.HughesPlane(3**4) # not tested - 10 secs\n (6643,82,1)-Balanced Incomplete Block Design\n ' if (not q2.is_square()): raise EmptySetError('No Hughes plane of non-square order exists.') if ((q2 % 2) == 0): raise EmptySetError('No Hughes plane of even order exists.') q = q2.sqrt() K = FiniteField(q2, prefix='x') F = FiniteField(q, prefix='y') A = q3_minus_one_matrix(F) A = A.change_ring(K) m = K.list() V = VectorSpace(K, 3) zero = K.zero() one = K.one() points = (([(x, y, one) for x in m for y in m] + [(x, one, zero) for x in m]) + [(one, zero, zero)]) relabel = {tuple(p): i for (i, p) in enumerate(points)} blcks = [] for a in m: if ((a not in F) or (a == 1)): aa = (~ a) l = [] l.append(V(((- a), one, zero))) for x in m: y = ((- aa) * (x + one)) if (not y.is_square()): y *= (aa ** (q - 1)) l.append(V((x, y, one))) blcks.append([relabel[normalize_hughes_plane_point(p, q)] for p in l]) for i in range((q2 + q)): l = [(A * j) for j in l] blcks.append([relabel[normalize_hughes_plane_point(p, q)] for p in l]) from .bibd import BalancedIncompleteBlockDesign return BalancedIncompleteBlockDesign((((q2 ** 2) + q2) + 1), blcks, check=check)
def projective_plane_to_OA(pplane, pt=None, check=True): '\n Return the orthogonal array built from the projective plane ``pplane``.\n\n The orthogonal array `OA(n+1,n,2)` is obtained from the projective plane\n ``pplane`` by removing the point ``pt`` and the `n+1` lines that pass\n through it`. These `n+1` lines form the `n+1` groups while the remaining\n `n^2+n` lines form the transversals.\n\n INPUT:\n\n - ``pplane`` -- a projective plane as a 2-design\n\n - ``pt`` -- a point in the projective plane ``pplane``. If it is not provided,\n then it is set to `n^2 + n`.\n\n - ``check`` -- (boolean) Whether to check that output is correct before\n returning it. As this is expected to be useless (but we are cautious\n guys), you may want to disable it whenever you want speed. Set to\n ``True`` by default.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.block_design import projective_plane_to_OA\n sage: p2 = designs.DesarguesianProjectivePlaneDesign(2, point_coordinates=False)\n sage: projective_plane_to_OA(p2)\n [[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0]]\n sage: p3 = designs.DesarguesianProjectivePlaneDesign(3, point_coordinates=False)\n sage: projective_plane_to_OA(p3)\n [[0, 0, 0, 0],\n [0, 1, 2, 1],\n [0, 2, 1, 2],\n [1, 0, 2, 2],\n [1, 1, 1, 0],\n [1, 2, 0, 1],\n [2, 0, 1, 1],\n [2, 1, 0, 2],\n [2, 2, 2, 0]]\n\n sage: pp = designs.DesarguesianProjectivePlaneDesign(16, point_coordinates=False)\n sage: _ = projective_plane_to_OA(pp, pt=0)\n sage: _ = projective_plane_to_OA(pp, pt=3)\n sage: _ = projective_plane_to_OA(pp, pt=7)\n ' from .bibd import _relabel_bibd pplane = pplane.blocks() n = (len(pplane[0]) - 1) if (pt is None): pt = ((n ** 2) + n) assert (len(pplane) == (((n ** 2) + n) + 1)), 'pplane is not a projective plane' assert all(((len(B) == (n + 1)) for B in pplane)), 'pplane is not a projective plane' pplane = _relabel_bibd(pplane, (((n ** 2) + n) + 1), p=((n ** 2) + n)) OA = [[(x % n) for x in sorted(X)] for X in pplane if (((n ** 2) + n) not in X)] assert (len(OA) == (n ** 2)), 'pplane is not a projective plane' if check: from .designs_pyx import is_orthogonal_array is_orthogonal_array(OA, (n + 1), n, 2) return OA
def projective_plane(n, check=True, existence=False): '\n Return a projective plane of order ``n`` as a 2-design.\n\n A finite projective plane is a 2-design with `n^2+n+1` lines (or blocks) and\n `n^2+n+1` points. For more information on finite projective planes, see the\n :wikipedia:`Projective_plane#Finite_projective_planes`.\n\n If no construction is possible, then the function raises a :class:`EmptySetError`,\n whereas if no construction is available, the function raises a\n :class:`NotImplementedError`.\n\n INPUT:\n\n - ``n`` -- the finite projective plane\'s order\n\n EXAMPLES::\n\n sage: # needs sage.schemes\n sage: designs.projective_plane(2)\n (7,3,1)-Balanced Incomplete Block Design\n sage: designs.projective_plane(3)\n (13,4,1)-Balanced Incomplete Block Design\n sage: designs.projective_plane(4)\n (21,5,1)-Balanced Incomplete Block Design\n sage: designs.projective_plane(5)\n (31,6,1)-Balanced Incomplete Block Design\n sage: designs.projective_plane(6)\n Traceback (most recent call last):\n ...\n EmptySetError: By the Bruck-Ryser theorem, no projective plane of order 6 exists.\n sage: designs.projective_plane(10)\n Traceback (most recent call last):\n ...\n EmptySetError: No projective plane of order 10 exists by\n C. Lam, L. Thiel and S. Swiercz "The nonexistence of finite\n projective planes of order 10" (1989), Canad. J. Math.\n sage: designs.projective_plane(12)\n Traceback (most recent call last):\n ...\n NotImplementedError: If such a projective plane exists,\n we do not know how to build it.\n sage: designs.projective_plane(14)\n Traceback (most recent call last):\n ...\n EmptySetError: By the Bruck-Ryser theorem, no projective plane of order 14 exists.\n\n TESTS::\n\n sage: # needs sage.schemes\n sage: designs.projective_plane(2197, existence=True)\n True\n sage: designs.projective_plane(6, existence=True)\n False\n sage: designs.projective_plane(10, existence=True)\n False\n sage: designs.projective_plane(12, existence=True)\n Unknown\n ' from sage.combinat.designs.bibd import BruckRyserChowla_check if (n <= 1): if existence: return False raise EmptySetError('There is no projective plane of order <= 1') if (n == 10): if existence: return False ref = 'C. Lam, L. Thiel and S. Swiercz "The nonexistence of finite projective planes of order 10" (1989), Canad. J. Math.' raise EmptySetError(('No projective plane of order 10 exists by %s' % ref)) if (BruckRyserChowla_check((((n * n) + n) + 1), (n + 1), 1) is False): if existence: return False raise EmptySetError('By the Bruck-Ryser theorem, no projective plane of order {} exists.'.format(n)) if (not is_prime_power(n)): if existence: return Unknown raise NotImplementedError('If such a projective plane exists, we do not know how to build it.') if existence: return True else: return DesarguesianProjectivePlaneDesign(n, point_coordinates=False, check=check)
def AffineGeometryDesign(n, d, F, point_coordinates=True, check=True): '\n Return an affine geometry design.\n\n The affine geometry design `AG_d(n,q)` is the 2-design whose blocks are the\n `d`-vector subspaces in `\\GF{q}^n`. It has parameters\n\n .. MATH::\n\n v = q^n,\\ k = q^d,\\ \\lambda = \\binom{n-1}{d-1}_q\n\n where the `q`-binomial coefficient `\\binom{m}{r}_q` is defined by\n\n .. MATH::\n\n \\binom{m}{r}_q = \\frac{(q^m - 1)(q^{m-1} - 1) \\cdots (q^{m-r+1}-1)}\n {(q^r-1)(q^{r-1}-1)\\cdots (q-1)}\n\n .. SEEALSO::\n\n :func:`ProjectiveGeometryDesign`\n\n INPUT:\n\n - ``n`` (integer) -- the Euclidean dimension. The number of points of the\n design is `v=|\\GF{q}^n|`.\n\n - ``d`` (integer) -- the dimension of the (affine) subspaces of `\\GF{q}^n`\n which make up the blocks.\n\n - ``F`` -- a finite field or a prime power.\n\n - ``point_coordinates`` -- (optional, default ``True``) whether we use\n coordinates in `\\GF{q}^n` or plain integers for the points of the design.\n\n - ``check`` -- (optional, default ``True``) whether to check the output.\n\n EXAMPLES::\n\n sage: # needs sage.combinat\n sage: BD = designs.AffineGeometryDesign(3, 1, GF(2))\n sage: BD.is_t_design(return_parameters=True)\n (True, (2, 8, 2, 1))\n sage: BD = designs.AffineGeometryDesign(3, 2, GF(4))\n sage: BD.is_t_design(return_parameters=True)\n (True, (2, 64, 16, 5))\n sage: BD = designs.AffineGeometryDesign(4, 2, GF(3))\n sage: BD.is_t_design(return_parameters=True)\n (True, (2, 81, 9, 13))\n\n With ``F`` an integer instead of a finite field::\n\n sage: BD = designs.AffineGeometryDesign(3, 2, 4)\n sage: BD.is_t_design(return_parameters=True)\n (True, (2, 64, 16, 5))\n\n Testing the option ``point_coordinates``::\n\n sage: designs.AffineGeometryDesign(3, 1, GF(2),\n ....: point_coordinates=True).blocks()[0]\n [(0, 0, 0), (0, 0, 1)]\n sage: designs.AffineGeometryDesign(3, 1, GF(2),\n ....: point_coordinates=False).blocks()[0]\n [0, 1]\n ' try: q = int(F) except TypeError: q = F.cardinality() else: from sage.rings.finite_rings.finite_field_constructor import GF F = GF(q) n = int(n) d = int(d) from itertools import islice from sage.combinat.q_analogues import q_binomial from sage.matrix.echelon_matrix import reduced_echelon_matrix_iterator points = {p: i for (i, p) in enumerate(reduced_echelon_matrix_iterator(F, 1, (n + 1), copy=True, set_immutable=True)) if p[(0, 0)]} blocks = [] l1 = int((q_binomial((n + 1), (d + 1), q) - q_binomial(n, (d + 1), q))) l2 = (q ** d) for m1 in islice(reduced_echelon_matrix_iterator(F, (d + 1), (n + 1), copy=False), int(l1)): b = [] for m2 in islice(reduced_echelon_matrix_iterator(F, 1, (d + 1), copy=False), int(l2)): m = (m2 * m1) m.echelonize() m.set_immutable() b.append(points[m]) blocks.append(b) B = BlockDesign(len(points), blocks, name='AffineGeometryDesign', check=check) if point_coordinates: rd = {i: p[0][1:] for (p, i) in points.items()} for v in rd.values(): v.set_immutable() B.relabel(rd) if check: if (not B.is_t_design(t=2, v=(q ** n), k=(q ** d), l=q_binomial((n - 1), (d - 1), q))): raise RuntimeError('error in AffineGeometryDesign construction. Please e-mail sage-devel@googlegroups.com') return B
def CremonaRichmondConfiguration(): '\n Return the Cremona-Richmond configuration.\n\n The Cremona-Richmond configuration is a set system whose incidence graph\n is equal to the\n :meth:`~sage.graphs.graph_generators.GraphGenerators.TutteCoxeterGraph`. It\n is a generalized quadrangle of parameters `(2,2)`.\n\n For more information, see the\n :wikipedia:`Cremona-Richmond_configuration`.\n\n EXAMPLES::\n\n sage: H = designs.CremonaRichmondConfiguration(); H # needs networkx\n Incidence structure with 15 points and 15 blocks\n sage: g = graphs.TutteCoxeterGraph() # needs networkx\n sage: H.incidence_graph().is_isomorphic(g) # needs networkx\n True\n ' from sage.graphs.generators.smallgraphs import TutteCoxeterGraph from sage.combinat.designs.incidence_structures import IncidenceStructure g = TutteCoxeterGraph() H = IncidenceStructure([g.neighbors(v) for v in g.bipartite_sets()[0]]) H.relabel() return H
def WittDesign(n): "\n INPUT:\n\n - ``n`` is in `9,10,11,12,21,22,23,24`.\n\n Wraps GAP Design's WittDesign. If ``n=24`` then this function returns the\n large Witt design `W_{24}`, the unique (up to isomorphism) `5-(24,8,1)`\n design. If ``n=12`` then this function returns the small Witt design\n `W_{12}`, the unique (up to isomorphism) `5-(12,6,1)` design. The other\n values of `n` return a block design derived from these.\n\n .. NOTE::\n\n Requires GAP's Design package (included in the gap_packages Sage spkg).\n\n EXAMPLES::\n\n sage: # optional - gap_package_design\n sage: BD = designs.WittDesign(9)\n sage: BD.is_t_design(return_parameters=True)\n (True, (2, 9, 3, 1))\n sage: BD\n Incidence structure with 9 points and 12 blocks\n sage: print(BD)\n Incidence structure with 9 points and 12 blocks\n " libgap.load_package('design') B = libgap.WittDesign(n) v = B['v'].sage() gB = [[(x - 1) for x in b] for b in B['blocks'].sage()] return BlockDesign(v, gB, name='WittDesign', check=True)
def HadamardDesign(n): '\n As described in Section 1, p. 10, in [CvL]_. The input n must have the\n property that there is a Hadamard matrix of order `n+1` (and that a\n construction of that Hadamard matrix has been implemented...).\n\n EXAMPLES::\n\n sage: # needs sage.combinat sage.modules\n sage: designs.HadamardDesign(7)\n Incidence structure with 7 points and 7 blocks\n sage: print(designs.HadamardDesign(7))\n Incidence structure with 7 points and 7 blocks\n\n For example, the Hadamard 2-design with `n = 11` is a design whose parameters are `2-(11, 5, 2)`.\n We verify that `NJ = 5J` for this design. ::\n\n sage: # needs sage.combinat sage.modules\n sage: D = designs.HadamardDesign(11); N = D.incidence_matrix()\n sage: J = matrix(ZZ, 11, 11, [1]*11*11); N*J\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n [5 5 5 5 5 5 5 5 5 5 5]\n\n REFERENCES:\n\n - [CvL] P. Cameron, J. H. van Lint, Designs, graphs, codes and\n their links, London Math. Soc., 1991.\n ' from sage.combinat.matrices.hadamard_matrix import hadamard_matrix from sage.matrix.constructor import matrix H = hadamard_matrix((n + 1)) H1 = H.matrix_from_columns(range(1, (n + 1))) H2 = H1.matrix_from_rows(range(1, (n + 1))) J = matrix(ZZ, n, n, (([1] * n) * n)) MS = J.parent() A = MS(((H2 + J) / 2)) return IncidenceStructure(incidence_matrix=A, name='HadamardDesign')
def Hadamard3Design(n): '\n Return the Hadamard 3-design with parameters `3-(n, \\frac n 2, \\frac n 4 - 1)`.\n\n This is the unique extension of the Hadamard `2`-design (see\n :meth:`HadamardDesign`). We implement the description from pp. 12 in\n [CvL]_.\n\n INPUT:\n\n - ``n`` (integer) -- a multiple of 4 such that `n>4`.\n\n EXAMPLES::\n\n sage: # needs sage.combinat sage.modules\n sage: designs.Hadamard3Design(12)\n Incidence structure with 12 points and 22 blocks\n\n We verify that any two blocks of the Hadamard `3`-design `3-(8, 4, 1)`\n design meet in `0` or `2` points. More generally, it is true that any two\n blocks of a Hadamard `3`-design meet in `0` or `\\frac{n}{4}` points (for `n\n > 4`).\n\n ::\n\n sage: # needs sage.combinat sage.modules\n sage: D = designs.Hadamard3Design(8)\n sage: N = D.incidence_matrix()\n sage: N.transpose()*N\n [4 2 2 2 2 2 2 2 2 2 2 2 2 0]\n [2 4 2 2 2 2 2 2 2 2 2 2 0 2]\n [2 2 4 2 2 2 2 2 2 2 2 0 2 2]\n [2 2 2 4 2 2 2 2 2 2 0 2 2 2]\n [2 2 2 2 4 2 2 2 2 0 2 2 2 2]\n [2 2 2 2 2 4 2 2 0 2 2 2 2 2]\n [2 2 2 2 2 2 4 0 2 2 2 2 2 2]\n [2 2 2 2 2 2 0 4 2 2 2 2 2 2]\n [2 2 2 2 2 0 2 2 4 2 2 2 2 2]\n [2 2 2 2 0 2 2 2 2 4 2 2 2 2]\n [2 2 2 0 2 2 2 2 2 2 4 2 2 2]\n [2 2 0 2 2 2 2 2 2 2 2 4 2 2]\n [2 0 2 2 2 2 2 2 2 2 2 2 4 2]\n [0 2 2 2 2 2 2 2 2 2 2 2 2 4]\n\n\n REFERENCES:\n\n .. [CvL] \\P. Cameron, J. H. van Lint, Designs, graphs, codes and\n their links, London Math. Soc., 1991.\n ' if ((n == 1) or (n == 4)): raise ValueError(('The Hadamard design with n = %s does not extend to a three design.' % n)) from sage.combinat.matrices.hadamard_matrix import hadamard_matrix from sage.matrix.constructor import matrix, block_matrix H = hadamard_matrix(n) H1 = H.matrix_from_columns(range(1, n)) J = matrix(ZZ, n, (n - 1), (([1] * (n - 1)) * n)) A1 = ((H1 + J) / 2) A2 = ((J - H1) / 2) A = block_matrix(1, 2, [A1, A2]) return IncidenceStructure(incidence_matrix=A, name='HadamardThreeDesign')
def schonheim(v, k, t): "\n Return the Schonheim lower bound for the size of such a covering design.\n\n INPUT:\n\n - ``v`` -- integer, size of point set\n\n - ``k`` -- integer, cardinality of each block\n\n - ``t`` -- integer, cardinality of sets being covered\n\n OUTPUT:\n\n The Schonheim lower bound for such a covering design's size:\n `C(v, k, t) \\leq \\lceil(\\frac{v}{k} \\lceil \\frac{v-1}{k-1} \\cdots\n \\lceil \\frac{v-t+1}{k-t+1} \\rceil \\cdots \\rceil \\rceil`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import schonheim\n sage: schonheim(10, 3, 2)\n 17\n sage: schonheim(32, 16, 8)\n 930\n " bound = 1 for i in range((t - 1), (- 1), (- 1)): bound = Rational(((bound * (v - i)), (k - i))).ceil() return bound
def trivial_covering_design(v, k, t): "\n Construct a trivial covering design.\n\n INPUT:\n\n - ``v`` -- integer, size of point set\n\n - ``k`` -- integer, cardinality of each block\n\n - ``t`` -- integer, cardinality of sets being covered\n\n OUTPUT:\n\n A trivial `(v, k, t)` covering design\n\n EXAMPLES::\n\n sage: C = trivial_covering_design(8, 3, 1)\n sage: print(C)\n C(8, 3, 1) = 3\n Method: Trivial\n 0 1 2\n 0 6 7\n 3 4 5\n sage: C = trivial_covering_design(5, 3, 2)\n sage: print(C)\n 4 <= C(5, 3, 2) <= 10\n Method: Trivial\n 0 1 2\n 0 1 3\n 0 1 4\n 0 2 3\n 0 2 4\n 0 3 4\n 1 2 3\n 1 2 4\n 1 3 4\n 2 3 4\n\n .. NOTE::\n\n Cases are:\n\n * `t=0`: This could be empty, but it's a useful convention to have\n one block (which is empty if `k=0`).\n\n * `t=1` : This contains `\\lceil v/k \\rceil` blocks:\n `[0, ..., k-1], [k, ..., 2k-1], ...`. The last block wraps around if\n `k` does not divide `v`.\n\n * anything else: Just use every `k`-subset of `[0, 1,..., v-1]`.\n\n " if (t == 0): blk = [] for i in range(k): blk.append(i) return CoveringDesign(v, k, t, 1, range(v), [blk], 1, 'Trivial') if (t == 1): size = Rational((v, k)).ceil() blocks = [] for i in range((size - 1)): blk = [] for j in range((i * k), ((i + 1) * k)): blk.append(j) blocks.append(blk) blk = [] for j in range(((size - 1) * k), v): blk.append(j) for j in range((k - len(blk))): blk.append(j) blk.sort() blocks.append(blk) return CoveringDesign(v, k, t, size, range(v), blocks, size, 'Trivial') return CoveringDesign(v, k, t, binomial(v, k), range(v), Combinations(range(v), k), schonheim(v, k, t), 'Trivial')
class CoveringDesign(SageObject): '\n Covering design.\n\n INPUT:\n\n - ``v``, ``k``, ``t`` -- integer parameters of the covering design\n\n - ``size`` (integer)\n\n - ``points`` -- list of points (default points are `[0, ..., v-1]`)\n\n - ``blocks``\n\n - ``low_bd`` (integer) -- lower bound for such a design\n\n - ``method``, ``creator``, ``timestamp`` -- database information\n ' def __init__(self, v=0, k=0, t=0, size=0, points=None, blocks=None, low_bd=0, method='', creator='', timestamp=''): "\n EXAMPLES::\n\n sage: C = CoveringDesign(5, 4, 3, 4, range(5), [[0, 1, 2, 3],\n ....: [0, 1, 2, 4], [0, 1, 3, 4], [0, 2, 3, 4]], 4,\n ....: 'Lexicographic Covering')\n sage: print(C)\n C(5, 4, 3) = 4\n Method: Lexicographic Covering\n 0 1 2 3\n 0 1 2 4\n 0 1 3 4\n 0 2 3 4\n " self.__v = v self.__k = k self.__t = t self.__size = size if (low_bd > 0): self.__low_bd = low_bd else: self.__low_bd = schonheim(v, k, t) self.__method = method self.__creator = creator self.__timestamp = timestamp if (points is None): points = [] if (blocks is None): blocks = [] self.__incidence_structure = IncidenceStructure(points, blocks) def __repr__(self): "\n Return the representation of this covering design.\n\n This has the parameters but not the blocks.\n\n EXAMPLES::\n\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C\n (7, 3, 2)-covering design of size 7\n Lower bound: 7\n Method: Projective Plane\n " repr = ('(%d, %d, %d)-covering design of size %d\n' % (self.__v, self.__k, self.__t, self.__size)) repr += ('Lower bound: %d\n' % self.__low_bd) if self.__creator: repr += ('Created by: %s\n' % self.__creator) if self.__method: repr += ('Method: %s\n' % self.__method) if self.__timestamp: repr += ('Submitted on: %s\n' % self.__timestamp) return repr[:(- 1)] def __str__(self): "\n Return the string for this covering design.\n\n This has the parameters and the blocks in readable form.\n\n EXAMPLES::\n\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: print(C)\n C(7, 3, 2) = 7\n Method: Projective Plane\n 0 1 2\n 0 3 4\n 0 5 6\n 1 3 5\n 1 4 6\n 2 3 6\n 2 4 5\n " if (self.__size == self.__low_bd): repr = ('C(%d, %d, %d) = %d\n' % (self.__v, self.__k, self.__t, self.__size)) else: repr = ('%d <= C(%d, %d, %d) <= %d\n' % (self.__low_bd, self.__v, self.__k, self.__t, self.__size)) if self.__creator: repr += ('Created by: %s\n' % self.__creator) if self.__method: repr += ('Method: %s\n' % self.__method) if self.__timestamp: repr += ('Submitted on: %s\n' % self.__timestamp) return (repr + '\n'.join((' '.join((str(k) for k in block)) for block in self.__incidence_structure.blocks()))) def is_covering(self): "\n Check all `t`-sets are in fact covered by the blocks of ``self``.\n\n .. NOTE::\n\n This is very slow and wasteful of memory.\n\n EXAMPLES::\n\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C.is_covering()\n True\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6], [2, 3, 6],\n ....: [2, 4, 6]], 0, 'not a covering') # last block altered\n sage: C.is_covering()\n False\n " v = self.__v k = self.__k t = self.__t Svt = Combinations(range(v), t) Skt = Combinations(range(k), t) tset = {} for i in Svt: tset[tuple(i)] = False for a in self.__incidence_structure.blocks(): for z in Skt: y = (a[x] for x in z) tset[tuple(y)] = True for i in Svt: if (not tset[tuple(i)]): return False return True def v(self): "\n Return `v`, the number of points in the covering design.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C.v()\n 7\n " return self.__v def k(self): "\n Return `k`, the size of blocks of the covering design\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C.k()\n 3\n " return self.__k def t(self): "\n Return `t`, the size of sets which must be covered by the\n blocks of the covering design\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C.t()\n 2\n " return self.__t def size(self): "\n Return the number of blocks in the covering design\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C.size()\n 7\n " return self.__size def low_bd(self): "\n Return a lower bound for the number of blocks a covering\n design with these parameters could have.\n\n Typically this is the Schonheim bound, but for some parameters\n better bounds have been shown.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C.low_bd()\n 7\n " return self.__low_bd def method(self): "\n Return the method used to create the covering design.\n\n This field is optional, and is used in a database to give information\n about how coverings were constructed.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: C.method()\n 'Projective Plane'\n " return self.__method def creator(self): "\n Return the creator of the covering design\n\n This field is optional, and is used in a database to give\n attribution for the covering design It can refer to the person\n who submitted it, or who originally gave a construction\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6], [2, 3, 6],\n ....: [2, 4, 5]],0, 'Projective Plane', 'Gino Fano')\n sage: C.creator()\n 'Gino Fano'\n " return self.__creator def timestamp(self): "\n Return the time that the covering was submitted to the database\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]],0, 'Projective Plane',\n ....: 'Gino Fano', '1892-01-01 00:00:00')\n sage: C.timestamp() # No exact date known; in Fano's 1892 article\n '1892-01-01 00:00:00'\n " return self.__timestamp def incidence_structure(self): "\n Return the incidence structure of this design, without extra parameters.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import CoveringDesign\n sage: C = CoveringDesign(7, 3, 2, 7, range(7), [[0, 1, 2],\n ....: [0, 3, 4], [0, 5, 6], [1, 3, 5], [1, 4, 6],\n ....: [2, 3, 6], [2, 4, 5]], 0, 'Projective Plane')\n sage: D = C.incidence_structure()\n sage: D.ground_set()\n [0, 1, 2, 3, 4, 5, 6]\n sage: D.blocks()\n [[0, 1, 2], [0, 3, 4], [0, 5, 6], [1, 3, 5],\n [1, 4, 6], [2, 3, 6], [2, 4, 5]]\n\n " return self.__incidence_structure
def best_known_covering_design_www(v, k, t, verbose=False): '\n Return the best known `(v, k, t)` covering design from an online database.\n\n This uses the La Jolla Covering Repository, a database\n available at `<https://ljcr.dmgordon.org/cover.html>`_\n\n INPUT:\n\n - ``v`` -- integer, the size of the point set for the design\n\n - ``k`` -- integer, the number of points per block\n\n - ``t`` -- integer, the size of sets covered by the blocks\n\n - ``verbose`` -- bool (default: ``False``), print verbose message\n\n OUTPUT:\n\n A :class:`CoveringDesign` object representing the ``(v, k, t)``-covering\n design with smallest number of blocks available in the database.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.covering_design import ( # optional - internet\n ....: best_known_covering_design_www)\n sage: C = best_known_covering_design_www(7, 3, 2) # optional - internet\n sage: print(C) # optional - internet\n C(7, 3, 2) = 7\n Method: lex covering\n Submitted on: 1996-12-01 00:00:00\n 0 1 2\n 0 3 4\n 0 5 6\n 1 3 5\n 1 4 6\n 2 3 6\n 2 4 5\n\n A :class:`ValueError` is raised if the ``(v, k, t)`` parameters are not\n found in the database.\n ' v = int(v) k = int(k) t = int(t) param = ('?v=%s&k=%s&t=%s' % (v, k, t)) url = ('https://ljcr.dmgordon.org/cover/get_cover.php' + param) if verbose: print(('Looking up the bounds at %s' % url)) f = urlopen(url, context=default_context()) try: s = bytes_to_str(f.read()) finally: f.close() if ('covering not in database' in s): str = ('no (%d, %d, %d) covering design in database\n' % (v, k, t)) raise ValueError(str) return sage_eval(s)
def _MOLS_from_string(s, k): '\n Return MOLS from a string\n\n INPUT:\n\n - ``s`` (string) -- represents the MOLS with entries in a-z. To understand\n how the string should be formatted, read the source code of a constructor\n that uses it.\n\n - ``k`` (integer) -- the number of MOLS encoded by the string.\n\n EXAMPLES::\n\n sage: _ = designs.mutually_orthogonal_latin_squares(2,10) # indirect doctest # needs sage.modules\n ' from sage.matrix.constructor import Matrix matrices = [[] for _ in range(k)] for (i, l) in enumerate(s.split()): l = [(ord(x) - 97) for x in l] matrices[(i % k)].append(l) return [Matrix(_) for _ in matrices]
def MOLS_10_2(): '\n Return a pair of MOLS of order 10\n\n Data obtained from\n `<http://www.cecm.sfu.ca/organics/papers/lam/paper/html/POLS10/POLS10.html>`_\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.latin_squares import are_mutually_orthogonal_latin_squares\n sage: from sage.combinat.designs.database import MOLS_10_2\n sage: MOLS = MOLS_10_2() # needs sage.modules\n sage: print(are_mutually_orthogonal_latin_squares(MOLS)) # needs sage.modules\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(2,10)\n True\n ' from sage.matrix.constructor import Matrix return [Matrix([[1, 8, 9, 0, 2, 4, 6, 3, 5, 7], [7, 2, 8, 9, 0, 3, 5, 4, 6, 1], [6, 1, 3, 8, 9, 0, 4, 5, 7, 2], [5, 7, 2, 4, 8, 9, 0, 6, 1, 3], [0, 6, 1, 3, 5, 8, 9, 7, 2, 4], [9, 0, 7, 2, 4, 6, 8, 1, 3, 5], [8, 9, 0, 1, 3, 5, 7, 2, 4, 6], [2, 3, 4, 5, 6, 7, 1, 8, 9, 0], [3, 4, 5, 6, 7, 1, 2, 0, 8, 9], [4, 5, 6, 7, 1, 2, 3, 9, 0, 8]]), Matrix([[1, 7, 6, 5, 0, 9, 8, 2, 3, 4], [8, 2, 1, 7, 6, 0, 9, 3, 4, 5], [9, 8, 3, 2, 1, 7, 0, 4, 5, 6], [0, 9, 8, 4, 3, 2, 1, 5, 6, 7], [2, 0, 9, 8, 5, 4, 3, 6, 7, 1], [4, 3, 0, 9, 8, 6, 5, 7, 1, 2], [6, 5, 4, 0, 9, 8, 7, 1, 2, 3], [3, 4, 5, 6, 7, 1, 2, 8, 0, 9], [5, 6, 7, 1, 2, 3, 4, 0, 9, 8], [7, 1, 2, 3, 4, 5, 6, 9, 8, 0]])]
def MOLS_12_5(): '\n Return 5 MOLS of order 12\n\n These MOLS have been found by Brendan McKay.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.latin_squares import are_mutually_orthogonal_latin_squares\n sage: from sage.combinat.designs.database import MOLS_12_5\n sage: MOLS = MOLS_12_5() # needs sage.modules\n sage: print(are_mutually_orthogonal_latin_squares(MOLS)) # needs sage.modules\n True\n ' M = '\n abcdefghijkl abcdefghijkl abcdefghijkl abcdefghijkl abcdefghijkl\n badcfehgjilk ghefklijcdab dcbahgfelkji jilkbadcfehg klijcdabghef\n cdabghefklij efghijklabcd lkjidcbahgfe ijklabcdefgh fehgjilkbadc\n dcbahgfelkji cdabghefklij ghefklijcdab badcfehgjilk hgfelkjidcba\n ijklabcdefgh klijcdabghef efghijklabcd fehgjilkbadc jilkbadcfehg\n jilkbadcfehg fehgjilkbadc hgfelkjidcba dcbahgfelkji lkjidcbahgfe\n klijcdabghef hgfelkjidcba jilkbadcfehg cdabghefklij dcbahgfelkji\n lkjidcbahgfe ijklabcdefgh badcfehgjilk efghijklabcd ghefklijcdab\n efghijklabcd jilkbadcfehg fehgjilkbadc lkjidcbahgfe cdabghefklij\n fehgjilkbadc dcbahgfelkji cdabghefklij ghefklijcdab badcfehgjilk\n ghefklijcdab badcfehgjilk klijcdabghef hgfelkjidcba ijklabcdefgh\n hgfelkjidcba lkjidcbahgfe ijklabcdefgh klijcdabghef efghijklabcd\n ' return _MOLS_from_string(M, 5)
def MOLS_14_4(): '\n Return four MOLS of order 14\n\n These MOLS were shared by Ian Wanless. The first proof of existence was\n given in [Todorov12]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.latin_squares import are_mutually_orthogonal_latin_squares\n sage: from sage.combinat.designs.database import MOLS_14_4\n sage: MOLS = MOLS_14_4() # needs sage.modules\n sage: print(are_mutually_orthogonal_latin_squares(MOLS)) # needs sage.modules\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(4,14) # needs sage.schemes\n True\n\n REFERENCE:\n\n .. [Todorov12] \\D.T. Todorov,\n Four mutually orthogonal Latin squares of order 14,\n Journal of Combinatorial Designs 2012, vol.20 n.8 pp.363-367\n ' M = '\n bjihgkecalnfmd bfmcenidgjhalk bcdefghijklmna bcdefghijklmna\n fckjbhledimagn jcgndfalehkbim gnkjdmiclbhaef jflhnkaecmgdib\n mgdlkcbafejnih ikdhaegnmfblcj lifhbjemkangcd emkdjbgfnliahc\n cnhemldbigfkaj hjlebifkangcmd dalmgnbjehcfik anighmflkbdcej\n edabfnmkcjhgli gbkmfcjeliahdn njcaeifhbdgkml kebcajimdgfhln\n nfeicgajldkbhm khclngdafmjibe mfbkcdlagnjihe cgnflembihakjd\n iagfjdhnkmelcb elbdmahfignkjc aemnhkjdcifblg ilabkdnhfcjegm\n dlnkeafimhcjbg ceabkjnihdmgfl hdnikbagmcelfj ljgnihecbamfdk\n gemalfihjnbdkc adficlkmjbenhg cgjflhnbiekdam ndmabcjglfeikh\n jhfnimgdbkacel liegjdmhnkcfab fkibmagenldhjc mbhiefljadkncg\n hkbgajnmeclidf nmjfhkecbaldgi imhlneckdfajgb difjcnkamehgbl\n ablchikgnfdmje fankgbljdcimeh klegafdnhjmcbi ghckmlbdeinjaf\n licmdbjfhagenk mgialhcbkedjnf jhadicmlfgbekn fajlgidkhncbme\n kmjdneclgbihfa dnhjimbgclfeka ebgcjlkfamindh hkemdacngjblfi\n ' return _MOLS_from_string(M, 4)
def MOLS_15_4(): '\n Return 4 MOLS of order 15.\n\n These MOLS were shared by Ian Wanless.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.latin_squares import are_mutually_orthogonal_latin_squares\n sage: from sage.combinat.designs.database import MOLS_15_4\n sage: MOLS = MOLS_15_4() # needs sage.modules\n sage: print(are_mutually_orthogonal_latin_squares(MOLS)) # needs sage.modules\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(4,15) # needs sage.schemes\n True\n ' M = '\n bcdefghijklmnoa bdgiknfcamehjlo bhealiofmdjgcnk blhcmdinejofakg\n abcdefghijklmno acehjlogdbnfikm lcifbmjagnekhdo hcmidnejofkagbl\n oabcdefghijklmn nbdfikmahecogjl amdjgcnkbhoflie midnjeofkaglbhc\n noabcdefghijklm mocegjlnbifdahk fbnekhdolciagmj dnjeokfaglbhmci\n mnoabcdefghijkl lnadfhkmocjgebi kgcoflieamdjbhn jeokfalgbhmcind\n lmnoabcdefghijk jmobegilnadkhfc olhdagmjfbnekci ekfalgbmhcindjo\n klmnoabcdefghij dknacfhjmobelig jamiebhnkgcofld aflgbmhcnidjoek\n jklmnoabcdefghi helobdgiknacfmj ekbnjfciolhdagm lbgmhcnidojekaf\n ijklmnoabcdefgh kifmacehjlobdgn nflcokgdjamiebh gmchnidojeakflb\n hijklmnoabcdefg oljgnbdfikmaceh iogmdalhekbnjfc chndiojeakfblgm\n ghijklmnoabcdef iamkhocegjlnbdf djahnebmiflcokg ndioejakfblgcmh\n fghijklmnoabcde gjbnliadfhkmoce hekbiofcnjgmdal ioejafkblgcmhdn\n efghijklmnoabcd fhkcomjbegilnad miflcjagdokhneb ojafkbglcmhdnie\n defghijklmnoabc egildankcfhjmob cnjgmdkbhealiof fakbglchmdnieoj\n cdefghijklmnoab cfhjmeboldgikna gdokhnelcifbmja kgblchmdineojfa\n ' return _MOLS_from_string(M, 4)
def MOLS_18_3(): '\n Return 3 MOLS of order 18.\n\n These MOLS were shared by Ian Wanless.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.latin_squares import are_mutually_orthogonal_latin_squares\n sage: from sage.combinat.designs.database import MOLS_18_3\n sage: MOLS = MOLS_18_3() # needs sage.modules\n sage: print(are_mutually_orthogonal_latin_squares(MOLS)) # needs sage.modules\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(3,18)\n True\n ' M = '\n bgejhkmodcnarilpfq beqpodgcflkrjahnim bcdefghijklmnopqra\n echfbilnprdokajmqg gcfrqpehdnmlabkioj rbkamfgdehqjinopcl\n qfdigcjmohaeplkbnr ehdgarqfibonmkcljp mlbqhifgajdcrenopk\n prgejhdbnaikfqmlco jfiehkargqcponldmb hijbcdefgqraklmnop\n oqahfbiecpkjlgrnmd hbgjfilkacrdqpomen gderbkamfpclhqjino\n dprkigcjfeqlbmhaon kichbgjmlodaerqpnf fgamlbqhiopkjdcren\n geqaljhdbofrmcnikp mljdichbngpekfarqo efghijbcdnopqraklm\n chfrkmbieqpgandojl onmbejdicphqflgkar amfgderbkinopclhqj\n fdigalncjmrqhkoepb dponcfbejaqirgmhlk qhifgamlbrenopkjdc\n lnbqcogpakmhdrifej crhapeoqmkbgidnjfl leqjponacbkidfgmhr\n kmocrdphqblnieajgf ndaikqfprmlchjeobg kjmcrponhlbqeafgid\n rlnpdaeqigcmojfkbh aoekjlrgqhnmdibfpc dqriklponajbcmhfge\n jamoqekfrihdnpbglc rkpflbmahdionejcgq nacleqjpomhrbkidfg\n abknprflgdjieoqchm ialqgmcnkrejpofbdh onhkjmcrpgidlbqeaf\n hkcloqagmnebjfprdi ljkmrhndoiafbqpgce pondqriklfgeajbcmh\n nildmprkhjofcbgqae pmblnaioefjkgcrqhd jponacleqdfgmhrbki\n iojmenqalfbpgdchrk fqncmokjpegblhdari crponhkjmeafgidlbq\n mjpbnforklgcqhedia qgrodnplbjfhcmieka iklpondqrcmhfgeajb\n ' return _MOLS_from_string(M, 3)
def OA_7_18(): '\n Return an OA(7,18)\n\n Proved in [JulianAbel13]_.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_quasi_difference_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_7_18\n sage: OA = OA_7_18()\n sage: is_orthogonal_array(OA,7,18,2)\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(7,18) # needs sage.schemes\n True\n ' M = '\n 000 100 100 000 100 100 100 000 000 000 100 000\n 000 020 100 100 000 120 110 110 010 020 010 120\n 000 100 022 102 112 001 101 120 121 001 020 002\n 000 002 100 002 102 122 010 111 110 121 021 001\n 000 021 000 100 020 112 100 021 112 102 102 012\n 000 000 011 010 100 010 110 122 011 121 120 111\n 000 100 002 022 011 121 020 122 100 010 112 112\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic from sage.categories.cartesian_product import cartesian_product G = cartesian_product([AdditiveCyclic(2), AdditiveCyclic(3), AdditiveCyclic(3)]) M = [G([int(_) for _ in xx]) for xx in M.split()] M = [M[(i * 12):((i + 1) * 12)] for i in range(7)] Mb = [] for (a, b, c, d, e, f, g) in zip(*M): for y in range(3): Mb.append([(a + G((0, 0, 0))), (b + G((0, 0, y))), (c + G((0, y, 0))), (d + G((0, (2 * y), y))), (e + G((0, (2 * y), (2 * y)))), (f + G((0, y, (2 * y)))), (g + G((0, 0, (2 * y))))]) M = OA_from_quasi_difference_matrix(Mb, G, add_col=False) M = [M[i] for i in range(len(M)) if ((i % 18) < 9)] return M
def OA_9_40(): '\n Return an OA(9,40)\n\n As explained in the Handbook III.3.62 [DesignHandbook]_. Uses the fact that\n `40 = 2^3 \\times 5` and that `5` is prime.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_9_40\n sage: OA = OA_9_40() # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,9,40,2) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(9,40) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None)], [(0, None), (1, None), (2, 2), (3, 2), (4, 2), (2, None), (3, None), (4, None), (0, 2), (1, 2)], [(0, None), (2, 5), (4, 5), (1, 2), (3, 6), (3, 4), (0, 0), (2, 1), (4, 1), (1, 6)], [(0, None), (3, 4), (1, 4), (4, 0), (2, 5), (3, None), (1, 0), (4, 1), (2, 2), (0, 3)], [(0, None), (4, 6), (3, None), (2, 3), (1, 4), (2, 1), (1, None), (0, 4), (4, 0), (3, 2)], [(0, None), (1, 2), (4, 6), (4, 4), (1, 0), (0, 6), (2, 3), (3, 6), (3, 5), (2, 5)], [(1, None), (0, 3), (1, 2), (4, 5), (4, None), (2, 3), (0, 0), (2, 2), (3, 0), (3, None)], [(4, None), (1, 3), (0, 0), (1, 1), (4, 0), (3, 1), (2, 5), (0, None), (2, 1), (3, None)]] Y = [None, 0, 1, 6, 5, 4, 3, 2] return OA_n_times_2_pow_c_from_matrix(9, 3, FiniteField(5), A, Y, check=False)
def OA_7_66(): '\n Return an OA(7,66)\n\n Construction shared by Julian R. Abel.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_PBD`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.orthogonal_arrays import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_7_66\n sage: OA = OA_7_66() # needs sage.schemes\n sage: is_orthogonal_array(OA,7,66,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(7,66) # needs sage.schemes\n True\n ' B = [0, 19, 26, 14, 63, 15, 32, 35, 65] BIBD = [[((x + i) % 73) for x in B] for i in range(73)] oval = [((- x) % 73) for x in B][:7] PBD = [[x for x in B if (x not in oval)] for B in BIBD] V = [x for x in range(73) if (x not in oval)] rel = dict(zip(V, range(len(V)))) PBD = [[rel[x] for x in B] for B in PBD] return OA_from_PBD(7, 66, PBD, check=False)
def OA_7_68(): '\n Return an OA(7,68)\n\n Construction shared by Julian R. Abel.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_PBD`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.orthogonal_arrays import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_7_68\n sage: OA = OA_7_68() # needs sage.schemes\n sage: is_orthogonal_array(OA,7,68,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(7,68) # needs sage.schemes\n True\n ' B = [0, 19, 26, 14, 63, 15, 32, 35, 65] BIBD = [[((x + i) % 73) for x in B] for i in range(73)] oval = [((- x) % 73) for x in B][:5] PBD = [[x for x in B if (x not in oval)] for B in BIBD] V = [x for x in range(73) if (x not in oval)] rel = dict(zip(V, range(len(V)))) PBD = [[rel[x] for x in B] for B in PBD] return OA_from_PBD(7, 68, PBD, check=False)
def OA_8_69(): '\n Return an OA(8,69)\n\n Construction shared by Julian R. Abel.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_PBD`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.orthogonal_arrays import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_8_69\n sage: OA = OA_8_69() # needs sage.schemes\n sage: is_orthogonal_array(OA,8,69,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(8,69) # needs sage.schemes\n True\n ' B = [1, 2, 4, 8, 16, 32, 37, 55, 64] BIBD = [[((x + i) % 73) for x in B] for i in range(73)] oval = [72, 71, 69, 65] PBD = [[x for x in B if (x not in oval)] for B in BIBD] sets_of_size_seven = [R for R in PBD if (len(R) == 7)] others = [R for R in PBD if (len(R) != 7)] O1 = sets_of_size_seven[:3] O2 = sets_of_size_seven[(- 3):] assert all(((x in sum(O1, [])) for x in (68, 27, 52))) assert all(((x in sum(O2, [])) for x in (68, 27, 52))) OA = OA_from_PBD(8, 69, others, check=False)[:(- 69)] OA_8_7 = orthogonal_array(8, 7, check=False) for B in O1: for BB in OA_8_7: OA.append([B[i] for i in BB]) OA_8_7_minus_TD_8_1 = OA_8_7 OA_8_7_minus_TD_8_1.remove(([0] * 8)) for B in O2: B.sort(key=(lambda x: int(bool((x not in (68, 27, 52)))))) for BB in OA_8_7: OA.append([B[i] for i in BB]) done = (sum(O1, []) + sum(O2, [])) missing = [x for x in range(73) if ((x not in done) and (x not in oval))] for x in missing: OA.append(([x] * 8)) relabel = dict(zip([x for x in range(73) if (x not in oval)], range(69))) OA = [[relabel[x] for x in B] for B in OA] return OA
def OA_7_74(): '\n Return an OA(7,74)\n\n Construction shared by Julian R. Abel.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_PBD`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.orthogonal_arrays import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_7_74\n sage: OA = OA_7_74() # needs sage.schemes\n sage: is_orthogonal_array(OA,7,74,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(7,74) # needs sage.schemes\n True\n ' B = [0, 1, 3, 9, 27, 81, 61, 49, 56, 77] BIBD = [[((x + i) % 91) for x in B] for i in range(91)] oval = [((- x) % 91) for x in B][(- 7):] to_delete = (oval + B) PBD = [[x for x in B if (x not in to_delete)] for B in BIBD] PBD.remove([]) V = [x for x in range(91) if (x not in to_delete)] rel = dict(zip(V, range(len(V)))) PBD = [[rel[x] for x in B] for B in PBD] return OA_from_PBD(7, 74, PBD, check=False)
def OA_8_76(): '\n Return an OA(8,76)\n\n Construction shared by Julian R. Abel.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_PBD`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.orthogonal_arrays import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_8_76\n sage: OA = OA_8_76() # needs sage.schemes\n sage: is_orthogonal_array(OA,8,76,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(8,76) # needs sage.schemes\n True\n ' B = [0, 1, 3, 9, 27, 81, 61, 49, 56, 77] BIBD = [[((x + i) % 91) for x in B] for i in range(91)] oval = [2, 4, 5, 12, 24] to_remove = (oval + B) PBD = [[x for x in B if (x not in to_remove)] for B in BIBD] PBD.remove([]) sets_of_size_seven = [R for R in PBD if (len(R) == 7)] others = [R for R in PBD if (len(R) != 7)] critical_points = [57, 83, 52, 13, 15, 64, 37, 50, 63, 31] for (i, x) in zip(critical_points, sets_of_size_seven): x.sort(key=(lambda x: (- int((x == i))))) assert (x[0] == i) OA = OA_from_PBD(8, 76, others, check=False)[:(- 76)] OA_8_7 = orthogonal_array(8, 7, check=False) OA_8_7_minus_TD_8_1 = OA_8_7 OA_8_7_minus_TD_8_1.remove(([0] * 8)) for B in sets_of_size_seven: for BB in OA_8_7: OA.append([B[i] for i in BB]) done = sum(sets_of_size_seven, []) missing = [x for x in range(91) if ((x not in done) and (x not in to_remove))] for x in missing: OA.append(([x] * 8)) relabel = dict(zip([x for x in range(91) if (x not in to_remove)], range(91))) OA = [[relabel[x] for x in B] for B in OA] return OA
def OA_11_80(): '\n Return an OA(11,80)\n\n As explained in the Handbook III.3.76 [DesignHandbook]_. Uses the fact that\n `80 = 2^4 \\times 5` and that `5` is prime.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_11_80\n sage: OA = OA_11_80() # needs sage.rings.finite_rings sage.schemes\n sage: is_orthogonal_array(OA,11,80,2) # needs sage.rings.finite_rings sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(11,80) # needs sage.rings.finite_rings sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None)], [(0, None), (1, None), (2, 3), (3, None), (4, 3), (2, None), (3, 3), (4, None), (0, 3), (1, 3)], [(0, None), (2, 8), (4, 6), (1, 3), (3, 3), (3, 13), (0, 13), (2, 6), (4, 14), (1, 12)], [(0, None), (3, 11), (1, 0), (4, 9), (2, 0), (3, 7), (1, 8), (4, 10), (2, 10), (0, 11)], [(0, None), (4, 8), (3, 14), (2, 14), (1, 12), (2, 10), (1, 10), (0, 3), (4, 5), (3, 8)], [(0, None), (1, 8), (4, 14), (4, 12), (1, 1), (0, 1), (2, 8), (3, 12), (3, 6), (2, 1)], [(1, None), (0, 6), (1, 1), (4, 4), (4, 13), (2, 6), (0, 14), (2, 9), (3, 0), (3, 3)], [(4, None), (1, 9), (0, 7), (1, 1), (4, 8), (3, 5), (2, 14), (0, 0), (2, None), (3, 0)], [(4, None), (4, 6), (1, 2), (0, None), (1, 13), (3, 8), (3, 2), (2, 0), (0, 14), (2, None)], [(1, None), (4, 9), (4, 1), (1, 0), (0, 4), (2, 5), (3, None), (3, 5), (2, None), (0, None)]] Y = [None, 0, 1, 14, 12, 7, 2, 11, 3, 6] return OA_n_times_2_pow_c_from_matrix(11, 4, FiniteField(5), A, Y, check=False)
def OA_15_112(): '\n Returns an OA(15,112)\n\n Published by Julian R. Abel in [Ab1995]_. Uses the fact that 112 = `2^4\n \\times 7` and that `7` is prime.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_15_112\n sage: OA = OA_15_112() # needs sage.rings.finite_rings sage.schemes\n sage: is_orthogonal_array(OA,15,112,2) # needs sage.rings.finite_rings sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(15,112) # needs sage.rings.finite_rings sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None), (4, None), (2, None), (2, None), (4, None), (1, None)], [(0, None), (1, None), (2, None), (3, 5), (4, 9), (5, 11), (6, 12), (1, 10), (0, 10), (1, 11), (4, 13), (2, 6), (2, 2), (4, 1)], [(0, None), (2, 3), (4, 6), (6, 0), (1, 1), (3, 12), (5, 6), (4, 2), (1, 9), (0, 3), (1, 7), (4, 7), (2, 8), (2, 5)], [(0, None), (3, 3), (6, 2), (2, 3), (5, 2), (1, 9), (4, 13), (2, 8), (4, 12), (1, 12), (0, 7), (1, 10), (4, 11), (2, 14)], [(0, None), (4, None), (1, 0), (5, 1), (2, 0), (6, 7), (3, 4), (2, 11), (2, 9), (4, 13), (1, 3), (0, 7), (1, 11), (4, 2)], [(0, None), (5, None), (3, 14), (1, 7), (6, 5), (4, 3), (2, 1), (4, 6), (2, 5), (2, 14), (4, 12), (1, 1), (0, 2), (1, 2)], [(0, None), (6, None), (5, 0), (4, 4), (3, 11), (2, 2), (1, 7), (1, 13), (4, 8), (2, 11), (2, 3), (4, None), (1, 8), (0, 10)], [(0, None), (4, 3), (2, 14), (1, 5), (1, 4), (2, 5), (4, 2), (0, 8), (6, 10), (3, 11), (5, 6), (5, 5), (3, 0), (6, 11)], [(0, None), (5, 3), (4, 0), (4, 6), (5, 4), (0, 3), (3, 11), (6, None), (0, 4), (6, 5), (3, 13), (5, 6), (5, 4), (3, 4)], [(0, None), (6, 3), (6, 4), (0, 5), (2, 5), (5, 5), (2, None), (3, 6), (6, 7), (0, 12), (6, 12), (3, 12), (5, None), (5, 10)], [(0, None), (0, 3), (1, None), (3, 9), (6, 8), (3, 14), (1, 14), (5, 6), (3, 8), (6, 13), (0, 8), (6, 3), (3, 9), (5, 0)], [(0, None), (1, 3), (3, 1), (6, 6), (3, None), (1, 10), (0, 1), (5, 7), (5, 7), (3, 14), (6, 0), (0, 10), (6, 9), (3, 6)], [(0, None), (2, None), (5, 3), (2, 10), (0, 8), (6, 5), (6, 0), (3, 7), (5, 1), (5, 12), (3, 14), (6, 4), (0, 10), (6, 4)], [(0, None), (3, None), (0, 4), (5, 6), (4, 1), (4, 7), (5, 1), (6, 8), (3, 2), (5, 2), (5, 2), (3, 13), (6, 7), (0, 2)]] Y = [None, 0, 1, 14, 12, 7, 2, 11, 3, 4, 5, 10, 8, 6] return OA_n_times_2_pow_c_from_matrix(15, 4, FiniteField(7), list(zip(*A)), Y, check=False)
def OA_9_120(): '\n Return an OA(9,120)\n\n Construction shared by Julian R. Abel:\n\n From a resolvable `(120,8,1)-BIBD`, one can obtain 7 `MOLS(120)` or a\n resolvable `TD(8,120)` by forming a resolvable `TD(8,8) - 8.TD(8,1)` on\n `I_8 \\times B` for each block `B` in the BIBD. This gives a `TD(8,120)\n - 120 TD(8,1)` (which is resolvable as the BIBD is resolvable).\n\n .. SEEALSO::\n\n :func:`RBIBD_120_8_1`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_9_120\n sage: OA = OA_9_120() # needs sage.modules sage.schemes\n sage: is_orthogonal_array(OA,9,120,2) # needs sage.modules sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(9,120) # needs sage.schemes\n True\n ' RBIBD_120 = RBIBD_120_8_1() equiv = [RBIBD_120[(i * 15):((i + 1) * 15)] for i in range(17)] OA8 = orthogonal_array(9, 8) assert all((((len(set(B[:(- 1)])) == 1) == (B[(- 1)] == 0)) for B in OA8)) OA = [] for (i, classs) in enumerate(equiv): for S in classs: for B in OA8: if (B[(- 1)] != 0): OA.append(([S[x] for x in B[:(- 1)]] + [((i * 7) + B[(- 1)])])) for i in range(120): OA.append((([i] * 8) + [0])) return OA
def OA_9_135(): "\n Return an OA(9,135)\n\n Construction shared by Julian R. Abel:\n\n This design can be built by Wilson's method (`135 = 8.16 + 7`) applied\n to an Orthogonal Array `OA(9+7,16)` with 7 groups truncated to size 1 in\n such a way that a block contain 0, 1 or 3 points of the truncated\n groups.\n\n This is possible, because `PG(2,2)` (the projective plane over `GF(2)`)\n is a subdesign in `PG(2,16)` (the projective plane over `GF(16)`); in a\n cyclic `PG(2,16)` or `BIBD(273,17,1)` the points `\\equiv 0\n \\pmod{39}` form such a subdesign (note that `273=16^2 + 16 +1` and\n `273 = 39 \\times 7` and `7 = 2^2 + 2 + 1`).\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_9_135\n sage: OA = OA_9_135() # needs sage.rings.finite_rings sage.schemes\n sage: is_orthogonal_array(OA,9,135,2) # needs sage.rings.finite_rings sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(9,135) # needs sage.schemes\n True\n\n As this orthogonal array requires a `(273,17,1)` cyclic difference set, we check that\n it is available::\n\n sage: G,D = designs.difference_family(273,17,1); G # needs sage.libs.pari\n Ring of integers modulo 273\n " from .bibd import BIBD_from_difference_family from .difference_family import singer_difference_set (G, B) = singer_difference_set(16, 2) PG16 = BIBD_from_difference_family(G, B) n = 273 assert all(((sum((((x % 39) == 0) for x in B)) in [0, 1, 3]) for B in PG16)) lines = [B for B in PG16 if (sum((((x % 39) == 0) for x in B)) == 3)] p = set(range(237)).difference(*lines).pop() for B in PG16: B.sort(key=(lambda x: int(((x % 39) != 0)))) PG16.sort(key=(lambda B: sum((((x % 39) == 0) for x in B)))) r = {} for B in PG16: if (p in B): for x in B: if (x != p): r[x] = len(r) r[p] = (n - 1) assert all(((r[(x * 39)] >= ((n - 1) - (16 * 7))) for x in range(7))) assert all((((r[(x * 39)] % 16) == 0) for x in range(7))) PG = [sorted([r[x] for x in B]) for B in PG16] OA = [[(x % 16) for x in B] for B in PG if ((n - 1) not in B)] truncated_OA = [(B[1:(- 7)] + [(x if (x == 0) else None) for x in B[(- 7):]]) for B in OA] return wilson_construction(truncated_OA, 9, 16, 8, ((1,) * 7), check=False)
def OA_11_160(): '\n Returns an OA(11,160)\n\n Published by Julian R. Abel in [Ab1995]_. Uses the fact that `160 = 2^5\n \\times 5` is a product of a power of `2` and a prime number.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_11_160\n sage: OA = OA_11_160() # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,11,160,2) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(11,160) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None), (4, None), (4, None), (1, None)], [(0, None), (1, None), (2, 5), (3, 9), (4, 9), (1, 16), (0, 20), (1, 23), (4, 24), (4, 19)], [(0, None), (2, 4), (4, 3), (1, 10), (3, 10), (4, 20), (1, 1), (0, 24), (1, 5), (4, 2)], [(0, None), (3, None), (1, 28), (4, 7), (2, 6), (4, 4), (4, 23), (1, 5), (0, 8), (1, 1)], [(0, None), (4, 4), (3, 25), (2, 24), (1, 13), (1, 6), (4, 6), (4, 2), (1, 18), (0, 1)], [(0, None), (2, None), (3, 3), (3, 21), (2, 18), (0, 6), (2, 20), (3, 3), (3, 11), (2, 1)], [(0, None), (3, 4), (0, 5), (1, 27), (1, 30), (2, None), (0, 0), (2, 2), (3, 2), (3, 18)], [(0, None), (4, None), (2, 19), (4, 26), (0, 12), (3, 19), (2, 4), (0, 2), (2, 0), (3, 0)], [(0, None), (0, 4), (4, 29), (2, 29), (4, None), (3, 0), (3, 0), (2, 1), (0, 18), (2, None)], [(0, None), (1, 4), (1, 5), (0, 19), (3, 2), (2, 0), (3, None), (3, 0), (2, None), (0, None)]] Y = [None, 0, 1, 2, 15, 27, 22, 12, 3, 28] return OA_n_times_2_pow_c_from_matrix(11, 5, FiniteField(5), list(zip(*A)), Y, check=False)
def OA_16_176(): '\n Returns an OA(16,176)\n\n Published by Julian R. Abel in [Ab1995]_. Uses the fact that `176 = 2^4\n \\times 11` is a product of a power of `2` and a prime number.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_16_176\n sage: OA = OA_16_176() # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,16,176,2) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(16,176) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None), (4, None), (9, None)], [(0, None), (1, None), (2, None), (3, 0), (4, 2), (5, 12), (6, 5), (7, 6), (8, 13), (9, 9), (10, 11), (1, 3), (0, 6), (1, 14), (4, 12)], [(0, None), (2, None), (4, 4), (6, 4), (8, 7), (10, 2), (1, 2), (3, 13), (5, 0), (7, 3), (9, 7), (4, 6), (1, 12), (0, 1), (1, 10)], [(0, None), (3, None), (6, 3), (9, 4), (1, 6), (4, 13), (7, 1), (10, 1), (2, 7), (5, 1), (8, 0), (9, 6), (4, 4), (1, 5), (0, 1)], [(0, None), (4, None), (8, 13), (1, 8), (5, 0), (9, 5), (2, 14), (6, None), (10, 5), (3, 7), (7, 10), (5, 3), (9, 10), (4, 11), (1, 14)], [(0, None), (5, None), (10, 10), (4, 2), (9, 7), (3, 2), (8, 3), (2, 13), (7, 7), (1, 9), (6, None), (3, 7), (5, 1), (9, 10), (4, 11)], [(0, None), (6, None), (1, 8), (7, 14), (2, 2), (8, 3), (3, 11), (9, 12), (4, 8), (10, 13), (5, 1), (3, 6), (3, 5), (5, 10), (9, 9)], [(0, None), (7, None), (3, 3), (10, None), (6, 14), (2, 4), (9, 1), (5, 7), (1, 5), (8, 7), (4, 13), (5, 6), (3, 6), (3, 11), (5, 3)], [(0, None), (8, None), (5, 14), (2, 11), (10, 14), (7, 8), (4, 14), (1, 14), (9, 9), (6, 14), (3, 9), (9, 2), (5, 6), (3, 3), (3, 10)], [(0, None), (9, None), (7, 5), (5, 5), (3, 8), (1, 8), (10, None), (8, 12), (6, 9), (4, 12), (2, 9), (4, 7), (9, 2), (5, 0), (3, 7)], [(0, None), (10, None), (9, 11), (8, 7), (7, 6), (6, 12), (5, None), (4, 1), (3, 13), (2, 8), (1, 9), (1, None), (4, 3), (9, 7), (5, 13)], [(0, None), (6, 3), (2, 0), (10, 8), (8, 12), (7, 9), (7, 2), (8, 0), (10, 7), (2, 10), (6, 4), (0, 7), (10, 10), (7, 3), (2, 11)], [(0, None), (7, 3), (4, None), (2, 12), (1, 10), (1, 3), (2, 8), (4, 9), (7, 0), (0, 1), (5, 6), (10, 3), (0, 9), (10, 13), (7, 11)], [(0, None), (8, 3), (6, 8), (5, 2), (5, 13), (6, 1), (8, 9), (0, 2), (4, 10), (9, 8), (4, 12), (7, 7), (10, 2), (0, 12), (10, 4)], [(0, None), (9, 3), (8, 3), (8, 9), (9, 1), (0, 4), (3, 3), (7, 11), (1, 9), (7, 10), (3, 8), (2, 10), (7, 6), (10, 14), (0, 3)], [(0, None), (10, 3), (10, 5), (0, 1), (2, 1), (5, 8), (9, 2), (3, 5), (9, 5), (5, 3), (2, 4), (6, 12), (2, 6), (7, 11), (10, 7)], [(0, None), (0, 3), (1, None), (3, 2), (6, 8), (10, 11), (4, 6), (10, None), (6, None), (3, 1), (1, 1), (8, 0), (6, 14), (2, 0), (7, 14)], [(0, None), (1, 3), (3, 8), (6, 9), (10, 8), (4, 10), (10, 1), (6, 10), (3, 0), (1, 8), (0, 11), (8, 10), (8, 14), (6, 10), (2, 14)], [(0, None), (2, 3), (5, 1), (9, 8), (3, 4), (9, 14), (5, 5), (2, 4), (0, 2), (10, 2), (10, None), (6, 2), (8, 5), (8, 1), (6, 9)], [(0, None), (3, 3), (7, 0), (1, None), (7, 1), (3, 10), (0, 8), (9, 13), (8, None), (8, 10), (9, 14), (2, 0), (6, 5), (8, 5), (8, 7)], [(0, None), (4, 3), (9, 10), (4, 14), (0, 14), (8, 14), (6, 14), (5, 6), (5, 13), (6, 5), (8, 12), (7, 1), (2, 4), (6, 3), (8, 6)], [(0, None), (5, 3), (0, 8), (7, 3), (4, 10), (2, 1), (1, 3), (1, 10), (2, None), (4, 8), (7, 12), (10, 6), (7, 10), (2, 6), (6, 1)]] Y = [None, 0, 1, 2, 8, 6, 9, 4, 10, 3, 5, 11, 13, 14, 12] return OA_n_times_2_pow_c_from_matrix(16, 4, FiniteField(11), list(zip(*A)), Y, check=False)
def OA_11_185(): "\n Returns an OA(11,185)\n\n The construction is given in [Greig99]_. In Julian R. Abel's words:\n\n Start with a `PG(2,16)` with a `7` points Fano subplane; outside this\n plane there are `7(17-3) = 98` points on a line of the subplane and\n `273-98-7 = 168` other points. Greig notes that the subdesign\n consisting of these `168` points is a `(168, \\{10,12\\})-PBD`. Now add\n the `17` points of a line disjoint from this subdesign (e.g. a line of\n the Fano subplane). This line will intersect every line of the `168`\n point subdesign in `1` point. Thus the new line sizes are `11` and\n `13`, plus a unique line of size `17`, giving a `(185,\\{11,13,17\\}`-PBD\n and an `OA(11,185)`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_11_185\n sage: OA = OA_11_185() # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,11,185,2) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(11,185) # needs sage.schemes\n True\n\n " from sage.combinat.designs.difference_family import difference_family (G, (B,)) = difference_family(273, 17) BIBD = [[int((x + i)) for x in B] for i in G] assert all(((sum((((x % 39) == 0) for x in B)) in [0, 1, 3]) for B in BIBD)) fano_lines = [B for B in BIBD if (sum((((x % 39) == 0) for x in B)) == 3)] on_a_fano_line = set().union(*fano_lines) not_on_a_fano_line = set(range(273)).difference(on_a_fano_line) ground_set = not_on_a_fano_line.union(fano_lines[0]) PBD = [ground_set.intersection(B) for B in BIBD] relabel = {v: i for (i, v) in enumerate(ground_set)} PBD = [[relabel[x] for x in B] for B in PBD if (len(B) > 1)] special_set = [relabel[x] for x in fano_lines[0]] assert all((((len(B) in (11, 13)) or (set(B) == set(special_set))) for B in PBD)) OA = OA_from_PBD(11, 185, [B for B in PBD if (len(B) < 17)], check=False)[:(- 185)] OA.extend([([i] * 11) for i in range(185) if (i not in special_set)]) OA.extend([[special_set[x] for x in B] for B in orthogonal_array(11, 17)]) return OA
def OA_10_205(): '\n Return an `OA(10,205)`.\n\n Julian R. Abel shared the following construction, which originally appeared\n in Theorem 8.7 of [Greig99]_, and can in Lemmas 5.14-5.16 of [ColDin01]_:\n\n Consider a `PG(2,4^2)` containing a Baer subplane (i.e. a `PG(2,4)`) `B`\n and a point `p\\in B`. Among the `4^2+1=17` lines of `PG(2,4^2)`\n containing `p`:\n\n * `4+1=5` lines intersect `B` on `5` points\n\n * `4^2-4=12` lines intersect `B` on `1` point\n\n As those lines are disjoint outside of `B` we can use them as groups to\n build a GDD on `16^2+16+1-(4^4+4+1)=252` points. By keeping only 9 lines\n of the second kind, however, we obtain a `(204,\\{9,13,17\\})`-GDD of type\n 12^5.16^9.\n\n We complete it into a PBD by adding a block `g\\cup \\{204\\}` for each\n group `g`. We then build an OA from this PBD using the fact that all\n blocks of size 9 are disjoint.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_PBD`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_10_205\n sage: OA = OA_10_205() # needs sage.schemes\n sage: is_orthogonal_array(OA,10,205,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(10,205) # needs sage.schemes\n True\n ' pplane_size = (((16 ** 2) + 16) + 1) baer_subplane_size = (((4 ** 2) + 4) + 1) B = [0, 1, 22, 33, 83, 122, 135, 141, 145, 159, 175, 200, 226, 229, 231, 238, 246] pplane = [[((xx + i) % pplane_size) for xx in B] for i in range(pplane_size)] baer_subplane = set([((i * pplane_size) / baer_subplane_size) for i in range(baer_subplane_size)]) p = list(baer_subplane)[0] lines_through_p = [B for B in pplane if (p in B)] lines_through_p.sort(key=(lambda s: len(baer_subplane.intersection(s)))) groups = [[xx for xx in l if (xx not in baer_subplane)] for l in lines_through_p[(((4 ** 2) - 4) - 9):]] relabel = {v: i for (i, v) in enumerate(sum(groups, []))} GDD = [[relabel[xx] for xx in B if (xx in relabel)] for B in pplane if (p not in B)] GDD.extend([([relabel[xx] for xx in G] + [204]) for G in groups]) blocks_of_size_9 = [B for B in GDD if (len(B) == 9)] blocks_of_size_9_union = sum(blocks_of_size_9, []) OA = OA_from_PBD(10, 205, [B for B in GDD if (len(B) != 9)], check=False)[:(- 205)] OA.extend([[B[xx] for xx in R] for R in orthogonal_array(10, 9) for B in blocks_of_size_9]) OA.extend([([i] * 10) for i in set(range(205)).difference(blocks_of_size_9_union)]) return OA
def OA_16_208(): '\n Returns an OA(16,208)\n\n Published by Julian R. Abel in [Ab1995]_. Uses the fact that `208 = 2^4\n \\times 13` is a product of `2` and a prime number.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_16_208\n sage: OA = OA_16_208() # not tested (too long) # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,16,208,2) # not tested (too long) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(16,208) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None)], [(0, None), (1, None), (2, 0), (3, 7), (4, 1), (5, 11), (6, 2), (7, 10), (8, None), (9, 10), (10, None), (11, 3), (12, 3), (1, 4), (0, 8)], [(0, None), (2, None), (4, 4), (6, 3), (8, 0), (10, 5), (12, 14), (1, None), (3, 10), (5, 7), (7, 3), (9, 12), (11, 6), (4, 9), (1, 14)], [(0, None), (3, None), (6, 4), (9, 6), (12, 10), (2, 11), (5, 14), (8, 3), (11, 13), (1, 1), (4, 12), (7, 14), (10, 1), (9, 7), (4, 8)], [(0, None), (4, None), (8, 9), (12, 5), (3, 10), (7, 14), (11, 0), (2, 6), (6, 11), (10, 11), (1, 9), (5, 3), (9, 9), (3, 6), (9, 8)], [(0, None), (5, None), (10, 5), (2, 5), (7, 3), (12, 3), (4, 12), (9, 3), (1, 2), (6, 2), (11, None), (3, 13), (8, 7), (12, 10), (3, 1)], [(0, None), (6, None), (12, 13), (5, 5), (11, 13), (4, 6), (10, 6), (3, 2), (9, 4), (2, 12), (8, 13), (1, 13), (7, 2), (10, 8), (12, None)], [(0, None), (7, None), (1, 2), (8, 12), (2, 4), (9, 12), (3, 0), (10, 10), (4, 14), (11, 11), (5, 14), (12, 9), (6, 8), (10, 3), (10, 6)], [(0, None), (8, None), (3, None), (11, 4), (6, 12), (1, 12), (9, 14), (4, 2), (12, 9), (7, 9), (2, None), (10, 1), (5, 14), (12, 5), (10, 8)], [(0, None), (9, None), (5, 9), (1, 7), (10, 6), (6, 3), (2, 6), (11, 10), (7, 11), (3, 13), (12, 2), (8, 0), (4, 13), (3, 3), (12, 14)], [(0, None), (10, None), (7, 7), (4, 1), (1, 8), (11, 1), (8, 11), (5, 4), (2, 11), (12, 8), (9, 12), (6, 4), (3, 0), (9, 4), (3, 8)], [(0, None), (11, None), (9, 3), (7, 11), (5, 14), (3, 10), (1, 10), (12, 0), (10, 2), (8, 2), (6, 6), (4, 2), (2, 12), (4, 8), (9, 10)], [(0, None), (12, None), (11, 4), (10, 9), (9, 2), (8, None), (7, 9), (6, 12), (5, 5), (4, None), (3, 7), (2, 10), (1, 13), (1, 6), (4, 0)], [(0, None), (5, 3), (7, 5), (6, 5), (2, 14), (8, 5), (11, 1), (11, 6), (8, 13), (2, 13), (6, 9), (7, None), (5, 10), (0, 5), (2, 8)], [(0, None), (6, 3), (9, 4), (9, 13), (6, 4), (0, 5), (4, 6), (5, 2), (3, None), (11, 14), (3, 3), (5, 7), (4, 1), (2, 8), (0, 2)], [(0, None), (7, 3), (11, 5), (12, 12), (10, None), (5, 5), (10, 7), (12, 9), (11, 9), (7, 7), (0, 0), (3, 12), (3, 11), (8, 13), (2, 14)], [(0, None), (8, 3), (0, 8), (2, 6), (1, None), (10, 9), (3, 12), (6, 8), (6, 4), (3, 9), (10, 2), (1, 11), (2, 7), (5, 2), (8, 2)], [(0, None), (9, 3), (2, 3), (5, 3), (5, 8), (2, 0), (9, 1), (0, 3), (1, 14), (12, 3), (7, 6), (12, 4), (1, 3), (6, 10), (5, 7)], [(0, None), (10, 3), (4, 2), (8, 0), (9, 8), (7, 1), (2, 5), (7, None), (9, 2), (8, 4), (4, 14), (10, 13), (0, 10), (11, 7), (6, 10)], [(0, None), (11, 3), (6, 9), (11, 14), (0, 10), (12, 13), (8, 6), (1, 8), (4, 7), (4, 0), (1, 14), (8, 2), (12, 8), (7, 10), (11, 7)], [(0, None), (12, 3), (8, 12), (1, 9), (4, 6), (4, 13), (1, 6), (8, 1), (12, 4), (0, 7), (11, 5), (6, 6), (11, 14), (7, 3), (7, 5)], [(0, None), (0, 3), (10, 10), (4, 2), (8, 1), (9, None), (7, 2), (2, 10), (7, 13), (9, 5), (8, 14), (4, 7), (10, 11), (11, 13), (7, 0)], [(0, None), (1, 3), (12, 11), (7, 12), (12, 13), (1, 2), (0, 9), (9, 6), (2, 13), (5, 4), (5, 13), (2, 4), (9, 12), (6, 5), (11, 1)], [(0, None), (2, 3), (1, 8), (10, None), (3, 13), (6, None), (6, 1), (3, 0), (10, 4), (1, 14), (2, 0), (0, 3), (8, 13), (5, 1), (6, 7)], [(0, None), (3, 3), (3, 14), (0, 1), (7, 14), (11, 4), (12, 9), (10, 1), (5, 9), (10, None), (12, 13), (11, None), (7, 7), (8, 6), (5, 0)], [(0, None), (4, 3), (5, 10), (3, 8), (11, 8), (3, 0), (5, 7), (4, 12), (0, 13), (6, None), (9, 11), (9, 5), (6, 0), (2, 5), (8, 8)]] Y = [None, 0, 1, 2, 12, 9, 13, 11, 7, 4, 8, 5, 14, 6, 3] return OA_n_times_2_pow_c_from_matrix(16, 4, FiniteField(13), list(zip(*A)), Y, check=False)
def OA_15_224(): '\n Returns an OA(15,224)\n\n Published by Julian R. Abel in [Ab1995]_ (uses the fact that `224=2^5\n \\times 7` is a product of a power of `2` and a prime number).\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_15_224\n sage: OA = OA_15_224() # not tested (too long) # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,15,224,2) # not tested (too long) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(15,224) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None), (4, None), (2, None), (2, None), (4, None), (1, None)], [(0, None), (1, None), (2, 9), (3, 23), (4, 29), (5, 4), (6, 30), (1, 26), (0, None), (1, 11), (4, 2), (2, 28), (2, None), (4, 13)], [(0, None), (2, None), (4, 8), (6, None), (1, 29), (3, 21), (5, 4), (4, 5), (1, 4), (0, 14), (1, 5), (4, 6), (2, 0), (2, 2)], [(0, None), (3, None), (6, 8), (2, 12), (5, 4), (1, 1), (4, 2), (2, 1), (4, 18), (1, 27), (0, 5), (1, None), (4, 1), (2, None)], [(0, None), (4, None), (1, 9), (5, 2), (2, 29), (6, 17), (3, 0), (2, 12), (2, 5), (4, 22), (1, 0), (0, 29), (1, 19), (4, None)], [(0, None), (5, None), (3, 26), (1, 0), (6, 29), (4, 16), (2, 11), (4, 21), (2, 28), (2, 16), (4, 0), (1, 3), (0, 11), (1, 2)], [(0, None), (6, None), (5, 3), (4, 19), (3, 24), (2, 20), (1, 28), (1, 12), (4, 23), (2, 0), (2, 5), (4, 29), (1, 0), (0, 2)], [(0, None), (4, 4), (2, 14), (1, 23), (1, 22), (2, 17), (4, 17), (0, 25), (6, 21), (3, 11), (5, 2), (5, 27), (3, 5), (6, 2)], [(0, None), (5, 4), (4, 3), (4, 0), (5, 20), (0, 4), (3, 8), (6, 28), (0, 16), (6, 1), (3, 22), (5, 0), (5, 0), (3, 2)], [(0, None), (6, 4), (6, None), (0, 18), (2, 0), (5, 20), (2, 4), (3, 11), (6, 15), (0, 18), (6, 5), (3, 0), (5, None), (5, 2)], [(0, None), (0, 4), (1, 15), (3, 29), (6, 20), (3, 24), (1, 13), (5, 30), (3, 2), (6, None), (0, 10), (6, 3), (3, 0), (5, None)], [(0, None), (1, 4), (3, 4), (6, 12), (3, 28), (1, 27), (0, 6), (5, 7), (5, 29), (3, 0), (6, 0), (0, 0), (6, 0), (3, None)], [(0, None), (2, 4), (5, 11), (2, 5), (0, 21), (6, 11), (6, 24), (3, 24), (5, 11), (5, 30), (3, None), (6, None), (0, None), (6, 1)], [(0, None), (3, 4), (0, 11), (5, 11), (4, 22), (4, 2), (5, 23), (6, 22), (3, 27), (5, 1), (5, 0), (3, None), (6, None), (0, None)]] Y = [None, 0, 1, 2, 27, 22, 11, 4, 26, 25, 29, 24, 7, 20] return OA_n_times_2_pow_c_from_matrix(15, 5, FiniteField(7), list(zip(*A)), Y, check=False)
def OA_11_254(): '\n Return an OA(11,254)\n\n This constructions appears in [Greig99]_.\n\n From a cyclic `PG(2,19)` whose base blocks contains 7,9, and 4 points in the\n congruence classes mod 3, build a `(254,{11,13,16})-PBD` by ignoring the\n points of a congruence class. There exist `OA(12,11),OA(12,13),OA(12,16)`,\n which gives the `OA(11,254)`.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_from_PBD`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_11_254\n sage: OA = OA_11_254() # needs sage.schemes\n sage: is_orthogonal_array(OA,11,254,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(11,254) # needs sage.schemes\n True\n ' B = (0, 1, 19, 28, 96, 118, 151, 153, 176, 202, 240, 254, 290, 296, 300, 307, 337, 361, 366, 369) BIBD = [[((x + i) % 381) for x in B] for i in range(381)] BIBD = [[((2 * (x // 3)) + (x % 3)) for x in B if ((x % 3) < 2)] for B in BIBD] return OA_from_PBD(11, 254, BIBD, check=False)
def OA_20_352(): '\n Returns an OA(20,352)\n\n Published by Julian R. Abel in [Ab1995]_ (uses the fact that `352=2^5\n \\times 11` is the product of a power of `2` and a prime number).\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_20_352\n sage: OA = OA_20_352() # not tested (~25s) # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,20,352,2) # not tested (~25s) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(20,352) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None), (4, None), (9, None), (5, None), (3, None), (3, None), (5, None)], [(0, None), (1, None), (2, 13), (3, 2), (4, 0), (5, 8), (6, 30), (7, 0), (8, 13), (9, 26), (10, 10), (1, 29), (0, 9), (1, 11), (4, 0), (9, 23), (5, 7), (3, 25), (3, 29)], [(0, None), (2, None), (4, 29), (6, 6), (8, 3), (10, 18), (1, 21), (3, 24), (5, 4), (7, 7), (9, 29), (4, 22), (1, 2), (0, 27), (1, 10), (4, 13), (9, 22), (5, 6), (3, 20)], [(0, None), (3, None), (6, 25), (9, 21), (1, 23), (4, 25), (7, 12), (10, 16), (2, 26), (5, 27), (8, 19), (9, 27), (4, 6), (1, 5), (0, 6), (1, 15), (4, 10), (9, 2), (5, 14)], [(0, None), (4, None), (8, 3), (1, 23), (5, 17), (9, 7), (2, 7), (6, 25), (10, 27), (3, 30), (7, 5), (5, 23), (9, 24), (4, 16), (1, 12), (0, 8), (1, 12), (4, 17), (9, 28)], [(0, None), (5, None), (10, 10), (4, 27), (9, 4), (3, 24), (8, 21), (2, 3), (7, 22), (1, 21), (6, 24), (3, 28), (5, 3), (9, 26), (4, 29), (1, 9), (0, 19), (1, 2), (4, 0)], [(0, None), (6, None), (1, 11), (7, 9), (2, 14), (8, 15), (3, 11), (9, 7), (4, 27), (10, 13), (5, 4), (3, 18), (3, 0), (5, 5), (9, 2), (4, 7), (1, 30), (0, 10), (1, None)], [(0, None), (7, None), (3, 25), (10, 7), (6, 29), (2, 4), (9, 10), (5, 22), (1, 25), (8, 18), (4, 11), (5, 21), (3, 29), (3, 14), (5, 12), (9, 25), (4, 2), (1, 13), (0, 19)], [(0, None), (8, None), (5, 27), (2, 30), (10, 24), (7, 4), (4, 6), (1, 4), (9, 5), (6, 27), (3, 0), (9, 2), (5, 20), (3, 10), (3, 13), (5, 2), (9, 5), (4, 21), (1, 12)], [(0, None), (9, None), (7, 21), (5, 0), (3, 9), (1, 13), (10, 17), (8, 1), (6, 15), (4, 30), (2, 28), (4, 3), (9, 28), (5, 0), (3, None), (3, 2), (5, 23), (9, 10), (4, 15)], [(0, None), (10, None), (9, 29), (8, 8), (7, 6), (6, 6), (5, 18), (4, 20), (3, 22), (2, 7), (1, 13), (1, 24), (4, 13), (9, 14), (5, 29), (3, 27), (3, 16), (5, 12), (9, 4)], [(0, None), (6, 4), (2, 17), (10, 16), (8, 26), (7, 17), (7, 21), (8, 9), (10, 2), (2, 25), (6, 27), (0, 20), (10, 8), (7, 12), (2, 26), (6, 22), (8, 8), (8, 16), (6, 13)], [(0, None), (7, 4), (4, 1), (2, 0), (1, 8), (1, 18), (2, 10), (4, 9), (7, 2), (0, 11), (5, 27), (10, 27), (0, 16), (10, 19), (7, 0), (2, 2), (6, 26), (8, 30), (8, 6)], [(0, None), (8, 4), (6, 19), (5, 24), (5, 16), (6, 20), (8, None), (0, 17), (4, 5), (9, 23), (4, 27), (7, 22), (10, 25), (0, 23), (10, 11), (7, 10), (2, 16), (6, 28), (8, 3)], [(0, None), (9, 4), (8, 14), (8, 30), (9, 16), (0, 0), (3, 25), (7, 30), (1, 27), (7, 4), (3, 10), (2, 5), (7, 3), (10, 11), (0, 21), (10, None), (7, 7), (2, 19), (6, 24)], [(0, None), (10, 4), (10, 30), (0, 12), (2, 9), (5, 9), (9, 0), (3, 14), (9, 17), (5, 17), (2, 18), (6, 10), (2, 0), (7, 16), (10, 23), (0, 1), (10, 26), (7, 18), (2, 9)], [(0, None), (0, 4), (1, 13), (3, 28), (6, 25), (10, 28), (4, 16), (10, 17), (6, 23), (3, 7), (1, 22), (8, 22), (6, 27), (2, 29), (7, 5), (10, 14), (0, 12), (10, 14), (7, 6)], [(0, None), (1, 4), (3, 6), (6, 4), (10, 13), (4, 12), (10, 15), (6, 27), (3, None), (1, 26), (0, 3), (8, 21), (8, 26), (6, 13), (2, 27), (7, 11), (10, 5), (0, 3), (10, 3)], [(0, None), (2, 4), (5, 12), (9, 27), (3, 7), (9, 21), (5, None), (2, 22), (0, 28), (10, 30), (10, 25), (6, 12), (8, 6), (8, 30), (6, 28), (2, 6), (7, 26), (10, 3), (0, None)], [(0, None), (3, 4), (7, 22), (1, 7), (7, 8), (3, 12), (0, 27), (9, 1), (8, 17), (8, 4), (9, 12), (2, 16), (6, 23), (8, 14), (8, 2), (6, 26), (2, 14), (7, 22), (10, 30)], [(0, None), (4, 4), (9, 21), (4, 25), (0, 9), (8, 23), (6, 5), (5, 20), (5, 13), (6, 19), (8, 0), (7, 30), (2, 29), (6, 24), (8, 18), (8, 10), (6, 9), (2, 20), (7, 4)], [(0, None), (5, 4), (0, 25), (7, 4), (4, 20), (2, 3), (1, None), (1, 21), (2, None), (4, 26), (7, 1), (10, 23), (7, 20), (2, 3), (6, 5), (8, 19), (8, 9), (6, 23), (2, 7)]] Y = [None, 0, 1, 2, 18, 5, 11, 4, 13, 26, 25, 29, 24, 7, 20, 19, 9, 12, 15] return OA_n_times_2_pow_c_from_matrix(20, 5, FiniteField(11), list(zip(*A)), Y, check=False)
def OA_20_416(): '\n Returns an OA(20,416)\n\n Published by Julian R. Abel in [Ab1995]_ (uses the fact that `416=2^5\n \\times 13` is the product of a power of `2` and a prime number).\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_20_416\n sage: OA = OA_20_416() # not tested (~35s) # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,20,416,2) # not tested # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(20,416) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField Z = None A = [[(0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (1, Z), (4, Z), (9, Z), (3, Z), (12, Z)], [(0, Z), (1, Z), (2, 18), (3, 2), (4, 20), (5, 22), (6, 11), (7, 19), (8, 0), (9, 26), (10, Z), (11, 5), (12, 27), (1, 17), (0, 30), (1, 22), (4, 29), (9, 6), (3, 19)], [(0, Z), (2, 4), (4, 21), (6, 10), (8, 24), (10, 13), (12, 7), (1, 11), (3, 29), (5, 12), (7, 21), (9, 2), (11, 11), (4, 5), (1, 11), (0, 23), (1, 13), (4, 6), (9, 15)], [(0, Z), (3, 4), (6, 17), (9, 20), (12, 26), (2, 2), (5, 12), (8, 29), (11, 1), (1, Z), (4, 15), (7, 16), (10, 27), (9, 2), (4, 7), (1, 5), (0, 23), (1, 24), (4, 8)], [(0, Z), (4, 4), (8, 29), (12, 8), (3, 3), (7, 8), (11, 2), (2, 17), (6, 4), (10, 2), (1, 21), (5, 29), (9, 20), (3, 2), (9, 1), (4, 14), (1, 21), (0, 24), (1, 28)], [(0, Z), (5, 4), (10, 22), (2, 18), (7, 6), (12, 2), (4, 18), (9, 27), (1, 15), (6, Z), (11, 20), (3, 15), (8, 9), (12, 9), (3, 3), (9, 13), (4, 4), (1, 7), (0, 14)], [(0, Z), (6, Z), (12, 23), (5, 13), (11, 11), (4, 10), (10, 0), (3, 4), (9, 16), (2, 28), (8, 27), (1, 1), (7, 23), (10, 17), (12, 9), (3, 20), (9, 16), (4, 17), (1, 26)], [(0, Z), (7, Z), (1, 3), (8, 13), (2, 8), (9, 9), (3, 0), (10, 26), (4, 5), (11, 6), (5, 22), (12, 1), (6, 17), (10, 10), (10, 5), (12, 15), (3, 25), (9, Z), (4, 4)], [(0, Z), (8, 4), (3, 10), (11, 3), (6, 17), (1, 21), (9, 18), (4, 5), (12, 27), (7, 20), (2, 16), (10, 25), (5, 22), (12, 21), (10, 25), (10, 12), (12, 28), (3, 19), (9, 29)], [(0, Z), (9, 4), (5, 6), (1, 16), (10, 4), (6, 24), (2, 14), (11, 11), (7, 2), (3, 9), (12, 30), (8, 28), (4, 2), (3, 7), (12, 6), (10, 17), (10, 2), (12, 13), (3, 26)], [(0, Z), (10, 4), (7, 11), (4, 18), (1, 23), (11, 21), (8, 28), (5, 21), (2, 29), (12, 20), (9, 0), (6, 8), (3, 6), (9, 7), (3, 12), (12, 5), (10, 1), (10, 21), (12, 5)], [(0, Z), (11, 4), (9, 22), (7, 11), (5, 17), (3, Z), (1, 17), (12, 25), (10, 14), (8, 18), (6, 2), (4, 17), (2, 25), (4, 29), (9, 6), (3, 2), (12, 8), (10, 13), (10, 14)], [(0, Z), (12, Z), (11, 7), (10, 26), (9, 24), (8, 4), (7, 25), (6, Z), (5, 13), (4, 9), (3, 5), (2, 19), (1, 10), (1, 26), (4, 14), (9, 7), (3, 11), (12, 9), (10, 20)], [(0, Z), (5, Z), (7, 7), (6, 27), (2, 5), (8, 1), (11, 23), (11, Z), (8, 23), (2, 21), (6, 20), (7, 5), (5, 6), (0, 2), (2, 12), (8, 15), (5, 22), (6, 25), (11, 10)], [(0, Z), (6, 4), (9, 24), (9, 18), (6, 26), (0, 26), (4, 17), (5, 24), (3, 5), (11, 9), (3, 15), (5, 23), (4, 22), (2, 26), (0, 8), (2, 21), (8, 25), (5, 15), (6, 8)], [(0, Z), (7, 4), (11, 11), (12, 9), (10, 10), (5, 6), (10, 1), (12, 24), (11, 6), (7, 26), (0, 8), (3, 10), (3, 29), (8, 3), (2, 24), (0, 22), (2, 13), (8, 2), (5, 0)], [(0, Z), (8, Z), (0, 27), (2, 0), (1, 25), (10, 21), (3, 10), (6, 20), (6, 14), (3, 1), (10, 3), (1, 15), (2, 14), (5, 12), (8, 11), (2, 28), (0, 15), (2, 13), (8, 22)], [(0, Z), (9, Z), (2, 13), (5, 11), (5, 6), (2, 24), (9, 9), (0, 14), (1, 30), (12, 1), (7, 15), (12, 15), (1, 5), (6, 23), (5, 9), (8, 3), (2, 27), (0, 28), (2, 12)], [(0, Z), (10, Z), (4, 18), (8, 23), (9, 27), (7, 4), (2, 2), (7, Z), (9, 10), (8, 8), (4, 0), (10, 12), (0, 21), (11, 28), (6, 15), (5, 23), (8, 5), (2, 28), (0, 7)], [(0, Z), (11, Z), (6, 7), (11, 27), (0, 0), (12, 17), (8, 11), (1, 12), (4, 22), (4, 15), (1, 16), (8, 0), (12, 6), (7, 16), (11, 30), (6, 21), (5, 14), (8, 17), (2, 26)], [(0, Z), (12, 4), (8, 28), (1, 22), (4, 2), (4, 15), (1, 6), (8, 12), (12, 19), (0, 21), (11, 2), (6, 4), (11, 19), (7, 30), (7, 11), (11, 12), (6, 20), (5, 3), (8, 7)], [(0, Z), (0, 4), (10, 21), (4, 4), (8, 1), (9, 6), (7, 30), (2, 4), (7, 8), (9, 30), (8, 3), (4, 22), (10, 3), (11, 25), (7, 1), (7, 24), (11, 20), (6, 30), (5, 4)], [(0, Z), (1, 4), (12, 21), (7, 3), (12, 2), (1, 1), (0, 6), (9, 14), (2, 19), (5, 6), (5, 12), (2, 9), (9, 9), (6, 19), (11, Z), (7, 4), (7, 6), (11, 29), (6, 15)], [(0, Z), (2, Z), (1, 22), (10, Z), (3, 5), (6, 30), (6, 26), (3, 1), (10, 12), (1, 16), (2, 28), (0, 20), (8, 11), (5, 29), (6, 7), (11, 21), (7, 14), (7, 8), (11, 11)], [(0, Z), (3, Z), (3, 4), (0, 18), (7, 2), (11, 16), (12, 28), (10, 4), (5, 28), (10, 0), (12, 4), (11, 10), (7, 11), (8, 17), (5, 6), (6, 16), (11, 4), (7, 22), (7, 28)], [(0, Z), (4, Z), (5, 22), (3, 18), (11, Z), (3, 15), (5, 1), (4, 26), (0, 10), (6, 8), (9, 9), (9, 29), (6, Z), (2, 23), (8, 28), (5, 30), (6, 8), (11, 24), (7, 16)]] Y = [None, 0, 1, 2, 18, 5, 11, 4, 13, 26, 25, 29, 24, 7, 20, 19, 9, 12, 15] return OA_n_times_2_pow_c_from_matrix(20, 5, FiniteField(13), list(zip(*A)), Y, check=False)
def OA_20_544(): '\n Returns an OA(20,544)\n\n Published by Julian R. Abel in [Ab1995]_ (uses the fact that\n `544=2^5 \\times 17` is the product of a power of `2` and a prime number).\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_20_544\n sage: OA = OA_20_544() # not tested (too long ~1mn) # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,20,544,2) # not tested # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(20,544) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField Z = None A = [[(0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (0, Z), (1, Z)], [(0, Z), (1, 4), (2, 7), (3, 30), (4, 17), (5, 2), (6, 22), (7, 23), (8, 28), (9, 2), (10, 27), (11, 26), (12, 13), (13, 25), (14, 18), (15, 15), (16, 18), (1, 14), (0, 1)], [(0, Z), (2, 4), (4, 20), (6, 29), (8, 27), (10, 7), (12, 20), (14, 19), (16, 26), (1, 28), (3, Z), (5, 27), (7, Z), (9, 11), (11, Z), (13, 17), (15, 1), (4, 14), (1, 14)], [(0, Z), (3, Z), (6, 14), (9, 26), (12, 17), (15, 15), (1, 26), (4, 24), (7, 27), (10, 13), (13, 10), (16, 7), (2, 1), (5, Z), (8, 1), (11, 15), (14, 18), (9, 21), (4, 6)], [(0, Z), (4, 4), (8, Z), (12, 2), (16, 23), (3, 19), (7, 26), (11, 7), (15, 26), (2, 3), (6, 11), (10, 16), (14, 23), (1, 30), (5, 1), (9, 30), (13, 19), (16, 10), (9, 4)], [(0, Z), (5, Z), (10, 17), (15, 19), (3, 13), (8, 4), (13, 21), (1, 9), (6, 7), (11, 4), (16, 24), (4, 6), (9, 11), (14, Z), (2, 6), (7, 14), (12, 10), (8, 12), (16, 1)], [(0, Z), (6, Z), (12, 1), (1, 23), (7, 21), (13, 10), (2, 0), (8, 15), (14, 19), (3, 30), (9, 21), (15, 17), (4, 25), (10, 20), (16, 15), (5, 16), (11, 15), (2, 22), (8, 29)], [(0, Z), (7, Z), (14, 30), (4, 26), (11, 24), (1, 22), (8, 22), (15, 27), (5, 23), (12, 13), (2, 18), (9, 22), (16, 6), (6, 27), (13, 19), (3, 1), (10, 16), (15, 9), (2, 5)], [(0, Z), (8, 4), (16, 5), (7, 18), (15, 11), (6, 1), (14, 21), (5, 28), (13, 19), (4, 7), (12, 19), (3, 15), (11, 13), (2, 23), (10, 1), (1, 23), (9, 19), (13, 27), (15, 25)], [(0, Z), (9, Z), (1, 3), (10, 4), (2, 29), (11, 13), (3, 27), (12, 11), (4, 30), (13, 9), (5, 18), (14, 17), (6, 18), (15, 10), (7, 11), (16, 28), (8, 26), (13, 12), (13, 9)], [(0, Z), (10, Z), (3, 18), (13, 21), (6, 8), (16, 1), (9, 11), (2, 11), (12, 12), (5, 20), (15, 21), (8, 12), (1, 5), (11, 28), (4, 16), (14, 16), (7, 21), (15, 0), (13, 20)], [(0, Z), (11, 4), (5, 25), (16, 2), (10, 18), (4, 6), (15, 20), (9, 29), (3, 13), (14, 24), (8, 18), (2, 22), (13, 1), (7, 8), (1, 21), (12, 16), (6, 23), (2, 10), (15, 26)], [(0, Z), (12, 4), (7, 11), (2, 4), (14, 25), (9, 0), (4, 5), (16, 21), (11, 18), (6, 18), (1, 22), (13, 27), (8, 23), (3, 20), (15, 18), (10, 7), (5, 10), (8, 11), (2, 18)], [(0, Z), (13, Z), (9, 21), (5, 17), (1, 26), (14, 30), (10, 11), (6, 1), (2, 8), (15, 9), (11, 5), (7, 29), (3, 17), (16, 3), (12, 3), (8, 30), (4, 3), (16, 5), (8, 21)], [(0, Z), (14, Z), (11, 20), (8, 24), (5, Z), (2, 2), (16, 24), (13, 12), (10, 21), (7, 26), (4, 29), (1, 1), (15, 1), (12, 19), (9, 8), (6, 26), (3, 10), (9, 20), (16, 21)], [(0, Z), (15, Z), (13, 21), (11, 10), (9, 7), (7, 21), (5, 11), (3, 19), (1, 29), (16, 13), (14, 9), (12, 9), (10, 8), (8, 16), (6, 15), (4, 14), (2, 29), (4, 16), (9, 9)], [(0, Z), (16, 4), (15, 19), (14, 21), (13, 0), (12, 13), (11, 28), (10, 21), (9, 5), (8, 18), (7, 2), (6, Z), (5, 20), (4, 26), (3, 8), (2, 9), (1, 23), (1, 19), (4, 23)], [(0, Z), (3, 4), (12, 11), (10, 17), (14, 14), (7, 1), (6, 27), (11, 25), (5, 2), (5, 24), (11, 15), (6, 8), (7, 28), (14, 21), (10, 4), (12, 20), (3, 26), (0, 5), (3, 12)], [(0, Z), (4, Z), (14, 17), (13, 26), (1, 12), (12, 12), (12, 23), (1, 13), (13, 7), (14, 10), (4, 28), (0, 11), (2, 7), (10, 15), (7, Z), (10, 1), (2, 6), (3, 24), (0, 18)], [(0, Z), (5, 4), (16, 24), (16, 1), (5, 27), (0, 14), (1, 11), (8, 13), (4, 25), (6, 25), (14, 14), (11, 6), (14, 4), (6, 24), (4, 4), (8, 28), (1, 14), (12, 22), (3, 11)], [(0, Z), (6, 4), (1, 10), (2, 6), (9, 12), (5, 3), (7, 11), (15, 30), (12, 21), (15, 26), (7, 3), (5, 12), (9, 0), (2, 25), (1, 2), (6, 0), (0, 13), (10, 13), (12, 14)], [(0, Z), (7, 4), (3, 24), (5, 25), (13, 20), (10, 19), (13, 16), (5, 4), (3, 23), (7, 20), (0, 8), (16, 4), (4, 19), (15, 0), (15, 10), (4, 11), (16, 7), (14, 11), (10, 6)], [(0, Z), (8, Z), (5, 1), (8, 21), (0, 1), (15, 17), (2, 26), (12, 2), (11, 6), (16, 2), (10, 15), (10, 13), (16, 16), (11, 12), (12, 22), (2, 11), (15, 22), (7, 30), (14, 22)], [(0, Z), (9, 4), (7, 20), (11, 24), (4, 7), (3, 11), (8, 21), (2, 23), (2, 2), (8, 12), (3, 8), (4, 13), (11, 17), (7, 4), (9, 3), (0, 18), (14, 12), (6, 26), (7, 28)], [(0, Z), (10, 4), (9, 22), (14, 23), (8, 5), (8, 8), (14, 12), (9, 6), (10, 20), (0, 11), (13, 23), (15, 26), (6, 12), (3, 15), (6, Z), (15, 18), (13, 1), (11, 22), (6, 24)], [(0, Z), (11, Z), (11, 11), (0, 28), (12, 16), (13, 18), (3, 3), (16, 22), (1, 9), (9, Z), (6, 21), (9, 6), (1, 0), (16, 1), (3, 2), (13, 28), (12, 6), (5, 18), (11, 9)], [(0, Z), (12, Z), (13, 5), (3, 14), (16, 22), (1, 5), (9, 1), (6, Z), (9, 3), (1, 9), (16, 21), (3, 18), (13, 17), (12, 29), (0, 13), (11, 4), (11, 18), (5, 21), (5, 6)], [(0, Z), (13, 4), (15, 27), (6, 26), (3, 20), (6, 29), (15, 11), (13, 18), (0, 4), (10, 5), (9, 16), (14, 26), (8, 20), (8, 8), (14, 11), (9, 10), (10, 9), (11, 17), (5, 21)], [(0, Z), (14, 4), (0, 29), (9, 8), (7, 2), (11, 18), (4, 22), (3, 22), (8, 13), (2, 23), (2, 21), (8, 9), (3, 30), (4, 21), (11, 5), (7, 25), (9, Z), (6, 0), (11, 17)], [(0, Z), (15, 4), (2, 27), (12, 27), (11, 28), (16, 0), (10, 6), (10, 12), (16, 11), (11, 15), (12, 2), (2, 10), (15, 19), (0, 11), (8, 10), (5, 6), (8, 5), (7, 7), (6, 16)], [(0, Z), (16, Z), (4, 23), (15, 4), (15, 30), (4, 27), (16, 12), (0, 8), (7, 9), (3, 6), (5, 26), (13, 28), (10, 12), (13, 14), (5, 30), (3, 27), (7, 6), (14, 15), (7, 18)], [(0, Z), (0, 4), (6, 13), (1, 14), (2, 2), (9, 11), (5, 5), (7, 13), (15, 24), (12, 16), (15, 20), (7, 24), (5, 19), (9, 25), (2, 26), (1, 20), (6, 28), (10, 5), (14, 11)], [(0, Z), (1, Z), (8, 25), (4, 5), (6, 6), (14, 6), (11, 11), (14, 22), (6, 2), (4, 2), (8, 14), (1, 13), (0, 3), (5, 6), (16, 21), (16, 11), (5, 8), (12, 15), (10, 20)], [(0, Z), (2, Z), (10, 19), (7, 29), (10, 22), (2, 23), (0, 15), (4, 19), (14, 6), (13, 14), (1, 5), (12, 24), (12, 8), (1, 4), (13, 1), (14, 21), (4, 17), (3, 3), (12, 27)]] Y = [None, 0, 1, 2, 18, 5, 11, 4, 13, 26, 25, 29, 24, 7, 20, 19, 9, 12, 15] return OA_n_times_2_pow_c_from_matrix(20, 5, FiniteField(17), list(zip(*A)), Y, check=False)
def OA_17_560(): '\n Returns an OA(17,560)\n\n This OA is built in Corollary 2.2 of [Thwarts]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_17_560\n sage: OA = OA_17_560() # needs sage.rings.finite_rings sage.schemes\n sage: is_orthogonal_array(OA,17,560,2) # needs sage.rings.finite_rings sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(17,560) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF alpha = 5 beta = 4 p = 2 k = 17 m = 16 n = (p ** alpha) G = GF((p, alpha), prefix='x') G_set = sorted(G) G_to_int = {v: i for (i, v) in enumerate(G_set)} OA = [[G_to_int[(i + (x * j))] for i in G_set for j in G_set] for x in G_set[(k + 1):0:(- 1)]] OA.append([j for i in range(n) for j in range(n)]) OA.append([i for i in range(n) for j in range(n)]) elements_of_subgroup = set([x for x in G_set if (x.polynomial().degree() < beta)]) relabel = {G_to_int[v]: i for (i, v) in enumerate(elements_of_subgroup)} for x in range((p ** alpha)): if (x not in relabel): relabel[x] = None for C in OA[(- 3):]: for (i, x) in enumerate(C): C[i] = relabel[x] OA = list(zip(*OA)) return wilson_construction(OA, k, n, m, ([(p ** beta)] * 3), check=False)
def OA_11_640(): '\n Returns an OA(11,640)\n\n Published by Julian R. Abel in [Ab1995]_ (uses the fact that `640=2^7\n \\times 5` is the product of a power of `2` and a prime number).\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_11_640\n sage: OA = OA_11_640() # not tested (too long) # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,11,640,2) # not tested (too long) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(11,640) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None), (4, None), (4, None), (1, None)], [(0, None), (1, None), (2, 7), (3, 55), (4, 54), (1, 87), (0, 124), (1, 123), (4, 83), (4, 61)], [(0, None), (2, None), (4, 14), (1, 63), (3, 6), (4, 87), (1, 16), (0, 47), (1, 29), (4, 16)], [(0, None), (3, None), (1, 1), (4, 15), (2, 5), (4, 32), (4, 30), (1, 3), (0, 12), (1, 14)], [(0, None), (4, None), (3, 28), (2, 62), (1, 64), (1, 55), (4, 63), (4, 4), (1, 0), (0, 0)], [(0, None), (2, 6), (3, 8), (3, 7), (2, 12), (0, 1), (2, 6), (3, 97), (3, 45), (2, 0)], [(0, None), (3, 6), (0, 63), (1, 5), (1, 6), (2, 97), (0, 28), (2, 63), (3, 0), (3, 2)], [(0, None), (4, 6), (2, 4), (4, 65), (0, 6), (3, 68), (2, 1), (0, 14), (2, 1), (3, 0)], [(0, None), (0, 6), (4, 9), (2, None), (4, 29), (3, 15), (3, 0), (2, 1), (0, 7), (2, 4)], [(0, None), (1, 6), (1, 14), (0, 14), (3, 4), (2, 0), (3, None), (3, 4), (2, 0), (0, None)]] Y = [None, 0, 1, 2, 121, 66, 77, 78, 41, 100] return OA_n_times_2_pow_c_from_matrix(11, 7, FiniteField(5), list(zip(*A)), Y, check=False)
def OA_10_796(): '\n Returns an OA(10,796)\n\n Construction shared by Julian R. Abel, from [AC07]_:\n\n Truncate one block of a `TD(17,47)` to size `13`, then add an extra\n point. Form a block on each group plus the extra point: we obtain a\n `(796, \\{13,16,17,47,48\\})`-PBD in which only the extra point lies in\n more than one block of size `48` (and each other point lies in exactly 1\n such block).\n\n For each block `B` (of size `k` say) not containing the extra point,\n construct a `TD(10, k) - k.TD(k,1)` on `I(10) X B`. For each block `B`\n (of size `k=47` or `48`) containing the extra point, construct a\n `TD(10,k) - TD(k,1)` on `I(10) X B`, the size `1` hole being on `I(10) X\n P` where `P` is the extra point. Finally form `1` extra block of size\n `10` on `I(10) X P`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_10_796\n sage: OA = OA_10_796() # needs sage.schemes\n sage: is_orthogonal_array(OA,10,796,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(10,796) # needs sage.schemes\n True\n ' from sage.combinat.designs.orthogonal_arrays import OA_relabel from sage.combinat.designs.orthogonal_arrays import OA_from_PBD from .orthogonal_arrays import incomplete_orthogonal_array OA = orthogonal_array(17, 47) OA = OA_relabel(OA, 17, 47, blocks=[OA[0]]) PBD = [[((i * 47) + x) for (i, x) in enumerate(B) if ((x < 46) or (i < 13))] for B in OA] extra_point = 10000 PBD.extend([(list(range((i * 47), (((i + 1) * 47) - int((i >= 13))))) + [extra_point]) for i in range(17)]) rel = {v: i for (i, v) in enumerate(set(range((17 * 47))).difference([(((i + 1) * 47) - 1) for i in range(13, 17)]))} rel[extra_point] = len(rel) PBD = [[rel[x] for x in B] for B in PBD] assert (set(map(len, PBD)) == set([13, 16, 17, 47, 48])) extra_point = rel[extra_point] others = [] OA = [] span = set() iOA = {47: incomplete_orthogonal_array(10, 47, (1,)), 48: incomplete_orthogonal_array(10, 48, (1,))} for B in PBD: if (len(B) >= 47): B.sort(key=(lambda x: int((x == extra_point)))) OA.extend([[B[i] for i in BB] for BB in iOA[len(B)]]) span.update(B[:(- 1)]) else: others.append(B) OA.extend(OA_from_PBD(10, 796, others, check=False)) OA = OA[:(- 796)] for x in set(range(796)).difference(span): OA.append(([x] * 10)) return OA
def OA_10_469(): "\n Return an OA(10,469)\n\n This construction appears in [Brouwer80]_. It is based on the same technique\n used in\n :func:`~sage.combinat.designs.orthogonal_arrays_build_recursive.brouwer_separable_design`.\n\n Julian R. Abel's instructions:\n\n Brouwer notes that a cyclic `PG(2,37)` (or `(1407,38,1)`-BIBD) can be\n obtained with a base block containing `13,9,` and `16` points in each\n residue class mod 3. Thus, by reducing the `PG(2,37)` to its points\n congruent to `0 \\pmod 3` one obtains a `(469,\\{9,13,16\\})`-PBD which\n consists in 3 symmetric designs, i.e. 469 blocks of size 9, 469 blocks\n of size 13, and 469 blocks of size 16.\n\n For each block size `s`, one can build a matrix with size `s\\times 469`\n in which each block is a row, and such that each point of the PBD\n appears once per column. By multiplying a row of an `OA(9,s)-s.OA(9,1)`\n with the rows of the matrix one obtains a parallel class of a resolvable\n `OA(9,469)`.\n\n Add to this the parallel class of all blocks `(0,0,...),(1,1,...),...`\n to obtain a resolvable `OA(9,469)` equivalent to an `OA(10,469)`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_10_469\n sage: OA = OA_10_469() # long time # needs sage.schemes\n sage: is_orthogonal_array(OA,10,469,2) # long time # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(10,469) # needs sage.schemes\n True\n " from .orthogonal_arrays_build_recursive import _reorder_matrix from .orthogonal_arrays import incomplete_orthogonal_array OA = [] B = (0, 1, 27, 44, 63, 69, 102, 149, 237, 249, 395, 436, 510, 515, 525, 533, 547, 592, 665, 731, 824, 837, 848, 932, 1002, 1051, 1055, 1089, 1105, 1145, 1165, 1196, 1217, 1226, 1274, 1281, 1309, 1405) BIBD = [[((x + i) % 1407) for x in B] for i in range(1407)] PBD = [[(x // 3) for x in B if ((x % 3) == 0)] for B in BIBD] blocks = {9: [], 13: [], 16: []} for B in PBD: blocks[len(B)].append(B) for (b_size, symmetric_design) in blocks.items(): matrix = _reorder_matrix(symmetric_design) OA.extend([[B[xx] for xx in R] for R in incomplete_orthogonal_array(9, b_size, ([1] * b_size)) for B in matrix]) OA.extend([([i] * 9) for i in range(469)]) for (i, R) in enumerate(OA): R.append((i // 469)) return OA
def OA_520_plus_x(x): '\n Return an `OA(10+x,520+x)`.\n\n The construction shared by Julian R. Abel works for :func:`OA(10,520)\n <OA_10_520>`, :func:`OA(12,522) <OA_12_522>`, and :func:`OA(14,524)\n <OA_14_524>`.\n\n Let `n=520+x` and `k=10+x`. Build a `TD(17,31)`. Remove `8-x` points\n contained in a common block, add a new point `p` and create a block\n `g_i\\cup \\{p\\}` for every (possibly truncated) group `g_i`. The result\n is a `(520+x,{9+x,16,17,31,32})-PBD`. Note that all blocks of size `\\geq\n 30` only intersect on `p`, and that the unique block `B_9` of size `9`\n intersects all blocks of size `32` on one point. Now:\n\n * Build an `OA(k,16)-16.OA(k,16)` for each block of size 16\n\n * Build an `OA(k,17)-17.OA(k,17)` for each block of size 17\n\n * Build an `OA(k,31)-OA(k,1)` for each block of size 31 (with the hole on\n `p`).\n\n * Build an `OA(k,32)-2.OA(k,1)` for each block `B` of size 32 (with the\n holes on `p` and `B\\cap B_9`).\n\n * Build an `OA(k,9)` on `B_9`.\n\n Only a row `[p,p,...]` is missing from the `OA(10+x,520+x)`\n\n This construction is used in :func:`OA(10,520) <OA_10_520>`,\n :func:`OA(12,522) <OA_12_522>`, and :func:`OA(14,524) <OA_14_524>`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_520_plus_x\n sage: OA = OA_520_plus_x(0) # not tested (already tested in OA_10_520)\n sage: is_orthogonal_array(OA,10,520,2) # not tested (already tested in OA_10_520)\n True\n\n ' from .orthogonal_arrays import incomplete_orthogonal_array k = ((9 + x) + 1) OA = incomplete_orthogonal_array(17, 31, [1]) OA.append(([30] * 17)) new_point = (31 * 17) PBD = [[((i * 31) + xx) for (i, xx) in enumerate(B) if ((i < (9 + x)) or (xx < 30))] for B in OA] PBD.extend([(list(range((i * 31), (((i * 31) + 30) + bool((i < (9 + x)))))) + [new_point]) for i in range(17)]) relabel = {v: i for (i, v) in enumerate(sorted(set().union(*PBD)))} PBD = [[relabel[xx] for xx in B] for B in PBD] subdesigns = {(9 + x): orthogonal_array(k, (9 + x)), 16: incomplete_orthogonal_array(k, 16, ([1] * 16)), 17: incomplete_orthogonal_array(k, 17, ([1] * 17)), 31: incomplete_orthogonal_array(k, 31, [1]), 32: incomplete_orthogonal_array(k, 32, ([1] * 2))} OA = [] for B in PBD: OA.extend([[B[xx] for xx in R] for R in subdesigns[len(B)]]) OA.append(([relabel[new_point]] * k)) return OA
def OA_10_520(): '\n Return an OA(10,520).\n\n This design is built by the slightly more general construction\n :func:`OA_520_plus_x`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_10_520\n sage: OA = OA_10_520() # needs sage.schemes\n sage: is_orthogonal_array(OA,10,520,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(10,520) # needs sage.schemes\n True\n ' return OA_520_plus_x(0)
def OA_12_522(): '\n Return an OA(12,522)\n\n This design is built by the slightly more general construction\n :func:`OA_520_plus_x`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_12_522\n sage: OA = OA_12_522() # needs sage.schemes\n sage: is_orthogonal_array(OA,12,522,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(12,522) # needs sage.schemes\n True\n ' return OA_520_plus_x(2)
def OA_14_524(): '\n Return an OA(14,524)\n\n This design is built by the slightly more general construction\n :func:`OA_520_plus_x`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_14_524\n sage: OA = OA_14_524() # needs sage.schemes\n sage: is_orthogonal_array(OA,14,524,2) # needs sage.schemes\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(14,524) # needs sage.schemes\n True\n ' return OA_520_plus_x(4)
def OA_15_896(): '\n Returns an OA(15,896)\n\n Uses the fact that `896 = 2^7 \\times 7` is the product of a power of `2` and\n a prime number.\n\n .. SEEALSO::\n\n :func:`sage.combinat.designs.orthogonal_arrays.OA_n_times_2_pow_c_from_matrix`\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_15_896\n sage: OA = OA_15_896() # not tested (too long, ~2min) # needs sage.rings.finite_rings\n sage: is_orthogonal_array(OA,15,896,2) # not tested (too long) # needs sage.rings.finite_rings\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(15,896) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField A = [[(0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (0, None), (1, None), (4, None), (2, None), (2, None), (4, None), (1, None)], [(0, None), (1, None), (2, 17), (3, 20), (4, 49), (5, 4), (6, 59), (1, 15), (0, 114), (1, 76), (4, 106), (2, 87), (2, 118), (4, 49)], [(0, None), (2, None), (4, 2), (6, 98), (1, 53), (3, 97), (5, 123), (4, 3), (1, 32), (0, 10), (1, 45), (4, 3), (2, 1), (2, 14)], [(0, None), (3, None), (6, 16), (2, 86), (5, 102), (1, 64), (4, 69), (2, 11), (4, 55), (1, 90), (0, 115), (1, 15), (4, 7), (2, 0)], [(0, None), (4, None), (1, 4), (5, 110), (2, 51), (6, 118), (3, 8), (2, 81), (2, 79), (4, 98), (1, 2), (0, 3), (1, 7), (4, None)], [(0, None), (5, None), (3, 66), (1, 70), (6, 102), (4, 119), (2, 20), (4, 86), (2, 59), (2, 15), (4, 63), (1, 126), (0, 1), (1, 0)], [(0, None), (6, None), (5, 94), (4, 48), (3, 90), (2, 2), (1, 13), (1, 53), (4, 117), (2, 21), (2, 2), (4, 1), (1, 0), (0, 0)], [(0, None), (4, 6), (2, 21), (1, 112), (1, 36), (2, 14), (4, 60), (0, 1), (6, 64), (3, 0), (5, 31), (5, 3), (3, 3), (6, 14)], [(0, None), (5, 6), (4, 61), (4, None), (5, 108), (0, 91), (3, 10), (6, 15), (0, None), (6, 15), (3, 7), (5, 0), (5, 1), (3, 0)], [(0, None), (6, 6), (6, 107), (0, 88), (2, 12), (5, 44), (2, 31), (3, 64), (6, 0), (0, None), (6, 2), (3, 3), (5, None), (5, 0)], [(0, None), (0, 6), (1, 52), (3, 115), (6, 30), (3, 78), (1, 64), (5, 63), (3, 5), (6, None), (0, None), (6, 3), (3, 1), (5, None)], [(0, None), (1, 6), (3, 117), (6, 19), (3, 9), (1, 31), (0, 56), (5, 0), (5, 63), (3, None), (6, None), (0, None), (6, 7), (3, None)], [(0, None), (2, 6), (5, 116), (2, 3), (0, 0), (6, None), (6, 1), (3, 0), (5, 0), (5, 2), (3, None), (6, None), (0, None), (6, 0)], [(0, None), (3, 6), (0, 0), (5, 0), (4, 1), (4, None), (5, None), (6, 0), (3, 2), (5, 0), (5, None), (3, None), (6, None), (0, None)]] Y = [None, 0, 1, 2, 121, 66, 77, 78, 41, 100, 74, 118, 108, 43] return OA_n_times_2_pow_c_from_matrix(15, 7, FiniteField(7), list(zip(*A)), Y, check=False)
def OA_9_1078(): '\n Returns an OA(9,1078)\n\n This is obtained through the generalized Brouwer-van Rees\n construction. Indeed, `1078 = 89.11 + (99=9.11)` and there exists an\n `OA(9,100) - OA(9,11)`.\n\n .. NOTE::\n\n This function should be removed once\n :func:`~sage.combinat.designs.orthogonal_arrays_find_recursive.find_brouwer_van_rees_with_one_truncated_column`\n can handle all incomplete orthogonal arrays obtained through\n :func:`~sage.combinat.designs.orthogonal_arrays.incomplete_orthogonal_array`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_9_1078\n sage: OA = OA_9_1078() # not tested -- ~3s\n sage: is_orthogonal_array(OA,9,1078,2) # not tested -- ~3s\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(9,1078) # needs sage.schemes\n True\n ' return wilson_construction(None, 9, 11, 89, [[(11, 9)]])
def OA_25_1262(): "\n Returns an OA(25,1262)\n\n The construction is given in [Greig99]_. In Julian R. Abel's words:\n\n Start with a cyclic `PG(2,43)` or `(1893,44,1)`-BIBD whose base block\n contains respectively `12,13` and `19` point in the residue classes mod\n 3. In the resulting BIBD, remove one of the three classes: the result is\n a `(1262, \\{25, 31,32\\})`-PBD, from which the `OA(25,1262)` is obtained.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_25_1262\n sage: OA = OA_25_1262() # not tested -- too long\n sage: is_orthogonal_array(OA,25,1262,2) # not tested -- too long\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(25,1262) # needs sage.schemes\n True\n " from sage.combinat.designs.orthogonal_arrays import OA_from_PBD B = (0, 68, 78, 106, 227, 296, 304, 330, 354, 411, 624, 631, 636, 732, 747, 772, 794, 846, 869, 939, 948, 1011, 1015, 1031, 1135, 1171, 1188, 1206, 1217, 1219, 1220, 1261, 1306, 1349, 1370, 1400, 1461, 1480, 1517, 1714, 1768, 1827, 1833, 1866) BIBD = [[((x + i) % 1893) for x in B] for i in range(1893)] PBD = [[x for x in B if ((x % 3) < 2)] for B in BIBD] PBD = [[((2 * (x // 3)) + (x % 3)) for x in B] for B in PBD] return OA_from_PBD(25, 1262, PBD, check=False)
def OA_9_1612(): '\n Returns an OA(9,1612)\n\n This is obtained through the generalized Brouwer-van Rees\n construction. Indeed, `1612 = 89.17 + (99=9.11)` and there exists an\n `OA(9,100) - OA(9,11)`.\n\n .. NOTE::\n\n This function should be removed once\n :func:`~sage.combinat.designs.orthogonal_arrays_find_recursive.find_brouwer_van_rees_with_one_truncated_column`\n can handle all incomplete orthogonal arrays obtained through\n :func:`~sage.combinat.designs.orthogonal_arrays.incomplete_orthogonal_array`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_9_1612\n sage: OA = OA_9_1612() # not tested -- ~6s\n sage: is_orthogonal_array(OA,9,1612,2) # not tested -- ~6s\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(9,1612) # needs sage.schemes\n True\n ' return wilson_construction(None, 9, 17, 89, [[(11, 9)]])
def OA_10_1620(): '\n Returns an OA(10,1620)\n\n This is obtained through the generalized Brouwer-van Rees\n construction. Indeed, `1620 = 144.11+(36=4.9)` and there exists an\n `OA(10,153) - OA(10,9)`.\n\n .. NOTE::\n\n This function should be removed once\n :func:`~sage.combinat.designs.orthogonal_arrays_find_recursive.find_brouwer_van_rees_with_one_truncated_column`\n can handle all incomplete orthogonal arrays obtained through\n :func:`~sage.combinat.designs.orthogonal_arrays.incomplete_orthogonal_array`.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_orthogonal_array\n sage: from sage.combinat.designs.database import OA_10_1620\n sage: OA = OA_10_1620() # not tested -- ~7s\n sage: is_orthogonal_array(OA,10,1620,2) # not tested -- ~7s\n True\n\n The design is available from the general constructor::\n\n sage: designs.orthogonal_arrays.is_available(10,1620) # needs sage.schemes\n True\n ' return wilson_construction(None, 10, 11, 144, [[(9, 4)]])
def QDM_19_6_1_1_1(): '\n Return a `(19,6;1,1;1)`-quasi-difference matrix.\n\n Used to build an `OA(6,20)`\n\n Given in the Handbook III.3.49 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_19_6_1_1_1\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_19_6_1_1_1()\n sage: is_quasi_difference_matrix(M,G,6,1,1,1)\n True\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic M = [[None, 7, 13, 1, 16, 9, 2], [0, 1, 15, 7, 17, 6, 14], [0, 11, 10, 11, 5, 4, 3], [7, None, 13, 16, 1, 2, 9], [1, 0, 15, 17, 7, 14, 6], [11, 0, 10, 5, 11, 3, 4]] Mb = [] for R in zip(*M): (a, b, c, d, e, f) = R Mb.append([a, b, c, d, e, f]) Mb.append([b, c, a, f, d, e]) Mb.append([c, a, b, e, f, d]) return (AdditiveCyclic(19), Mb)
def QDM_21_5_1_1_1(): '\n Return a `(21,5;1,1;1)`-quasi-difference matrix.\n\n Used to build an `OA(5,22)`\n\n Given in the Handbook III.3.51 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_21_5_1_1_1\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_21_5_1_1_1()\n sage: is_quasi_difference_matrix(M,G,5,1,1,1)\n True\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(21) M = [[1, 13, 18, 3, 16, 19, None], [16, 19, 1, 13, 18, 3, 0], [18, 3, 16, 19, 1, 13, 0], [6, 15, 6, 15, 6, 15, 0], [12, 9, 19, 16, 5, 2, 0]] Mb = [[0, 7, 14, None, 0], [0, 14, 7, 0, None]] for R in zip(*M): (a, b, c, d, e) = ((G(x) if (x is not None) else None) for x in R) Mb.append([a, b, c, d, e]) Mb.append([(16 * c), (None if (a is None) else (16 * a)), (16 * b), ((16 * d) + 7), ((16 * e) + 14)]) Mb.append([(4 * b), (4 * c), (None if (a is None) else (4 * a)), ((4 * d) + 14), ((4 * e) + 7)]) return (G, Mb)
def QDM_21_6_1_1_5(): '\n Return a `(21,6;1,1;5)`-quasi-difference matrix.\n\n Used to build an `OA(6,26)`\n\n Given in the Handbook III.3.53 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_21_6_1_1_5\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_21_6_1_1_5()\n sage: is_quasi_difference_matrix(M,G,6,1,1,5)\n True\n ' M = [[None, None, None, None, None], [0, 0, 0, 0, 0], [1, 6, 7, 8, 14], [3, 11, 20, 18, 10], [6, 10, 14, 1, 5], [4, 19, 5, 12, 2]] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(21) Mb = [[0, 0, 0, 0, 0, 0]] for R in zip(*M): (a, b, c, d, e, f) = R Mb.append([a, b, c, d, e, f]) Mb.append([b, c, d, e, f, a]) Mb.append([c, d, e, f, a, b]) Mb.append([d, e, f, a, b, c]) Mb.append([e, f, a, b, c, d]) Mb.append([f, a, b, c, d, e]) return (G, Mb)
def QDM_25_6_1_1_5(): '\n Return a `(25,6;1,1;5)`-quasi-difference matrix.\n\n Used to build an `OA(6,30)`\n\n Given in the Handbook III.3.55 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_25_6_1_1_5\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_25_6_1_1_5() # needs sage.modules\n sage: is_quasi_difference_matrix(M,G,6,1,1,5) # needs sage.modules\n True\n ' M = [[(0, 0), None, (0, 0), (0, 0), (0, 0), (0, 0), (0, 0)], [(0, 0), (0, 0), None, (0, 4), (0, 2), (0, 3), (0, 1)], [(0, 0), (3, 1), (3, 0), None, (4, 0), (1, 0), (2, 0)], [(0, 0), (3, 0), (0, 2), (1, 2), None, (0, 1), (0, 3)], [(0, 0), (3, 3), (1, 2), (4, 2), (2, 0), None, (0, 4)], [(0, 0), (4, 2), (2, 4), (0, 3), (2, 3), (3, 2), None]] from sage.groups.additive_abelian.additive_abelian_group import AdditiveAbelianGroup from sage.modules.free_module_element import free_module_element as vector G = AdditiveAbelianGroup([5, 5]) M = [[(None if (x is None) else G(vector(x))) for x in L] for L in M] Mb = [] for R in zip(*M): (a, b, c, d, e, f) = R for i in range(5): Mb.append([(None if (a is None) else (a + G(vector((i, i))))), (None if (b is None) else (b + G(vector(((2 * i), i))))), (None if (c is None) else (c + G(vector((i, 0))))), (None if (d is None) else (d + G(vector(((4 * i), 0))))), (None if (e is None) else (e + G(vector(((3 * i), (4 * i)))))), (None if (f is None) else (f + G(vector(((4 * i), (4 * i))))))]) return (G, Mb)
def QDM_33_6_1_1_1(): '\n Return a `(33,6;1,1;1)`-quasi-difference matrix.\n\n Used to build an `OA(6,34)`\n\n Given in the Handbook III.3.57 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_33_6_1_1_1\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_33_6_1_1_1()\n sage: is_quasi_difference_matrix(M,G,6,1,1,1)\n True\n ' M = [[None, 0, 0, 0, 0, 0], [30, 17, 10, 25, 23, 8], [22, 4, 32, 29, 28, 22], [25, 10, 20, 15, 21, 16], [0, 12, 15, 16, 32, 23], [6, 11, 18, 14, 9, 20]] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(33) Mb = [[0, 0, 0, 0, 0, 0], [1, 4, 16, 31, 25, 11], [3, 12, 15, 27, 9, 11], [10, 7, 28, 13, 19, 0], [5, 20, 14, 23, 26, None]] times4 = (lambda x: (None if (x is None) else (4 * x))) for R in zip(*M): (a, b, c, d, e, f) = ((None if (x is None) else G(x)) for x in R) for i in range(5): Mb.append([a, b, c, d, e, f]) (a, b, c, d, e, f) = map(times4, [e, a, b, c, d, f]) return (G, Mb)
def QDM_37_6_1_1_1(): '\n Return a `(37,6;1,1;1)`-quasi-difference matrix.\n\n Used to build an `OA(6,38)`\n\n Given in the Handbook III.3.60 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_37_6_1_1_1\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_37_6_1_1_1()\n sage: is_quasi_difference_matrix(M,G,6,1,1,1)\n True\n ' M = [[None, 10, 1, 2, 6, 3, 22, 5, 7, 9, 14, 18, 28], [0, 1, 10, 20, 23, 30, 35, 13, 33, 16, 29, 32, 21], [0, 26, 26, 15, 8, 4, 17, 19, 34, 12, 31, 24, 25], [10, None, 10, 6, 2, 22, 3, 7, 5, 14, 9, 28, 18], [1, 0, 26, 23, 20, 35, 30, 33, 13, 29, 16, 21, 32], [26, 0, 1, 8, 15, 17, 4, 34, 19, 31, 12, 25, 24]] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(37) Mb = [] for R in zip(*M): (a, b, c, d, e, f) = R Mb.append([a, b, c, d, e, f]) Mb.append([b, c, a, f, d, e]) Mb.append([c, a, b, e, f, d]) return (G, Mb)
def QDM_35_7_1_1_7(): '\n Return a `(35,7;1,1;7)`-quasi-difference matrix.\n\n Used to build an `OA(7,42)`\n\n As explained in the Handbook III.3.63 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_35_7_1_1_7\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_35_7_1_1_7()\n sage: is_quasi_difference_matrix(M,G,7,1,1,7)\n True\n ' M = [[None, None, None, None, None, None, None], [0, 0, 0, 0, 0, 0, 0], [18, (- 18), 11, (- 11), 5, (- 5), 4], [26, (- 26), 10, (- 10), 30, (- 30), 23], [20, (- 20), 3, (- 3), 33, (- 33), 23], [5, (- 5), 25, (- 25), 24, (- 24), 4], [17, (- 17), 4, (- 4), 22, (- 22), 0]] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(35) Mb = [] for R in zip(*M): for i in range(7): Mb.append(cyclic_shift(R, i)) return (G, Mb)
def QDM_45_7_1_1_9(): '\n Return a `(45,7;1,1;9)`-quasi-difference matrix.\n\n Used to build an `OA(7,54)`\n\n As explained in the Handbook III.3.71 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_45_7_1_1_9\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_45_7_1_1_9()\n sage: is_quasi_difference_matrix(M,G,7,1,1,9)\n True\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(45) M = [[None, None, None, None, None, None, None, None, None], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 27, 16, 7, (- 1), (- 27), (- 16), (- 7), 3], [24, 40, 1, 35, (- 24), (- 40), (- 1), (- 35), 7], [10, 30, 22, 44, (- 10), (- 30), (- 22), (- 44), 7], [5, 18, 14, 33, (- 5), (- 18), (- 14), (- 33), 3], [30, 16, 33, 27, (- 30), (- 16), (- 33), (- 27), 0]] Mb = [] for R in zip(*M): for c in range(7): Mb.append(cyclic_shift(R, c)) return (G, Mb)
def QDM_54_7_1_1_8(): '\n Return a `(54,7;1,1;8)`-quasi-difference matrix.\n\n Used to build an `OA(7,62)`\n\n As explained in the Handbook III.3.74 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_54_7_1_1_8\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_54_7_1_1_8()\n sage: is_quasi_difference_matrix(M,G,7,1,1,8)\n True\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(54) M = [[0, None, None, None, 0, None, None, None, None, None], [17, 0, 0, 0, (- 17), 0, 0, 0, 1, 11], [29, 28, 35, 23, (- 29), (- 28), (- 35), (- 23), 3, 19], [36, 50, 5, 33, (- 36), (- 50), (- 5), (- 33), 7, 33], [31, 2, 43, 30, (- 31), (- 2), (- 43), (- 30), 34, 33], [16, 47, 44, 51, (- 16), (- 47), (- 44), (- 51), 30, 19], [41, 11, 1, 17, (- 41), (- 11), (- 1), (- 17), 28, 11]] Mb = [] for R in zip(*M): for c in range(7): Mb.append(cyclic_shift(R, c)) return (G, Mb)
def QDM_57_9_1_1_8(): '\n Return a `(57,9;1,1;8)`-quasi-difference matrix.\n\n Used to build an `OA(9,65)`\n\n Construction shared by Julian R. Abel\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.database import QDM_57_9_1_1_8\n sage: from sage.combinat.designs.designs_pyx import is_quasi_difference_matrix\n sage: G,M = QDM_57_9_1_1_8() # needs sage.schemes\n sage: is_quasi_difference_matrix(M,G,9,1,1,8) # needs sage.schemes\n True\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as G B = [None, 1, 6, 7, 9, 19, 38, 42, 49] OA = orthogonal_array(9, 9, 2) M = [R for R in OA if any(((R[0] != x) for x in R))] M = [[B[x] for x in R] for R in M] M.append(([0] * 9)) return (G(57), M)
def DM_12_6_1(): '\n Return a `(12,6,1)`-difference matrix as built in [Hanani75]_.\n\n This design is Lemma 3.21 from [Hanani75]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_12_6_1\n sage: G,M = DM_12_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(12,6)\n\n REFERENCES:\n\n .. [Hanani75] Haim Hanani,\n Balanced incomplete block designs and related designs,\n :doi:`10.1016/0012-365X(75)90040-0`,\n Discrete Mathematics, Volume 11, Issue 3, 1975, Pages 255-369.\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(2).cartesian_product(AdditiveCyclic(6)) M = [[(0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0)], [(0, 0), (0, 1), (1, 0), (0, 3), (1, 2), (0, 4)], [(0, 0), (0, 2), (1, 2), (1, 0), (0, 1), (1, 5)], [(0, 0), (0, 3), (0, 2), (0, 1), (1, 5), (1, 4)], [(0, 0), (0, 4), (1, 1), (1, 3), (0, 5), (0, 2)], [(0, 0), (0, 5), (0, 1), (1, 5), (1, 3), (1, 1)], [(0, 0), (1, 0), (1, 3), (0, 2), (0, 3), (1, 2)], [(0, 0), (1, 1), (1, 5), (1, 2), (1, 4), (1, 0)], [(0, 0), (1, 2), (0, 4), (0, 5), (0, 2), (1, 3)], [(0, 0), (1, 3), (1, 4), (0, 4), (1, 1), (0, 1)], [(0, 0), (1, 4), (0, 5), (1, 1), (1, 0), (0, 3)], [(0, 0), (1, 5), (0, 3), (1, 4), (0, 4), (0, 5)]] return (G, M)
def DM_21_6_1(): '\n Return a `(21,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.50 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_21_6_1\n sage: G,M = DM_21_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(21,6) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic M = [[8, 17, 20, 2], [9, 16, 4, 15], [11, 5, 10, 6], [14, 1, 3, 13], [18, 19, 12, 7]] Mb = [[0, 0, 0, 0, 0, 0]] for (a, b, c, d, e) in zip(*M): Mb.append([a, b, c, d, e, 0]) Mb.append([b, c, d, e, a, 0]) Mb.append([c, d, e, a, b, 0]) Mb.append([d, e, a, b, c, 0]) Mb.append([e, a, b, c, d, 0]) return (AdditiveCyclic(21), Mb)
def DM_24_8_1(): '\n Return a `(24,8,1)`-difference matrix.\n\n As explained in the Handbook III.3.52 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_24_8_1\n sage: G,M = DM_24_8_1()\n sage: is_difference_matrix(M,G,8,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(24,8)\n ' M = ((((((('0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ' + '0000 0010 0100 0110 1000 1010 1100 1110 2000 2010 2100 2110 ') + '0000 0011 1001 2110 0111 2011 2111 1000 0100 1100 1101 2010 ') + '0000 1010 1011 2000 1101 2110 0001 0101 2100 2001 0111 1100 ') + '0000 0001 2010 1111 2111 2100 1101 0011 1010 2101 1000 0110 ') + '0000 1000 2001 1011 0100 1100 0110 2101 2111 0010 1111 2011 ') + '0000 1001 0111 2100 2000 0010 1110 2011 1100 1011 0101 2111 ') + '0000 1011 2101 0100 2110 1001 2000 0110 0101 1111 2011 1010 ') from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic from sage.categories.cartesian_product import cartesian_product G = cartesian_product([AdditiveCyclic(_) for _ in [2, 2, 6]]) rlabel = {((x % 2), (x % 3)): x for x in range(6)} M = [G([int(c), int(d), rlabel[(int(b), int(a))]]) for (a, b, c, d) in M.split()] M = [M[(i * 12):((i + 1) * 12)] for i in range(8)] Mb = [] for (a, b, c, d, e, f, g, h) in zip(*M): Mb.append([a, b, c, d, e, f, g, h]) Mb.append([(a + G([0, 0, rlabel[(0, 0)]])), (b + G([0, 1, rlabel[(0, 0)]])), (c + G([1, 0, rlabel[(0, 0)]])), (d + G([1, 1, rlabel[(0, 0)]])), (e + G([0, 0, rlabel[(1, 0)]])), (f + G([0, 1, rlabel[(1, 0)]])), (g + G([1, 0, rlabel[(1, 0)]])), (h + G([1, 1, rlabel[(1, 0)]]))]) return (G, Mb)
def DM_28_6_1(): '\n Return a `(28,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.54 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_28_6_1\n sage: G,M = DM_28_6_1() # needs sage.modules\n sage: is_difference_matrix(M,G,6,1) # needs sage.modules\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(28,6) # needs sage.modules\n ' z = 2 M = [[(0, 0), ((z + 1), 6), (1, 1), (1, 1), (1, 3), (1, 4), (0, 0), (1, 4), (z, 5)], [(z, 2), (0, 0), (1, 5), (z, 1), (z, 2), (z, 6), ((z + 1), 3), (0, 0), (z, 1)], [(z, 3), ((z + 1), 4), (0, 0), ((z + 1), 5), ((z + 1), 2), ((z + 1), 4), ((z + 1), 2), (1, 6), (0, 0)], [(0, 5), (z, 6), (0, 5), (0, 6), (z, 3), (0, 0), (0, 4), (1, 5), ((z + 1), 4)], [(0, 3), (0, 3), ((z + 1), 5), (0, 0), (0, 5), ((z + 1), 6), (1, 1), (0, 1), (z, 3)], [(1, 3), (0, 6), (0, 6), (1, 5), (0, 0), (0, 3), ((z + 1), 6), (z, 2), (0, 2)]] from sage.groups.additive_abelian.additive_abelian_group import AdditiveAbelianGroup from sage.modules.free_module_element import free_module_element as vector G = AdditiveAbelianGroup([2, 2, 7]) M = [[G(vector([(x // 2), (x % 2), y])) for (x, y) in L] for L in M] Mb = [[0, 0, 0, 0, 0, 0]] for R in zip(*M): (a, b, c, d, e, f) = R Mb.append([a, b, c, d, e, f]) Mb.append([b, c, a, f, d, e]) Mb.append([c, a, b, e, f, d]) return (G, Mb)
def DM_33_6_1(): '\n Return a `(33,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.56 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_33_6_1\n sage: G,M = DM_33_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(33,6) # needs sage.rings.finite_rings\n ' M = [[0, 0, 0, 0, 0, 0], [15, 11, 22, 4, 17, 8], [19, 7, 14, 32, 22, 18], [22, 19, 8, 24, 21, 6], [9, 12, 15, 7, 26, 14], [14, 28, 23, 2, 19, 3]] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(33) Mb = [[0, 0, 0, 0, 0, 0], [1, 4, 16, 31, 25, 22], [7, 28, 13, 19, 10, 0]] for R in zip(*M): (a, b, c, d, e, f) = R for i in range(5): Mb.append([a, b, c, d, e, f]) (a, b, c, d, e, f) = ((4 * e), (4 * a), (4 * b), (4 * c), (4 * d), (4 * f)) return (G, Mb)
def DM_35_6_1(): '\n Return a `(35,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.58 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_35_6_1\n sage: G,M = DM_35_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(35,6) # needs sage.rings.finite_rings\n ' M = [[0, 15, 30, 10, 25, 1, 16, 31, 11, 26, 2, 17, 32, 12, 6, 3, 18, 33, 27, 21, 4, 19, 13, 7, 22, 5, 34, 28, 8, 23, 20, 14, 29, 9, 24], [0, 22, 16, 3, 4, 9, 10, 32, 26, 13, 18, 5, 27, 14, 15, 20, 7, 1, 23, 31, 29, 2, 24, 11, 19, 17, 25, 12, 6, 28, 33, 34, 21, 8, 30], [0, 29, 2, 31, 18, 10, 32, 26, 34, 28, 27, 21, 15, 9, 17, 30, 3, 4, 5, 20, 12, 6, 14, 22, 16, 8, 23, 24, 25, 33, 11, 19, 13, 7, 1], [0, 8, 9, 17, 11, 25, 19, 27, 28, 1, 15, 23, 31, 4, 26, 12, 6, 14, 29, 16, 2, 3, 18, 33, 34, 20, 7, 22, 30, 24, 10, 32, 5, 13, 21], [0, 1, 23, 24, 32, 33, 6, 7, 29, 30, 10, 11, 12, 13, 28, 8, 9, 31, 4, 5, 27, 14, 15, 16, 3, 25, 26, 34, 21, 22, 2, 17, 18, 19, 20], ([0] * 35)] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(35) return (G, list(zip(*M)))
def DM_36_9_1(): '\n Return a `(36,9,1)`-difference matrix.\n\n As explained in the Handbook III.3.59 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_36_9_1\n sage: G,M = DM_36_9_1() # needs sage.modules\n sage: is_difference_matrix(M,G,9,1) # needs sage.modules\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(36,9) # needs sage.modules\n ' M = [[(0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)], [(0, 0, 0, 0), (0, 1, 0, 0), (1, 0, 0, 0), (1, 1, 0, 0), (0, 0, 0, 1), (0, 1, 0, 1), (1, 0, 0, 1), (1, 1, 0, 1), (0, 0, 0, 2), (0, 1, 0, 2), (1, 0, 0, 2), (1, 1, 0, 2)], [(0, 0, 0, 0), (1, 1, 1, 2), (0, 0, 2, 1), (0, 0, 1, 2), (0, 1, 2, 0), (0, 1, 0, 2), (1, 1, 1, 1), (0, 1, 1, 1), (1, 1, 1, 0), (1, 0, 2, 2), (1, 0, 0, 1), (1, 0, 1, 0)], [(0, 0, 0, 0), (0, 0, 1, 0), (1, 0, 1, 0), (0, 1, 0, 0), (1, 1, 0, 0), (1, 0, 2, 0), (1, 0, 0, 0), (0, 1, 2, 0), (1, 1, 2, 0), (0, 0, 2, 0), (1, 1, 1, 0), (0, 1, 1, 0)], [(0, 0, 0, 0), (0, 1, 2, 0), (0, 0, 1, 0), (1, 1, 1, 0), (1, 0, 2, 0), (1, 0, 1, 0), (0, 1, 0, 0), (0, 0, 2, 0), (0, 1, 1, 0), (1, 1, 0, 0), (1, 1, 2, 0), (1, 0, 0, 0)], [(0, 0, 0, 0), (0, 1, 1, 0), (0, 1, 2, 0), (1, 1, 2, 0), (1, 1, 0, 2), (0, 0, 1, 2), (1, 1, 2, 2), (1, 0, 0, 2), (1, 0, 0, 1), (1, 0, 1, 1), (0, 0, 2, 1), (0, 1, 1, 1)], [(0, 0, 0, 0), (1, 0, 1, 0), (1, 1, 0, 1), (1, 0, 1, 2), (1, 0, 2, 2), (0, 0, 2, 1), (0, 1, 0, 1), (0, 1, 0, 0), (1, 1, 2, 2), (0, 1, 1, 0), (0, 0, 1, 2), (1, 1, 2, 1)], [(0, 0, 0, 0), (1, 1, 0, 0), (0, 1, 1, 0), (1, 0, 2, 1), (0, 1, 0, 2), (1, 0, 2, 2), (0, 0, 2, 2), (1, 1, 1, 0), (1, 0, 1, 1), (0, 1, 2, 1), (1, 1, 1, 1), (0, 0, 0, 2)], [(0, 0, 0, 0), (1, 0, 0, 0), (1, 1, 1, 0), (0, 1, 1, 2), (1, 1, 2, 1), (0, 1, 1, 1), (0, 0, 1, 1), (1, 0, 2, 0), (0, 1, 2, 2), (1, 1, 0, 2), (1, 0, 2, 2), (0, 0, 0, 1)]] from sage.groups.additive_abelian.additive_abelian_group import AdditiveAbelianGroup from sage.modules.free_module_element import free_module_element as vector G = AdditiveAbelianGroup([2, 2, 3, 3]) M = [[G(vector(x)) for x in L] for L in M] Mb = [] for R in zip(*M): (a, b, c, d, e, f, g, h, i) = R for y in range(3): Mb.append([(a + G(vector([0, 0, 0, 0]))), (b + G(vector([0, 0, y, 0]))), (c + G(vector([0, 0, (2 * y), 0]))), (d + G(vector([0, 0, 0, y]))), (e + G(vector([0, 0, 0, (2 * y)]))), (f + G(vector([0, 0, y, y]))), (g + G(vector([0, 0, (2 * y), (2 * y)]))), (h + G(vector([0, 0, y, (2 * y)]))), (i + G(vector([0, 0, (2 * y), y])))]) return (G, Mb)
def DM_39_6_1(): '\n Return a `(39,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.61 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_39_6_1\n sage: G,M = DM_39_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n The design is available from the general constructor::\n\n sage: designs.difference_matrix(39,6,existence=True) # needs sage.rings.finite_rings\n True\n ' M = [[0, 0, 0, 0, 0, 0], [4, 23, 13, 5, 12, 11], [25, 11, 22, 34, 23, 6], [13, 4, 20, 17, 15, 29], [27, 21, 8, 16, 19, 26], [16, 19, 34, 38, 26, 21]] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(39) Mb = [[0, 0, 0, 0, 0, 0], [1, 16, 22, 17, 38, 23], [(- 1), (- 16), (- 22), (- 17), (- 38), (- 23)]] for R in zip(*M): (a, b, c, d, e, f) = map(G, R) for i in range(3): Mb.append([a, b, c, d, e, f]) Mb.append([(- a), (- b), (- c), (- d), (- e), (- f)]) (a, b, c, d, e, f) = ((16 * x) for x in [c, a, b, f, d, e]) return (G, Mb)
def DM_44_6_1(): '\n Return a `(44,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.64 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_44_6_1\n sage: G,M = DM_44_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(44,6)\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic from sage.categories.cartesian_product import cartesian_product G2 = AdditiveCyclic(2) G11 = AdditiveCyclic(11) G2211 = cartesian_product((G2, G2, G11)) M = [[(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], [(1, 1, 4), (0, 1, 4), (1, 1, 7), (1, 0, 6), (1, 1, 9), (0, 1, 2), (0, 1, 5), (0, 1, 1)], [(1, 0, 6), (0, 1, 3), (1, 0, 0), (0, 1, 9), (1, 1, 1), (0, 1, 4), (1, 1, 9), (1, 0, 9)], [(1, 1, 6), (1, 1, 9), (0, 1, 2), (1, 1, 0), (0, 1, 0), (1, 1, 5), (0, 0, 4), (0, 0, 9)], [(1, 0, 9), (0, 0, 2), (0, 0, 1), (1, 0, 2), (0, 0, 7), (1, 1, 6), (1, 1, 0), (1, 0, 7)], [(1, 0, 1), (1, 0, 6), (1, 1, 3), (0, 1, 5), (0, 0, 5), (0, 1, 3), (0, 1, 0), (1, 1, 0)]] M = [[G2211(x) for x in L] for L in M] Mb = [] for R in zip(*M): for c in range(5): ((x1, y1, z1), (x2, y2, z2), (x3, y3, z3), (x4, y4, z4), (x5, y5, z5), (x6, y6, z6)) = R Mb.append(list(R)) R = [(x5, y5, (5 * z5)), (x1, y1, (5 * z1)), (x2, y2, (5 * z2)), (x3, y3, (5 * z3)), (x4, y4, (5 * z4)), (x6, y6, (5 * z6))] for (x, y, z) in [(0, 0, 0), (1, 0, 1), (1, 1, 2), (0, 0, 8)]: Mb.append([(x, y, z), (x, y, (5 * z)), (x, y, (3 * z)), (x, y, (4 * z)), (x, y, (9 * z)), (0, 0, 0)]) return (G2211, Mb)
def DM_45_7_1(): '\n Return a `(45,7,1)`-difference matrix.\n\n As explained in the Handbook III.3.65 [DesignHandbook]_.\n\n ... whose description contained a very deadly typo, kindly fixed by Julian\n R. Abel.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_45_7_1\n sage: G,M = DM_45_7_1()\n sage: is_difference_matrix(M,G,7,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(45,7) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField from sage.categories.cartesian_product import cartesian_product G533 = cartesian_product((FiniteField(5), FiniteField(3), FiniteField(3))) M = [[(0, 0, 0), (2, 2, 1), (3, 1, 1), (4, 1, 2), (4, 0, 1), (0, 1, 1), (0, 2, 1), (3, 2, 2)], [(0, 0, 0), (1, 2, 1), (4, 2, 2), (1, 2, 0), (4, 1, 0), (3, 1, 1), (3, 0, 0), (2, 1, 2)], [(0, 0, 0), (4, 1, 1), (2, 2, 1), (3, 2, 0), (1, 2, 0), (2, 1, 0), (1, 0, 0), (3, 2, 1)], [(0, 0, 0), (0, 1, 0), (2, 1, 1), (4, 0, 0), (0, 0, 2), (4, 2, 2), (3, 2, 2), (1, 2, 2)], [(0, 0, 0), (3, 1, 2), (2, 1, 0), (0, 2, 2), (4, 2, 1), (0, 2, 1), (2, 0, 1), (1, 1, 2)], [(0, 0, 0), (2, 1, 1), (1, 2, 2), (3, 0, 1), (2, 0, 1), (1, 0, 0), (4, 2, 1), (1, 1, 0)], [(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)]] for i in range(6): M[i].extend(M[(5 - i)][1:8]) M[6].extend(M[6][1:8]) Mb = [] for R in zip(*M): ((x1, y1, z1), (x2, y2, z2), (x3, y3, z3), (x4, y4, z4), (x5, y5, z5), (x6, y6, z6), (x7, y7, z7)) = R for i in range(3): Mb.append([(x1, y1, (z1 + i)), (x2, (y2 + (2 * i)), z2), (x3, (y3 + i), (z3 + (2 * i))), (x4, (y4 + (2 * i)), (z4 + i)), (x5, (y5 + i), z5), (x6, y6, (z6 + (2 * i))), (x7, y7, z7)]) return (G533, Mb)
def DM_48_9_1(): '\n Return a `(48,9,1)`-difference matrix.\n\n As explained in the Handbook III.3.67 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_48_9_1\n sage: G,M = DM_48_9_1() # needs sage.rings.finite_rings\n sage: is_difference_matrix(M,G,9,1) # needs sage.rings.finite_rings\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(48,9) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField F16 = FiniteField(16, 'x') F3 = FiniteField(3) F3F16 = F3.cartesian_product(F16) w = F16.primitive_element() assert ((w ** 4) == (w + 1)) A = [[(0, 4), (2, 2), (2, 2), (0, 13), (0, 4), (2, 13), (0, 1), (0, 7), (1, 7), (2, 2), (0, 6), (2, 9)], [(2, 7), (0, 9), (2, 7), (2, 3), (0, 3), (0, 9), (1, 12), (0, 6), (0, 12), (2, 14), (2, 7), (0, 11)], [(2, 12), (2, 12), (0, 14), (0, 14), (2, 8), (0, 8), (0, 2), (1, 2), (0, 11), (0, 1), (2, 4), (2, 12)], [(1, 3), (0, 2), (0, 10), (0, 14), (0, 9), (1, 3), (0, 12), (2, 13), (2, 1), (2, 9), (2, 0), (1, 7)], [(0, 0), (1, 8), (0, 7), (1, 8), (0, 4), (0, 14), (2, 6), (0, 2), (2, 3), (1, 12), (2, 14), (2, 5)], [(0, 12), (0, 5), (1, 13), (0, 4), (1, 13), (0, 9), (2, 8), (2, 11), (0, 7), (2, 10), (1, 2), (2, 4)], [(1, 12), (2, 0), (1, 14), (0, 6), (1, 9), (0, 14), (1, 4), (0, 5), (1, 8), (1, 3), (2, 1), (1, 1)], [(1, 4), (1, 2), (2, 5), (0, 4), (0, 11), (1, 14), (1, 13), (1, 9), (0, 10), (1, 6), (1, 8), (2, 6)], [(2, 10), (1, 9), (1, 7), (1, 4), (0, 9), (0, 1), (0, 0), (1, 3), (1, 14), (2, 11), (1, 11), (1, 13)]] A = [[F3F16((F3(a), (w ** b))) for (a, b) in L] for L in A] V = [12, 2, 7, 0, 5, 10, 3, 8, 13] Mb = [] for L in zip(*A): Mb.append(L) for u in [0, 1, 4]: Mb.append([(e + F3F16((0, (w ** (x + u))))) for (e, x) in zip(L, V)]) return (F3F16, Mb)
def DM_51_6_1(): '\n Return a `(51,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.69 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_51_6_1\n sage: G,M = DM_51_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(51,6) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(51) M = [[5, 33, 29, 30, 1], [8, 3, 47, 10, 13], [14, 27, 6, 12, 28], [9, 16, 44, 49, 11], [34, 32, 36, 26, 20]] Mb = [[0, 0, 0, 0, 0]] for R in zip(*M): for i in range(5): for RR in [list(R), [(- x) for x in R]]: Mb.append(RR) R = cyclic_shift(R, 1) for R in Mb: R.append(0) return (G, Mb)
def DM_52_6_1(): '\n Return a `(52,6,1)`-difference matrix.\n\n As explained in the Handbook III.3.70 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_52_6_1\n sage: G,M = DM_52_6_1() # needs sage.rings.finite_rings\n sage: is_difference_matrix(M,G,6,1) # needs sage.rings.finite_rings\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(52,6) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField F4 = FiniteField(4, 'z') G13 = FiniteField(13) G = F4.cartesian_product(G13) z = F4('z') assert ((z ** 2) == (z + 1)) M = [[(0, 0), (0, 0), (0, 0), (0, 0), (0, 0)], [((z ** 2), 10), (0, 7), (1, 10), (z, 10), ((z ** 2), 3)], [(z, 10), ((z ** 2), 2), (1, 11), (z, 2), ((z ** 2), 7)], [(z, 8), ((z ** 2), 12), (0, 10), ((z ** 2), 11), ((z ** 2), 6)], [(1, 2), (0, 2), ((z ** 2), 8), (z, 3), (z, 7)], [(1, 6), (z, 12), (0, 7), ((z ** 2), 6), (z, 2)]] M2 = [[(1, 1), ((z ** 2), 11)], [(z, 3), (1, 7)], [((z ** 2), 9), (z, 8)], [(1, 4), ((z ** 2), 3)], [(z, 12), (1, 9)], [((z ** 2), 10), (z, 1)]] M = [[G(x) for x in L] for L in M] M2 = [[G(x) for x in L] for L in M2] Mb = [([(0, 0)] * 6)] from itertools import product def t1(i, R): if (i > 1): return t1(1, t1((i - 1), R)) ((x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5), (x6, y6)) = R return [((z * x3), (3 * y3)), ((z * x1), (3 * y1)), ((z * x2), (3 * y2)), ((z * x6), (3 * y6)), ((z * x4), (3 * y4)), ((z * x5), (3 * y5))] def t2(i, R): if (i > 1): return t2(1, t2((i - 1), R)) ((x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5), (x6, y6)) = R return [(x3, y3), (x1, y1), (x2, y2), (x5, y5), (x6, y6), (x4, y4)] for R in zip(*M): for (c1, c2) in product([1, 2, 3], repeat=2): Mb.append(t2(c2, t1(c1, R))) for R in zip(*M2): for c2 in [1, 2, 3]: Mb.append(t2(c2, R)) return (G, Mb)
def DM_55_7_1(): '\n Return a `(55,7,1)`-difference matrix.\n\n As explained in the Handbook III.3.72 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_55_7_1\n sage: G,M = DM_55_7_1()\n sage: is_difference_matrix(M,G,7,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(55,7) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(55) M = [[1, 7, 14, 19, 28, 33, 40, 46, 50], [2, 13, 25, 38, 52, 12, 20, 32, 45], [39, 6, 8, 26, 24, 51, 11, 34, 37], [54, 48, 41, 36, 27, 22, 15, 9, 5], [53, 42, 30, 17, 3, 43, 35, 23, 10], [16, 49, 47, 29, 31, 4, 44, 21, 18]] Mb = [[0, 0, 0, 0, 0, 0, 0]] for R in zip(*M): R = list(R) for c in range(6): Mb.append((cyclic_shift(R, c) + [0])) return (G, Mb)
def DM_56_8_1(): '\n Return a `(56,8,1)`-difference matrix.\n\n As explained in the Handbook III.3.73 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_56_8_1\n sage: G,M = DM_56_8_1() # needs sage.rings.finite_rings\n sage: is_difference_matrix(M,G,8,1) # needs sage.rings.finite_rings\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(56,8) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField F8 = FiniteField(8, 'z') F7 = FiniteField(7) G = F8.cartesian_product(F7) w = F8.primitive_element() assert ((w ** 3) == (w + 1)) M = [[(0, 0), ((w ** 0), 0), ((w ** 1), 0), ((w ** 2), 0), ((w ** 3), 0), ((w ** 4), 0), ((w ** 5), 0), ((w ** 6), 0)], [(0, 1), ((w ** 1), 6), ((w ** 2), 1), ((w ** 3), 1), ((w ** 4), 6), ((w ** 5), 1), ((w ** 6), 6), ((w ** 0), 6)], [(0, 4), ((w ** 2), 3), ((w ** 3), 4), ((w ** 4), 4), ((w ** 5), 3), ((w ** 6), 4), ((w ** 0), 3), ((w ** 1), 3)], [(0, 2), ((w ** 3), 5), ((w ** 4), 2), ((w ** 5), 2), ((w ** 6), 5), ((w ** 0), 2), ((w ** 1), 5), ((w ** 2), 5)], [(0, 2), ((w ** 4), 5), ((w ** 5), 2), ((w ** 6), 2), ((w ** 0), 5), ((w ** 1), 2), ((w ** 2), 5), ((w ** 3), 5)], [(0, 4), ((w ** 5), 3), ((w ** 6), 4), ((w ** 0), 4), ((w ** 1), 3), ((w ** 2), 4), ((w ** 3), 3), ((w ** 4), 3)], [(0, 1), ((w ** 6), 6), ((w ** 0), 1), ((w ** 1), 1), ((w ** 2), 6), ((w ** 3), 1), ((w ** 4), 6), ((w ** 5), 6)], [(1, 0), (1, 0), (1, 0), (1, 0), (1, 0), (1, 0), (1, 0), (1, 0)]] Mb = [] for R in zip(*M): for _ in range(7): Mb.append(R) ((x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5), (x6, y6), (x7, y7), (x8, y8)) = R R = [((w * x7), y7), ((w * x1), y1), ((w * x2), y2), ((w * x3), y3), ((w * x4), y4), ((w * x5), y5), ((w * x6), y6), ((w * x8), y8)] return (G, Mb)
def DM_57_8_1(): '\n Return a `(57,8,1)`-difference matrix.\n\n Given by Julian R. Abel.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_57_8_1\n sage: G,M = DM_57_8_1() # needs sage.rings.finite_rings sage.schemes\n sage: is_difference_matrix(M,G,8,1) # needs sage.rings.finite_rings sage.schemes\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(57,8) # needs sage.rings.finite_rings sage.schemes\n ' M = orthogonal_array(8, 8) M = [R for R in M if any(((x != R[0]) for x in R))] B = (1, 6, 7, 9, 19, 38, 42, 49) M = [[B[x] for x in R] for R in M] M.append(([0] * 8)) from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(57) return (G, M)
def DM_60_6_1(): '\n Return a `(60,6,1)`-difference matrix.\n\n As explained in [JulianAbel13]_.\n\n REFERENCES:\n\n .. [JulianAbel13] Existence of Five MOLS of Orders 18 and 60\n R. Julian R. Abel\n Journal of Combinatorial Designs\n 2013\n\n http://onlinelibrary.wiley.com/doi/10.1002/jcd.21384/abstract\n\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_60_6_1\n sage: G,M = DM_60_6_1()\n sage: is_difference_matrix(M,G,6,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(60,6)\n ' M60 = [[(0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0)], [(1, 10), (1, 6), (0, 17), (0, 7), (1, 5), (0, 9), (0, 3), (1, 13), (1, 17), (0, 13)], [(1, 22), (1, 1), (1, 8), (0, 9), (1, 21), (1, 29), (1, 0), (0, 2), (0, 12), (1, 15)], [(1, 24), (1, 1), (0, 14), (0, 0), (0, 16), (0, 18), (0, 8), (0, 28), (0, 17), (0, 7)], [(0, 17), (0, 7), (0, 20), (0, 1), (1, 4), (0, 26), (0, 19), (0, 28), (1, 21), (0, 6)], [(1, 14), (1, 9), (0, 10), (0, 27), (1, 20), (0, 11), (0, 13), (1, 12), (0, 28), (1, 18)]] from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic from sage.categories.cartesian_product import cartesian_product G = cartesian_product((AdditiveCyclic(2), AdditiveCyclic(30))) M60b = [] onezero = G((1, 0)) for R in zip(*M60): (a, b, c, d, e, f) = map(G, R) M60b.append([a, b, c, d, e, f]) M60b.append([c, a, b, e, f, d]) M60b.append([b, c, a, f, d, e]) M60b.append([(- d), (- e), (- f), ((- a) + onezero), ((- b) + onezero), ((- c) + onezero)]) M60b.append([(- e), (- f), (- d), ((- c) + onezero), ((- a) + onezero), ((- b) + onezero)]) M60b.append([(- f), (- d), (- e), ((- b) + onezero), ((- c) + onezero), ((- a) + onezero)]) return (G, M60b)
def DM_75_8_1(): '\n Return a `(75,8,1)`-difference matrix.\n\n As explained in the Handbook III.3.75 [DesignHandbook]_.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_75_8_1\n sage: G,M = DM_75_8_1()\n sage: is_difference_matrix(M,G,8,1)\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(75,8) # needs sage.rings.finite_rings\n ' from sage.rings.finite_rings.finite_field_constructor import FiniteField from sage.categories.cartesian_product import cartesian_product F3 = FiniteField(3) F5 = FiniteField(5) G = cartesian_product((F3, F5, F5)) M = [[(2, 0, 0), (0, 0, 0), (0, 0, 0), (1, 0, 0), (0, 0, 0), (1, 0, 0), (1, 0, 0), (0, 0, 0)], [(0, 2, 3), (1, 4, 4), (1, 1, 3), (1, 0, 4), (2, 4, 3), (0, 0, 3), (1, 4, 4), (0, 0, 0)], [(1, 3, 2), (2, 1, 1), (1, 4, 0), (0, 3, 0), (1, 0, 4), (2, 4, 1), (0, 1, 2), (0, 0, 0)], [(0, 2, 4), (1, 3, 1), (2, 0, 2), (0, 0, 1), (2, 4, 0), (1, 2, 2), (0, 0, 0), (0, 0, 0)], [(1, 1, 2), (2, 2, 3), (0, 3, 1), (1, 4, 2), (2, 1, 0), (1, 4, 3), (2, 4, 4), (0, 0, 0)], [(0, 1, 4), (0, 4, 4), (2, 4, 1), (1, 3, 0), (1, 3, 1), (2, 0, 0), (2, 4, 0), (0, 0, 0)], [(0, 4, 4), (2, 0, 1), (2, 3, 3), (2, 3, 2), (0, 0, 2), (2, 1, 2), (1, 4, 2), (0, 0, 0)], [(2, 4, 2), (2, 4, 1), (2, 3, 1), (1, 2, 2), (1, 3, 0), (0, 0, 2), (2, 4, 2), (0, 0, 0)]] for i in range(8): M[i].extend(M[(7 - i)][:7]) Mb = [] for R in zip(*M): for x in range(5): V = [(0, 0, x), (0, x, 0), (0, x, (2 * x)), (0, (2 * x), (2 * x)), (0, (3 * x), (3 * x)), (0, (4 * x), (3 * x)), (0, (4 * x), 0), (0, 0, (4 * x))] Mb.append([(G(e) + G(ee)) for (e, ee) in zip(R, V)]) return (G, Mb)
def DM_273_17_1(): '\n Return a `(273,17,1)`-difference matrix.\n\n Given by Julian R. Abel.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_273_17_1\n sage: G,M = DM_273_17_1() # needs sage.schemes\n sage: is_difference_matrix(M,G,17,1) # needs sage.schemes\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(273,17) # needs sage.schemes\n ' M = orthogonal_array(17, 17) M = [R for R in M if any(((x != R[0]) for x in R))] B = (1, 2, 4, 8, 16, 32, 64, 91, 117, 128, 137, 182, 195, 205, 234, 239, 256) M = [[B[x] for x in R] for R in M] M.append(([0] * 17)) from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(273) return (G, M)
def DM_993_32_1(): '\n Return a `(993,32,1)`-difference matrix.\n\n Given by Julian R. Abel.\n\n EXAMPLES::\n\n sage: from sage.combinat.designs.designs_pyx import is_difference_matrix\n sage: from sage.combinat.designs.database import DM_993_32_1\n sage: G,M = DM_993_32_1() # needs sage.schemes\n sage: is_difference_matrix(M,G,32,1) # needs sage.schemes\n True\n\n Can be obtained from the constructor::\n\n sage: _ = designs.difference_matrix(993,32) # needs sage.schemes\n ' M = orthogonal_array(32, 32) M = [R for R in M if any(((x != R[0]) for x in R))] B = (0, 74, 81, 126, 254, 282, 308, 331, 344, 375, 387, 409, 525, 563, 572, 611, 631, 661, 694, 702, 734, 763, 798, 809, 814, 851, 906, 908, 909, 923, 927, 933) M = [[B[x] for x in R] for R in M] M.append(([0] * 32)) from sage.rings.finite_rings.integer_mod_ring import IntegerModRing as AdditiveCyclic G = AdditiveCyclic(993) return (G, M)