Skip to main contentIBM Quantum Documentation
You are viewing the API reference for an old version of Qiskit SDK. Switch to latest version

DihedralUtils

DihedralUtils(num_qubits=2, group_tables=None, elmnt=None, gatelist=None, elmnt_key=None) GitHub(opens in a new tab)

Class for util functions for the CNOT-dihedral group.

Parameters

  • num_qubits (int) – number of qubits, dimension of the CNOT-dihedral object.
  • group_tables (dict) – table of all CNOTDihedral objects of a given dimension.
  • elmnt (CNOTDihedral) – a CNOT-dihedral group element.
  • elmnt_key (str) – a unique key of a CNOTDihedral object.
  • gatelist (list) – a list of gates corresponding to a CNOTDihedral object.

Methods

cnot_dihedral_gates

DihedralUtils.cnot_dihedral_gates(idx, G_table, G_keys)

Make a single CNOT-dihedral element on num_qubits.

Parameters

  • idx (int) – a unique index of a single CNOT-dihedral element.
  • G_table (dict) – the CNOT-dihedral group table on num_qubits.
  • G_keys (list) – list of keys to the CNOT-dihedral group table.

Returns

A single CNOT-dihedral element on num_qubits.

Return type

CNOTDihedral

cnot_dihedral_tables

DihedralUtils.cnot_dihedral_tables(num_qubits)

Generate a table of all CNOT-dihedral group elements on num_qubits.

Parameters

num_qubits (int) – number of qubits for the CNOTDihedral object.

Returns

A table of all CNOT-dihedral group elements

on num_qubits.

Return type

dict

compose_gates

DihedralUtils.compose_gates(elem, next_elem)

Compose two CNOTDihedral objects.

Parameters

Returns

A CNOTDihedral object, that is a composition of the two CNOTDihedral objects.

Return type

CNOTDihedral

elem_to_gates

DihedralUtils.elem_to_gates(circ)

Convert a CNOT-dihedral list of gates for the QuantumCircuit.

Parameters

circ (list) – list of gates of an element in the CNOT-dihedral group (from the group table).

Returns

List of gates for the QuantumCircuit.

Return type

list

Raises

ValueError – unknown gate type.

elmnt

DihedralUtils.elmnt()

Return a CNOTDihedral object.

elmnt_key

DihedralUtils.elmnt_key()

Return a unique key of a CNOTDihedral object.

find_inverse_gates

DihedralUtils.find_inverse_gates(num_qubits, elem)

Find the inverse of a CNOT-dihedral element.

Parameters

  • num_qubits (int) – the dimension of the CNOTDihedral element.
  • elem (CNOTDihedral) – an element in the CNOTDihedral group table.

Returns

An inverse list of gates.

Return type

list

Raises

ValueError – number of qubits bigger than 2 is not supported.

find_key

DihedralUtils.find_key(elem, num_qubits)

Find the key of a CNOTDihedral object in the group table.

Parameters

  • elem (CNOTDihedral) – CNOTDihedral object
  • num_qubits (int) – the dimension of the CNOTDihedral object.

Returns

A unique key to the CNOT-dihedral group table.

Return type

str

gatelist

DihedralUtils.gatelist()

Return a list of gates corresponding to a CNOTDihedral object.

group_tables

DihedralUtils.group_tables()

Return the CNOT-dihedral group tables.

load_dihedral_table

DihedralUtils.load_dihedral_table(picklefile='cnot_dihedral_2.pickle')

Load pickled files of the CNOT-dihedral group tables.

Parameters

picklefile (str) – pickle file name.

Returns

A table of all CNOT-dihedral group elements.

Return type

dict

load_tables

DihedralUtils.load_tables(num_qubits)

Return the CNOT dihedral group tables.

Parameters

num_qubits (int) – number of qubits for the CNOTDihedral object.

Returns

A table of all the CNOTDihedral objects.

Return type

dict

Raises

ValueError – number of qubits bigger than 2 is not supported.

num_qubits

DihedralUtils.num_qubits()

Return the number of qubits of the CNOTDihedral object.

pickle_dihedral_table

DihedralUtils.pickle_dihedral_table(num_qubits=2)

Create pickled versions of the CNOT-dihedral group tables.

Parameters

num_qubits (int) – number of qubits of the CNOTDihedral object.

Raises

ValueError – number of qubits bigger than 2 is not supported.

random_gates

DihedralUtils.random_gates(num_qubits)

Pick a random CNOT-dihedral element on num_qubits.

Parameters

num_qubits (int) – number of qubits of the CNOTDihedral object.

Returns

A CNOTDihedral object.

Return type

CNOTDihedral

Raises

ValueError – number of qubits bigger than 2 is not supported.

Was this page helpful?