qubiter.device_specific.Qubiter_to_IBMqasm module

class qubiter.device_specific.Qubiter_to_IBMqasm.Qubiter_to_IBMqasm(file_prefix, num_qbits, **kwargs)[source]

Bases: qubiter.device_specific.Qubiter_to_AnyQasm.Qubiter_to_AnyQasm

See docstring of parent class Qubiter_to_AnyQasm.

If input c_to_tars = None, all CNOTs allowed.

References

  1. https://github.com/Qiskit
__init__(file_prefix, num_qbits, **kwargs)[source]

Constructor

static qasm_line_for_rot(arr, tar_bit_pos)[source]

This function returns a string for an IBM qasm file line for a one qubit rotation.

Parameters:
  • arr (np.array) – the matrix of the rotation
  • tar_bit_pos (int) – target bit position at which rotation occurs.
Returns:

Return type:

str

use_HAD2(tar_bit_pos, controls)[source]

Writes line in IBM qasm file corresponding to an English file line of type: HAD2 with no controls.

Parameters:
  • tar_bit_pos (int) –
  • controls (Controls) –
Returns:

Return type:

None

use_NOTA(bla_str)[source]

Writes line in IBM qasm file corresponding to an English file line of type: NOTA

Parameters:bla_str (str) –
Returns:
Return type:None
use_PHAS(angle_rads, tar_bit_pos, controls)[source]

If called for a controlled phase, this function will halt execution of program. If it’s just a global phase with no controls, the function will comment the phase out in the output files (IBM qasm and output Qubiter English and Picture files.) and move on to the next line.

Parameters:
  • angle_rads (float) –
  • tar_bit_pos (int) –
  • controls (Controls) –
Returns:

Return type:

None

use_PRINT(style, line_num)[source]

Writes line in IBM qasm file corresponding to an English file line of type: PRINT

Parameters:
  • style (str) –
  • line_num (int) –
Returns:

Return type:

None

use_P_PH(projection_bit, angle_rads, tar_bit_pos, controls)[source]

Writes line in IBM qasm file corresponding to an English file line of type: P0PH or P1PH with 0 or 1 controls.

Parameters:
  • projection_bit (int) –
  • angle_rads (float) –
  • tar_bit_pos (int) –
  • controls (Controls) –
Returns:

Return type:

None

use_ROTA(axis, angle_rads, tar_bit_pos, controls)[source]

Writes line in IBM qasm file corresponding to an English file line of type: ROTX, ROTY or ROTZ with no controls.

Parameters:
  • axis (int) –
  • angle_rads (float) –
  • tar_bit_pos (int) –
  • controls (Controls) –
Returns:

Return type:

None

use_ROTN(angle_x_rads, angle_y_rads, angle_z_rads, tar_bit_pos, controls)[source]

Writes line in IBM qasm file corresponding to an English file line of type: ROTN with no controls.

Parameters:
  • angle_x_rads (float) –
  • angle_y_rads (float) –
  • angle_z_rads (float) –
  • tar_bit_pos (int) –
  • controls (Controls) –
Returns:

Return type:

None

use_SIG(axis, tar_bit_pos, controls)[source]

Writes line in IBM qasm file corresponding to an English file line of type: SIGX, SIGY or SIGZ with no controls, or else SIGX with one True control (i.e., simple CNOT).

Parameters:
  • axis (int) –
  • tar_bit_pos (int) –
  • controls (Controls) –
Returns:

Return type:

None

use_SWAP(bit1, bit2, controls)[source]

Writes line in IBM qasm file corresponding to an English file line of type: SWAP with no controls.

Parameters:
  • bit1 (int) –
  • bit2 (int) –
  • controls (Controls) –
Returns:

Return type:

None

write_ending()[source]

Writes IBM qasm ending statements after calls to use_ methods for gates.

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

Writes IBM qasm opening statements before calls to use_ methods for gates.

Returns:
Return type:None