Skip to content
Trevor Grant edited this page Aug 16, 2024 · 1 revision

This section covers the usage of the Qiskit backend in the QuMat library.

Initialization

To initialize the Qiskit backend, use the initialize_backend function. This function accepts a backend_config dictionary.

from qumat.qiskit_backend import initialize_backend  
  
backend_config = {  
    'backend_options': {  
        'simulator_type': 'qasm_simulator',  
        'shots': 1024  
    }  
}  
backend = initialize_backend(backend_config)  

Creating an Empty Circuit

To create an empty circuit, use the create_empty_circuit function.

from qumat.qiskit_backend import create_empty_circuit  
  
circuit = create_empty_circuit(num_qubits=2)  

Applying Gates

To apply different quantum gates, use the following functions:

NOT Gate

from qumat.qiskit_backend import apply_not_gate  
  
apply_not_gate(circuit, qubit_index=0)  

Hadamard Gate

from qumat.qiskit_backend import apply_hadamard_gate  
  
apply_hadamard_gate(circuit, qubit_index=0)  

CNOT Gate

from qumat.qiskit_backend import apply_cnot_gate  
  
apply_cnot_gate(circuit, control_qubit_index=0, target_qubit_index=1)  

Executing the Circuit

To execute the circuit, use the execute_circuit function.

from qumat.qiskit_backend import execute_circuit  
  
result = execute_circuit(circuit, backend, backend_config)  
print(result)  

Getting the Final State Vector

To get the final state vector, use the get_final_state_vector function.

from qumat.qiskit_backend import get_final_state_vector  
  
state_vector = get_final_state_vector(circuit, backend, backend_config)  
print(state_vector)