Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #15310: Merged into 6.2.rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanncohen committed May 1, 2014
2 parents fc52070 + d743414 commit 3fc79ba
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/sage/combinat/designs/bibd.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def BalancedIncompleteBlockDesign(v,k,use_LJCR=False):
.. SEEALSO::
* :meth:`steiner_triple_system`
* :meth:`v_4_1_bibd`
* :func:`steiner_triple_system`
* :func:`v_4_1_BIBD`
TODO:
Expand Down Expand Up @@ -452,7 +452,7 @@ def _relabel_bibd(B,n):

def PBD_4_5_8_9_12(v, check=True):
"""
Returns a `(v,\{4,5,8,9,12\})-PBD` on `v` elements.
Returns a `(v,\{4,5,8,9,12\})`-PBD on `v` elements.
A `(v,\{4,5,8,9,12\})`-PBD exists if and only if `v\equiv 0,1 \pmod 4`. The
construction implemented here appears page 168 in [Stinson2004]_.
Expand Down
28 changes: 25 additions & 3 deletions src/sage/combinat/designs/latin_squares.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def are_mutually_orthogonal_latin_squares(l, verbose=False):
return True


def mutually_orthogonal_latin_squares(n,k=None, partitions = False):
def mutually_orthogonal_latin_squares(n,k=None, partitions = False, availability=False):
r"""
Returns `k` Mutually Orthogonal `n\times n` Latin Squares (MOLS).
Expand Down Expand Up @@ -128,6 +128,11 @@ def mutually_orthogonal_latin_squares(n,k=None, partitions = False):
partitions satisfying this intersection property instead of the `k+2` MOLS
(though the data is exactly the same in both cases).
- ``availability`` (boolean) -- if ``availability`` is set to ``True``, the
function only returns boolean answers according to whether Sage knows how
to build such a collection. This should be much faster than actually
building it.
EXAMPLES::
sage: designs.mutually_orthogonal_latin_squares(5)
Expand Down Expand Up @@ -176,6 +181,8 @@ def mutually_orthogonal_latin_squares(n,k=None, partitions = False):
Traceback (most recent call last):
...
ValueError: There exist at most n-1 MOLS of size n.
sage: designs.mutually_orthogonal_latin_squares(6,3,availability=True)
Unknown
"""
from sage.rings.finite_rings.constructor import FiniteField
from sage.combinat.designs.block_design import AffineGeometryDesign
Expand All @@ -184,9 +191,15 @@ def mutually_orthogonal_latin_squares(n,k=None, partitions = False):
from sage.rings.arith import factor

if k is not None and k >= n:
raise ValueError("There exist at most n-1 MOLS of size n.")
if availability:
return False
else:
raise ValueError("There exist at most n-1 MOLS of size n.")

if is_prime_power(n):
if availability:
return n-1 if k is None else True

if k is None:
k = n-1
# Section 6.4.1 of [Stinson2004]
Expand Down Expand Up @@ -217,8 +230,17 @@ def mutually_orthogonal_latin_squares(n,k=None, partitions = False):
s = min(subcases)-1
if k is None:
k = s
if availability:
return k
elif k > s:
raise NotImplementedError("I don't know how to build these MOLS.")
if availability:
from sage.misc.unknown import Unknown
return Unknown
else:
raise NotImplementedError("I don't know how to build these MOLS.")
elif availability:
return True

subcalls = [mutually_orthogonal_latin_squares(p,k) for p in subcases]
matrices = [latin_square_product(*[sc[i] for sc in subcalls])
for i in range(k)]
Expand Down

0 comments on commit 3fc79ba

Please sign in to comment.