Flattening calculation

flattening.convert_in_binary(number, bits=0)[source]

Converts an int into a string containing the number in bits.

Examples:
>>> convert_in_binary(5,3)
"101"
>>> convert_in_binary(5,5)
"00101"
Parameters:
  • number (int) – the number that is going to be converted.

  • bits (int) – the number of bits required.

Returns:

str – The converted number.

flattening.flattening_and_rank_calculation(n, T)[source]

Constructs the matrices of every flattening type.

Example:
>>> flattening_and_rank_calculation(3, [1, 0, 0, 0, 0, 0, 0, 1])
([2, 2, 2], [[array([[1, 0, 0, 0], [0, 0, 0, 1]]), array([[1, 0, 0, 0], [0, 0, 0, 1]]), array([[1, 0, 0, 0], [0, 0, 0, 1]])]])
Parameters:

n (int) – The number of qubits.

:parameter list[int] T : A list filled with the coefficients corresponding to the vector. :return: list[np.array[int]] – A list of all the matrices after all flatennings.

flattening.list_of_combinaisons(n, type_of_flattening)[source]

Realizes the possible combinations for a type of flattening.

Examples:
>>> list_of_combinaisons(5, 1)
[(1,), (2,), (3,), (4,), (5,)]
>>> list_of_combinaisons(4, 2)
[(1, 2), (1, 3), (2, 3)]
Parameters:

n (int) – The number of qubits.

:parameter int type_of_flattening : The current type of flattening. :return: list[list[int]] – The list of every possible combination.

flattening.list_of_combinaisons_for_invariant(n)[source]

Realizes the possible combinations for a type of flattening.

Example:
>>> list_of_combinaisons(4)
[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]
Parameters:

n (int) – The number of qubits.

Returns:

list[list[int]] – The list of every possible combination.

flattening.maximum_of_flattening(n)[source]
Calculates the maximum of flattening types that can be done.

If the reuslt of the calculation is a float, then, this number turns out to be the largest integer less or equal to our number.

Examples:
>>> maximum_of_flattening(4)
2
>>> maximum_of_flattening(7)
3
Parameters:

n (int) – The number of qubits.

Returns:

int – The maximum number of flattening types.

flattening.maximum_of_matrices(n, type_of_flattening)[source]
Calculates the maximum of matrices for a type of flattening.

If the type of flattening is a divider of the number of qubits, then, the first result is divided by 2.

Examples:
>>> maximum_of_matrices(2, 1)
1.0
>>> maximum_of_matrices(4, 2)
3.0
Parameters:

n (int) – The number of qubits.

:parameter int type_of_flattening : The type of flattening. :return: float – The maximum number of matrices.

flattening.putting_in_list(number)[source]

Puts every figure of the number into a list type.

Example:
>>> putting_in_list("000")
[0, 0, 0]
Parameters:

number (str) – The number to split in a string format.

Returns:

list[int] – The list with every digit of the number in a case.