qubiter.CktEmbedder module

class qubiter.CktEmbedder.CktEmbedder(num_qbits_bef, num_qbits_aft, bit_map=None)[source]

Bases: object

This class stores parameters for embedding a quantum circuit within a larger circuit (one with more qubits). Note that we will use the word “bit” to mean either cbits or qbits.

Variables:
  • bit_map (list[int]) – 1-1 but not onto map of range(num_qbits_bef) into range(num_qbits_aft)
  • extra_controls (Controls) – When embedding controls, these extra ones will be added to the before embedding controls
  • num_qbits_aft (int) – number of qubits after circuit embedding
  • num_qbits_bef (int) – number of qubits before circuit embedding
__init__(num_qbits_bef, num_qbits_aft, bit_map=None)[source]

Constructor

Parameters:
  • num_qbits_bef (int) –
  • num_qbits_aft (int) –
aft(bef)[source]

Returns bit_map[bef] if bit_map is list. If bit_map is None, returns input ‘bef’ untouched.

Parameters:bef (int) –
Returns:
Return type:int
static composition(emb2, emb1)[source]

Returns composite map emb2(emb1()). This entails defining a new CktEmbedder whose bit_map is the composition of the bit maps of the other two. Also, the extra controls of emb2 and emb1 must be merged and given to the composition.

Parameters:
Returns:

Return type:

CktEmbedder

get_num_new_bits()[source]

Returns num_qbits_aft - num_qbits_bef.

Returns:
Return type:int
is_identity_map()[source]

Returns True (False) if bit_map is None (list).

Returns:
Return type:bool
is_old_bit(aft)[source]

Returns True if aft is in image of bit_map and False otherwise.

Parameters:aft (int) –
Returns:
Return type:bool