Coefficients shapes

There are three format used for the algorithms:

  1. A flat list of coefficients, organized as such: \([x1,y1,z1, x2,y2, ..., xn,yn,zn, x'1,y'1,z'1, x'2,y'2, ..., x'n,y'n,z'n]\). This format is called the unpacked coefficients and is used for the QFT optimization.
  2. A list of coefficients grouped by families of operators: \([[[x1,y1,z1], [x2,y2, ..., [xn,yn,zn]], [[x'1,y'1,z'1], [x'2,y'2, ..., [x'n,y'n,z'n]]]\) in other words, you have the whole \(a\) family and the the whole \(a'\) family, and in a family, you have \(a1\), \(a2\), and so on… Each \(a\) is described by it’s three coefficients: \(x\), \(y\) and \(z\). This format is called packed coefficients and is used to easily manipulate coefficients.
  3. A list of coefficients grouped by operator: \([[x1,y1,z1], [x'1,y'1,z'1], [x2,y2,z2], [x'2,y'2,z'2], ...]\) in other words, the list is formed as such: \([a1, a'1, a2, a'2, ...]\) This format was previously used for evaluation in Qiskit, allowing for a simpler data flow. But it has the inconvenient of being less true to the maths behind all this so it has been dropped. This format is called mixed

With the functions of this module, one may switch between 1. and 2. and between 2. and 3., allowing tho switch freely between the three formats.

coefficients_format_mixed_to_packed(_a_a_prime_coeffs)[source]

Format the coefficients in the shape previously used for evaluation

Example:
>>> coefficients_format_mixed_to_packed([[1, 2, 3], [7, 8, 9], [4, 5, 6], [10, 11, 12]])                   
([[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]])
Parameters:_a_a_prime_coeffs (list[list[any]]) – List of lists of elements as described above (mixed coefficients).
Returns:tuple(list[list[any]]) – Tuple of list of list of elements (packed coefficients).
coefficients_format_packed_to_mixed(_a_coeffs, _a_prime_coeffs)[source]

Format the coefficients in the shape now used for evaluation

Example:
>>> coefficients_format_packed_to_mixed([[1,2,3],[4,5,6]], [[7,8,9],[10,11,12]])                           
[[1, 2, 3], [7, 8, 9], [4, 5, 6], [10, 11, 12]]
Parameters:_a_coeffs, _a_prime_coeffs (list[list[any]]) – Lists of lists of elements as described above (packed coefficients).
Returns:list[any] – List of list of elements (mixed coefficients).
coefficients_format_packed_to_unpacked(_a_coeffs, _a_prime_coeffs)[source]

Unpacks two lists of lists of three elements to one list of elements

Example:
>>> coefficients_format_packed_to_unpacked([[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]])
[1,2,3,4,5,6,7,8,9,10,11,12]
Parameters:_a_coeffs, _a_prime_coeffs (list[list[any]]) – Lists of lists of elements as described above (packed coefficients).
Returns:list[any] – List of elements (unpacked coefficients).
coefficients_format_unpacked_to_packed(_a_a_prime_coeffs)[source]

Packs a list of elements in two lists of lists of three elements

Example:
>>> coefficients_format_unpacked_to_packed([1,2,3,4,5,6,7,8,9,10,11,12])
([[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]])
Parameters:_a_a_prime_coeffs (list[any]) – List of elements (unpacked coefficients).
Returns:tuple[list[list[any]]] – Lists of lists of elements as described above (packed coefficients).