qubiter.quantum_CSD_compiler.DiagUnitarySEO_writer module

class qubiter.quantum_CSD_compiler.DiagUnitarySEO_writer.DiagUnitarySEO_writer(file_prefix, emb, style, rad_angles=None, num_T_trols=0, num_F_trols=0, num_gbits=0, **kwargs)[source]

Bases: qubiter.SEO_writer.SEO_writer

A diagonal unitary (d-unitary) is square diagonal matrix whose diagonal entries are magnitude 1 complex numbers. Any d-unitary gate can be represent in an English file by a single line starting with DIAG.

This class is a child of SEO_writer. It adds to its parent class the ability to write a d-unitary gate in various styles.

When style = ‘one_line’, this class writes a d-unitary as a single line in an English file, the same away the parent class SEO_writer would write it.

When style = ‘exact’, this class writes a d-unitary as a SEO expansion occupying multiple lines of an English file. For this style, the class writes an exact expansion described in Refs. 1 and 2 below.

Actually, this class can write more than a mere d-unitary. It can write a controlled d-unitary too, meaning it can attach T or F controls to the intrinsic controls of the d-unitary. Those intrinsic controls are represented by percent signs in Picture files and by “half moon” nodes in the arxiv papers cited below. In class Controls, T controls are of kind True, F controls are of kind False, and intrinsic controls are assigned an int for kind.

It is important to note that the bits in the d-unitary being written will be in the following order, in order of increasing bit position:

  1. T controls
  2. F controls
  3. intrinsic d-unitary controls
  4. grounded bits, if any

References

1. R.R. Tucci, A Rudimentary Quantum Compiler(2cnd Ed.) https://arxiv.org/abs/quant-ph/9902062

2. R.R. Tucci, How to Compile Some NAND Formula Evaluators, https://arxiv.org/abs/0706.0479

3. R.R. Tucci, Oracular Approximation of Quantum Multiplexors and Diagonal Unitary Matrices, https://arxiv.org/abs/0901.3851

Variables:
  • num_of_F_trols (int) – The number of False controls of the controlled d-unitary.
  • num_gbits (int) – number of gbits (grounded bits). This is only needed for the oracular approximation. Grounded bits are extra ancilla bits that have been initialized to the ground state (state |0>).
  • num_of_T_trols (int) – The number of True controls of the controlled d-unitary.
  • rad_angles (list(float)) – list of angles in radians. These angles are the parameters specifying an DIAG gate. If the DIAG has N intrinsic controls, there are 2^N angles.
  • style (str) – must equal either ‘one_line’ or exact’.
__init__(file_prefix, emb, style, rad_angles=None, num_T_trols=0, num_F_trols=0, num_gbits=0, **kwargs)[source]

Constructor

Parameters:
  • file_prefix (str) –
  • emb (CktEmbedder) –
  • style (str) –
  • rad_angles (list(float)) –
  • num_T_trols (int) –
  • num_F_trols (int) –
  • num_gbits (int) –
static du_mat(rad_angles, herm_conj=False)[source]

This function returns a square numpy array whose diagonal is the component-wise exp(1j* ) of rad_angles.

Parameters:
  • rad_angles (list(float)) –
  • herm_conj (bool) – If True, uses exp(-1j*rad_angles). If False, uses exp(+1j*rad_angles)
Returns:

Return type:

np.ndarray

write()[source]

Main write function of this class. All other write functions are internal. This function writes a d-unitary in the style specified by the parameter self.style.

Returns:
Return type:None
write_exact()[source]

Writes in English file a multiple line, exact representation of the d-unitary.

Returns:
Return type:None
write_one_line()[source]

Writes in English file a one line representation of the d-unitary.

Returns:
Return type:None