qat.synthopline.phase_polynomials.random_phase_polynomial

qat.synthopline.phase_polynomials.random_phase_polynomial(nbqbits, nbterms, no_trivial=True)

Produces a random phase polynomial over nbqbits qbits and with support of size nbterms.

Note

The seed of the generator can be controlled using numpy’s random.seed method.

import numpy as np
from qat.synthopline.phase_polynomials import random_phase_polynomial

np.random.seed(1234)
ppol = random_phase_polynomial(10, 15)
for key, value in ppol.items():
    print(key, ":", value)
(0, 1, 0, 0, 0, 1, 1, 1, 1, 1) : 1.2033521966597658
(1, 1, 0, 0, 1, 0, 0, 1, 0, 1) : 4.294324272275401
(0, 1, 1, 1, 0, 1, 1, 0, 1, 0) : 4.8558128739121065
(1, 1, 1, 1, 0, 1, 0, 1, 1, 0) : 5.8630921783166405
(0, 0, 1, 1, 1, 0, 0, 0, 1, 1) : 5.460888444158442
(1, 1, 1, 0, 1, 0, 1, 0, 1, 0) : 1.3747113436983167
(0, 0, 0, 0, 0, 1, 1, 1, 0, 1) : 0.2975419919830728
(1, 1, 0, 1, 0, 1, 1, 0, 1, 0) : 2.0713679337660658
(1, 1, 0, 0, 0, 0, 0, 1, 1, 1) : 3.879500672799016
(1, 0, 1, 0, 1, 0, 1, 0, 1, 0) : 1.7922846408848714
(1, 0, 1, 1, 1, 1, 0, 1, 1, 1) : 2.8377906427956767
(0, 1, 0, 1, 0, 1, 1, 0, 1, 0) : 2.9633546100296067
(1, 1, 1, 0, 0, 0, 1, 0, 0, 0) : 0.03900926019963218
(0, 0, 1, 0, 0, 1, 1, 0, 0, 0) : 4.4359135278263615
(0, 1, 1, 0, 0, 1, 1, 0, 0, 1) : 0.9586430161104738
Parameters
  • nbqbits (int) – the number of qubits

  • nbterms (int) – the number of non-zero terms in the polynomial

  • no_trivial (optional, bool) – if set to True, avoid generating trivial terms (i.e global phases or 1-parities). Defaults to True.

Returns

a dictionary representing the phase polynomial

Return type

dict

Note

This method is available as an application in Qaptiva Access.