Quanlse/Utils/Benchmark.py
def stateTruthTable(unitary, qubitNum, sysLevel, initialBasisList=None, finalBasisList=None) -> ndarray:
    """
    Generate the truth table of a quantum gate contains the probability of the system being in each
    possible basis states at the end of an operation for each possible initial state.

    :param unitary: the unitary matrix
    :param qubitNum: the number of qubits
    :param sysLevel: the energy level of the system
    :param initialBasisList: the list initial basis
    :param finalBasisList: the list final basis
    :return: the population matrix
    """
    if not isinstance(sysLevel, int):
        raise ArgumentError('This function currently only supports an integer system level as input.')

    resultMatrix = []
    if initialBasisList is None:
        initialBasisList = range(sysLevel ** qubitNum)
    if finalBasisList is None:
        finalBasisList = range(sysLevel ** qubitNum)
    for state in initialBasisList:
        stateVec = basis(sysLevel ** qubitNum, state)
        stateFinalTemp = unitary @ stateVec
        probVec = []
        for index, item in enumerate(stateFinalTemp):
            if index in finalBasisList:
                probVec.append(abs(item) ** 2)
        resultMatrix.append(probVec)

    return array(resultMatrix)

    Generate the truth table of a quantum gate contains the probability of the system being in each
    possible basis states at the end of an operation for each possible initial state.

    :param unitary: the unitary matrix
    :param qubitNum: the number of qubits
    :param sysLevel: the energy level of the system
    :param initialBasisList: the list initial basis
    :param finalBasisList: the list final basis
    :return: the population matrix
    
Generate the truth table of a quantum gate contains the probability of the system being in each
possible basis states at the end of an operation for each possible initial state.
Generate the truth table of a quantum gate contains the probability of the system being in each possible basis states at the end of an operation for each possible initial state .
def stateTruthTable(unitary, qubitNum, sysLevel, initialBasisList=None, finalBasisList=None) -> ndarray:
    if not isinstance(sysLevel, int):
        raise ArgumentError('This function currently only supports an integer system level as input.')
    resultMatrix = []
    if initialBasisList is None:
        initialBasisList = range(sysLevel ** qubitNum)
    if finalBasisList is None:
        finalBasisList = range(sysLevel ** qubitNum)
    for state in initialBasisList:
        stateVec = basis(sysLevel ** qubitNum, state)
        stateFinalTemp = unitary @ stateVec
        probVec = []
        for index, item in enumerate(stateFinalTemp):
            if index in finalBasisList:
                probVec.append(abs(item) ** 2)
        resultMatrix.append(probVec)
    return array(resultMatrix)
def stateTruthTable ( unitary , qubitNum , sysLevel , initialBasisList = None , finalBasisList = None ) -> ndarray : if not isinstance ( sysLevel , int ) : raise ArgumentError ( 'This function currently only supports an integer system level as input.' ) resultMatrix = [ ] if initialBasisList is None : initialBasisList = range ( sysLevel ** qubitNum ) if finalBasisList is None : finalBasisList = range ( sysLevel ** qubitNum ) for state in initialBasisList : stateVec = basis ( sysLevel ** qubitNum , state ) stateFinalTemp = unitary @ stateVec probVec = [ ] for index , item in enumerate ( stateFinalTemp ) : if index in finalBasisList : probVec . append ( abs ( item ) ** 2 ) resultMatrix . append ( probVec ) return array ( resultMatrix )
Generate the truth table of a quantum gate contains the probability of the system being in each
possible basis states at the end of an operation for each possible initial state.
Generate the truth table of a quantum gate contains the probability of the system being in each possible basis states at the end of an operation for each possible initial state .
"""
    Generate the truth table of a quantum gate contains the probability of the system being in each
    possible basis states at the end of an operation for each possible initial state.

    :param unitary: the unitary matrix
    :param qubitNum: the number of qubits
    :param sysLevel: the energy level of the system
    :param initialBasisList: the list initial basis
    :param finalBasisList: the list final basis
    :return: the population matrix
    """
the population matrix
the population matrix
unitary
the unitary matrix
the unitary matrix
qubitNum
the number of qubits
the number of qubits
sysLevel
the energy level of the system
the energy level of the system
initialBasisList
the list initial basis
the list initial basis
finalBasisList
the list final basis
the list final basis