Quanlse/Simulator/PulseSimQCQ.py
def computationalSubspace(obj: Union[PulseModel, QHamiltonian]) -> ndarray:
    r"""
    Return the computational subspace matrix

    :param obj: input PulseModel object or QHamiltonian object

    :return: a 4-dimensions ndarray
    """
    if isinstance(obj, PulseModel):
        ham = obj.createQHamiltonian(frameMode='lab')
    elif isinstance(obj, QHamiltonian):
        ham = obj
    else:
        raise Error.ArgumentError("Pleases input a PulseModel object or a QHamiltonian object.")

    if ham.sysLevel == [3, 4, 4]:

        ham.buildCache()
        matQCQ = copy.deepcopy(ham.driftCache)

        # Decoupling coupler
        matQC1Q, unitaryC1 = fastBlockDiagonalization(mat=matQCQ, blockDim=2 * (4 ** 2))
        matQC0Q, unitaryC0 = fastBlockDiagonalization(mat=matQC1Q, blockDim=(4 ** 2))

        # Rearrange
        matQQ = rearrange(matQC0Q[:(4 ** 2), :(4 ** 2)])

        # Obtain the computation subspace matrix
        subMatrix = matQQ[:4, :4]

    else:
        raise Error.ArgumentError("Coupler (index: 0) level should be 3 and Qubit (index: 1, 2) level should be 4.")

    return subMatrix
r"""
    Return the computational subspace matrix

    :param obj: input PulseModel object or QHamiltonian object

    :return: a 4-dimensions ndarray
    
r"""
Return the computational subspace matrix
r " " " Return the computational subspace matrix
def computationalSubspace(obj: Union[PulseModel, QHamiltonian]) -> ndarray:
    if isinstance(obj, PulseModel):
        ham = obj.createQHamiltonian(frameMode='lab')
    elif isinstance(obj, QHamiltonian):
        ham = obj
    else:
        raise Error.ArgumentError("Pleases input a PulseModel object or a QHamiltonian object.")
    if ham.sysLevel == [3, 4, 4]:
        ham.buildCache()
        matQCQ = copy.deepcopy(ham.driftCache)
        matQC1Q, unitaryC1 = fastBlockDiagonalization(mat=matQCQ, blockDim=2 * (4 ** 2))
        matQC0Q, unitaryC0 = fastBlockDiagonalization(mat=matQC1Q, blockDim=(4 ** 2))
        matQQ = rearrange(matQC0Q[:(4 ** 2), :(4 ** 2)])
        subMatrix = matQQ[:4, :4]
    else:
        raise Error.ArgumentError("Coupler (index: 0) level should be 3 and Qubit (index: 1, 2) level should be 4.")
    return subMatrix
def computationalSubspace ( obj : Union [ PulseModel , QHamiltonian ] ) -> ndarray : if isinstance ( obj , PulseModel ) : ham = obj . createQHamiltonian ( frameMode = 'lab' ) elif isinstance ( obj , QHamiltonian ) : ham = obj else : raise Error . ArgumentError ( "Pleases input a PulseModel object or a QHamiltonian object." ) if ham . sysLevel == [ 3 , 4 , 4 ] : ham . buildCache ( ) matQCQ = copy . deepcopy ( ham . driftCache ) matQC1Q , unitaryC1 = fastBlockDiagonalization ( mat = matQCQ , blockDim = 2 * ( 4 ** 2 ) ) matQC0Q , unitaryC0 = fastBlockDiagonalization ( mat = matQC1Q , blockDim = ( 4 ** 2 ) ) matQQ = rearrange ( matQC0Q [ : ( 4 ** 2 ) , : ( 4 ** 2 ) ] ) subMatrix = matQQ [ : 4 , : 4 ] else : raise Error . ArgumentError ( "Coupler (index: 0) level should be 3 and Qubit (index: 1, 2) level should be 4." ) return subMatrix
r"""
Return the computational subspace matrix
r " " " Return the computational subspace matrix
r"""
    Return the computational subspace matrix

    :param obj: input PulseModel object or QHamiltonian object

    :return: a 4-dimensions ndarray
    """ # Decoupling coupler # Rearrange # Obtain the computation subspace matrix
a 4-dimensions ndarray
a 4 - dimensions ndarray
obj
Union[PulseModel, QHamiltonian]
input PulseModel object or QHamiltonian object
input PulseModel object or QHamiltonian object