### Navigation

- index
- modules |
- next |
- previous |
- Combinatorics »
- Designs and Incidence Structures »

# 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)

## Functions

`sage.combinat.designs.difference_matrices.``difference_matrix`(g, k, lmbda=1, existence=False, check=True)

  Return a \((g,k,\lambda)\)-difference matrix

  A matrix \(M\) is a \((g,k,\lambda)\)-difference matrix if its entries are element of a group \(G\) of cardinality \(g\), and if 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. If `k=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 to `True` by default.

  - `existence` (boolean) – instead of building the design, return:

    > - `True` – meaning that Sage knows how to build the design
    > - `Unknown` – meaning that Sage does not know how to build the design, but that the design may exist (see `sage.misc.unknown`).
    > - `False` – meaning that the design does not exist.

    Note

    When `k=None` and `existence=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

  TESTS:

      sage: designs.difference_matrix(10,12,1,existence=True)
      False
      sage: designs.difference_matrix(10,12,1)
      Traceback (most recent call last):
      ...
      EmptySetError: No (10,12,1)-Difference Matrix exists as k(=12)>g(=10)
      sage: designs.difference_matrix(10,9,1,existence=True)
      Unknown
      sage: designs.difference_matrix(10,9,1)
      Traceback (most recent call last):
      ...
      NotImplementedError: I don't know how to build a (10,9,1)-Difference Matrix!

### Navigation

- index
- modules |
- next |
- previous |
- Combinatorics »
- Designs and Incidence Structures »