total_search
Outline
This function calculates the number of qubits required on the quantum circuit based on the list of products of Pauli matrices that make up the linear combination.
引数一覧
argument name |
type |
role |
|---|---|---|
ope_list |
list(elements:int) |
List of prodactions of Pauli matrices |
戻り値
np.array(bit_list).max()+1(int):
Returns the maximum target qubit index plus one. This is because qubit indices start from zero.
Python code
def total_search(ope_list):
"""
This function reads out the coefficients and Pauli matrix product information from the results of the Jordan–Wigner and Bravyi–Kitaev transformations performed using OpenFermion.
Parameters:
ope_list: the information about Pauli matrix product
Returns:
int: the number of qubits which express quantum state
"""
# Local Values
bit_list = [] # A list to store the results of the reading process for the number of qubits
app_list = "" # A temporary list to store the results of the reading process for the number of qubits
for i in range(len(ope_list) - 1):
for j in range(len(ope_list[i+1])-1):
app_switch = 0
if ope_list[i+1][j+1] == "X":
app_switch = 1
if ope_list[i+1][j+1] == "Y":
app_switch = 1
if ope_list[i+1][j+1] == "Z":
app_switch = 1
if ope_list[i+1][j+1] == "I":
app_switch = 1
if app_switch == 0:
app_list += str(ope_list[i+1][j+1])
if app_switch == 1:
bit_list.append(int(app_list))
app_list = ""
bit_list.append(int(app_list))
app_list = ""
return np.array(bit_list).max()+1
実行例
[ ]:
import numpy as np
import pitbe
[ ]:
ope = ['', 'X0X1Y2Y3', 'X0Y1Y2X3', 'Y0X1X2Y3', 'Y0Y1X2X3', 'Z0', 'Z0Z1', 'Z0Z2', 'Z0Z3', 'Z1', 'Z1Z2', 'Z1Z3', 'Z2', 'Z2Z3', 'Z3']
main = pitbe.total_search(ope)
print(main)
4