qubiter.quantum_CSD_compiler.DiagUnitaryExpander module

class qubiter.quantum_CSD_compiler.DiagUnitaryExpander.DiagUnitaryExpander(file_prefix, num_qbits, style, gbit_list=None, vars_manager=None, **kwargs)[source]

Bases: qubiter.EchoingSEO_reader.EchoingSEO_reader

This class is a child of EchoingSEO_reader. The class reads any previously created Qubiter English file and it writes new English & Picture files wherein every line of the original English file that doesn’t start with DIAG (diagonal unitary, aka d-unitary) is echoed faithfully whereas lines which do start with DIAG are expanded via class DiagUnitarySEO_writer into a sequence in the style specified as input to the class constructor.

So, to expand English & Picture files that contain DIAG and MP_Y lines into just CNOTs and qubit rotations, first use this class and the analogous one for MP_Y, then use class CGateExpander.

If the input English file has in_file_prefix as file prefix, then the output English & Picture files have as file prefix in_file_prefix + ‘_X1’, assuming that ‘_X’ + str(k) for some integer k is not already the ending of in_file_prefix. If it is, then the ending is changed to ‘_X’ + str( k+1).

Variables:
  • gbit_list (list(int)|None) – Only needed for some expansion styles, this is a list of grounded bits
  • style (str) –
__init__(file_prefix, num_qbits, style, gbit_list=None, vars_manager=None, **kwargs)[source]

Constructor

Parameters:
  • file_prefix (str) –
  • num_qbits (int) –
  • style (str) –
  • gbit_list (list(int)) –
emb_for_du(controls)[source]

This is an internal function used inside the function use_DIAG(). This function returns emb, nt, nf to be used as arguments of a DiagUnitarySEO_writer that will be used to expand the DIAG line currently being considered. emb is a circuit embedder, nt is the number of T bits and nf is the number of F bits detected in the input argument ‘controls’.

Parameters:controls (Controls) – controls of the DIAG currently being considered.
Returns:
Return type:CktEmbedder, int, int
use_DIAG(controls, rad_angles)[source]

This is an override of a function in the parent class EchoingSEO_reader. This is the only use_ function of this class that doesn’t simply echo its input line. This function does most of its work inside the DiagUnitary_SEO_writer.write() function that it calls.

Parameters:
  • controls (Controls) –
  • rad_angles (list[float]) –
Returns:

Return type:

None