qbraid_algorithms.qtran.std_gates

class qbraid_algorithms.qtran.std_gates(*args, **kwargs)

STANDARD GATES LIBRARY

Implementation of std_lib quantum gates following OpenQASM 3.0 standards.

Available Gates:

  • Single-qubit: phase, x, y, z, h, s, sdg, sx

  • Two-qubit: cx, cy, cz, cp, crx, cry, crz, swap

  • Multi-qubit: ccx (Toffoli), cswap (Fredkin)

__init__(*args, **kwargs)

Initialize standard gates library and register all gates.

Methods

__init__(*args, **kwargs)

Initialize standard gates library and register all gates.

add_gate(name, gate_def)

Add a custom gate definition to the library.

add_var(name[, assignment, qtype])

simple stub for programatically adding a variable

begin_gate(name, qargs[, params])

GATE DEFINITION

begin_if(conditional)

CONDITIONAL BLOCK

begin_loop(iterator[, ident])

LOOPS

begin_subroutine(name, parameters[, return_type])

SUBROUTINE DEFINITION

call_gate(gate, target[, controls, phases, ...])

GATE APPLICATION

call_subroutine(subroutine, parameters[, ...])

SUBROUTINE APPLICATION

close_scope()

Close the current scope block and decrease indentation level.

cnot(control, targ)

Apply CNOT gate

comment(line)

COMMENTS

controlled_op(gate_call, params[, n])

CONTROLLED OPERATIONS

cry(theta, control, targ)

Apply controlled ry gate

end_gate()

End gate definition block.

end_if()

End conditional block.

end_loop()

End loop block.

end_subroutine()

End subroutine definition block.

h(targ)

Apply Hadamard gate: creates superposition

inverse_op(gate_call, params)

INVERSE OPERATIONS

measure(qubits, clbits)

MEASUREMENT

merge(program, imports, definitions, name)

Merges data from a built library/GateBuilder into the current library bases scope :type program: :param program: Gate body which is added into definitions :type imports: :param imports: all imports the gate depends on :param gate_def: Gate definitions for any child gates/dynamic libraries used

phase(theta, targ)

Apply phase gate: !0⟩>!0⟩, !1⟩>e^(iθ)!1⟩

rx(theta, targ)

Apply rx gate

ry(theta, targ)

Apply ry gate

rz(theta, targ)

Apply rz gate

s(targ)

Apply S gate (phase): !1⟩>i!1⟩

sdg(targ)

Apply S-dagger gate (inverse phase): !1⟩>-i!1⟩

sx(targ)

Apply square root of X gate

x(targ)

Apply Pauli-X gate (bit flip): !0⟩> !1⟩, !1⟩> !0⟩

y(targ)

Apply Pauli-Y gate: !0⟩>i!1⟩, !1⟩>-i!0⟩

z(targ)

Apply Pauli-Z gate (phase flip): !0⟩> !0⟩, !1⟩>-!1⟩

Attributes

gates

name