Difference Matrices#
This module gathers code related to difference matrices. One can build those
objects (or know if they can be built) with difference_matrix()
:
sage: G,DM = designs.difference_matrix(9,5,1)
>>> from sage.all import *
>>> G,DM = designs.difference_matrix(Integer(9),Integer(5),Integer(1))
Functions#
- sage.combinat.designs.difference_matrices.difference_matrix(g, k, lmbda=1, existence=False, check=True)[source]#
Return a \((g,k,\lambda)\)-difference matrix
A matrix \(M\) is a \((g,k,\lambda)\)-difference matrix if it has size \(\lambda g\times k\), its entries belong to the group \(G\) of cardinality \(g\), and for any two rows \(R,R'\) of \(M\) and \(x\in G\) there are exactly \(\lambda\) values \(i\) such that \(R_i-R'_i=x\).
INPUT:
k
– (integer) number of columns. Ifk=None
it is set to the largest value available.g
– (integer) cardinality of the group \(G\)lmbda
– (integer; default: 1) – number of times each element of \(G\) appears as a difference.check
– (boolean) Whether to check that output is correct before returning it. As this is expected to be useless (but we are cautious guys), you may want to disable it whenever you want speed. Set toTrue
by default.existence
(boolean) – instead of building the design, return:True
– meaning that Sage knows how to build the designUnknown
– meaning that Sage does not know how to build the design, but that the design may exist (seesage.misc.unknown
).False
– meaning that the design does not exist.
Note
When
k=None
andexistence=True
the function returns an integer, i.e. the largest \(k\) such that we can build a \((g,k,\lambda)\)-DM.
EXAMPLES:
sage: G,M = designs.difference_matrix(25,10); G Finite Field in x of size 5^2 sage: designs.difference_matrix(993,None,existence=1) 32
>>> from sage.all import * >>> G,M = designs.difference_matrix(Integer(25),Integer(10)); G Finite Field in x of size 5^2 >>> designs.difference_matrix(Integer(993),None,existence=Integer(1)) 32
Here we print for each \(g\) the maximum possible \(k\) for which Sage knows how to build a \((g,k,1)\)-difference matrix:
sage: for g in range(2,30): ....: k_max = designs.difference_matrix(g=g,k=None,existence=True) ....: print("{:2} {}".format(g, k_max)) ....: _ = designs.difference_matrix(g,k_max) 2 2 3 3 4 4 5 5 6 2 7 7 8 8 9 9 10 2 11 11 12 6 13 13 14 2 15 3 16 16 17 17 18 2 19 19 20 4 21 6 22 2 23 23 24 8 25 25 26 2 27 27 28 6 29 29
>>> from sage.all import * >>> for g in range(Integer(2),Integer(30)): ... k_max = designs.difference_matrix(g=g,k=None,existence=True) ... print("{:2} {}".format(g, k_max)) ... _ = designs.difference_matrix(g,k_max) 2 2 3 3 4 4 5 5 6 2 7 7 8 8 9 9 10 2 11 11 12 6 13 13 14 2 15 3 16 16 17 17 18 2 19 19 20 4 21 6 22 2 23 23 24 8 25 25 26 2 27 27 28 6 29 29
- sage.combinat.designs.difference_matrices.difference_matrix_product(k, M1, G1, lmbda1, M2, G2, lmbda2, check=True)[source]#
Return the product of the
(G1, k, lmbda1)
and(G2, k, lmbda2)
difference matricesM1
andM2
.The result is a \((G1 \times G2, k, \lambda_1 \lambda_2)\)-difference matrix.
INPUT:
k
,lmbda1
,lmbda2
– positive integersG1
,G2
– groupsM1
,M2
–(G1, k, lmbda1)
and(G, k, lmbda2)
difference matricescheck
– boolean (default:True
); whether to check the output before it is returned
EXAMPLES:
sage: from sage.combinat.designs.difference_matrices import ( ....: difference_matrix_product, ....: is_difference_matrix) sage: G1,M1 = designs.difference_matrix(11,6) sage: G2,M2 = designs.difference_matrix(7,6) sage: G,M = difference_matrix_product(6,M1,G1,1,M2,G2,1) sage: G1 Finite Field of size 11 sage: G2 Finite Field of size 7 sage: G The Cartesian product of (Finite Field of size 11, Finite Field of size 7) sage: is_difference_matrix(M,G,6,1) True
>>> from sage.all import * >>> from sage.combinat.designs.difference_matrices import ( ... difference_matrix_product, ... is_difference_matrix) >>> G1,M1 = designs.difference_matrix(Integer(11),Integer(6)) >>> G2,M2 = designs.difference_matrix(Integer(7),Integer(6)) >>> G,M = difference_matrix_product(Integer(6),M1,G1,Integer(1),M2,G2,Integer(1)) >>> G1 Finite Field of size 11 >>> G2 Finite Field of size 7 >>> G The Cartesian product of (Finite Field of size 11, Finite Field of size 7) >>> is_difference_matrix(M,G,Integer(6),Integer(1)) True
- sage.combinat.designs.difference_matrices.find_product_decomposition(k, lmbda=1)[source]#
Try to find a product decomposition construction for difference matrices.
INPUT:
g
,k
,lmbda
– integers, parameters of the difference matrix
OUTPUT:
A pair of pairs
(g1,lmbda),(g2,lmbda2)
if Sage knows how to build \((g1,k,lmbda1)\) and \((g2,k,lmbda2)\) difference matrices andFalse
otherwise.EXAMPLES:
sage: from sage.combinat.designs.difference_matrices import find_product_decomposition sage: find_product_decomposition(77,6) ((7, 1), (11, 1)) sage: find_product_decomposition(616,7) ((7, 1), (88, 1)) sage: find_product_decomposition(24,10) False
>>> from sage.all import * >>> from sage.combinat.designs.difference_matrices import find_product_decomposition >>> find_product_decomposition(Integer(77),Integer(6)) ((7, 1), (11, 1)) >>> find_product_decomposition(Integer(616),Integer(7)) ((7, 1), (88, 1)) >>> find_product_decomposition(Integer(24),Integer(10)) False