qubiter.quantum_CSD_compiler.MultiplexorSEO_writer module

class qubiter.quantum_CSD_compiler.MultiplexorSEO_writer.MultiplexorSEO_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 multiplexor is a matrix of the form

[ cc, ss] [-ss, cc]

where cc and ss are square diagonal matrices, both of the same dimension, satisfying cc^2 + ss^2=1.

A multiplexor gate can be represent in an English file by a single line starting with MP_Y.

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

When style = ‘one_line’, this class writes a multiplexor 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 multiplexor 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.

When style = ‘oracular’, this class writes a multiplexor as a SEO expansion occupying multiple lines of an English file. For this style, the class writes an approximation (called the “oracular approximation”) described in Ref.3 below.

Actually, this class can write more than a mere multiplexor. It can write a controlled multiplexor too, meaning it can attach T or F controls to the intrinsic controls of the multiplexor. 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 multiplexor being written will be in the following order, in order of increasing bit position:

  1. T controls
  2. F controls
  3. intrinsic multiplexor controls
  4. target bit of multiplexor
  5. 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 multiplexor
  • 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 multiplexor
  • rad_angles (list(float)) – list of angles in radians. These angles are the parameters specifying an MP_Y gate. If the MP_Y has N intrinsic controls, there are 2^N angles.
  • style (str) – must equal either ‘one_line’, exact’ or ‘oracular’.
__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 mp_mat(rad_angles, herm_conj=False)[source]

This function returns a numpy array with the multiplexor matrix

[ cc, ss] [-ss, cc]

in it, where cc (ss) is the component-wise cosine (sine) of rad_angles.

Parameters:
  • rad_angles (list(float)) –
  • herm_conj (bool) – When herm_conj=True, it uses ss = sine(-rad_angles), whereas if herm_conj=False, it uses ss = sine(+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 multiplexor 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 multiplexor.

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

Writes in English file a one line representation of the multiplexor.

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

Writes in English file a multiple line, approximate representation of the multiplexor.