Quanlse/Utils/Functions.py
def findIndex(referenceVecs: ndarray, indexKet: Union[List[ndarray], ndarray]):
    """
    Find the index of the given kets in the indexKet using inner product.

    :param referenceVecs: ndarray of reference vectors.
    :param indexKet: target ket or kets list.
    :return: list of index number.
    """
    # initialize index list
    idxList = []
    refVecList = copy.deepcopy(referenceVecs.T)

    if isinstance(indexKet, list):

        for ket in indexKet:
            innerProd = [vec for vec in refVecList @ ket]
            innerVal = max(innerProd)
            index = innerProd.index(innerVal)
            idxList.append(index)

        return idxList

    else:
        innerProd = [vec for vec in refVecList @ indexKet]
        innerVal = max(innerProd)
        index = innerProd.index(innerVal)
        return index

    Find the index of the given kets in the indexKet using inner product.

    :param referenceVecs: ndarray of reference vectors.
    :param indexKet: target ket or kets list.
    :return: list of index number.
    
Find the index of the given kets in the indexKet using inner product.
Find the index of the given kets in the indexKet using inner product .
def findIndex(referenceVecs: ndarray, indexKet: Union[List[ndarray], ndarray]):
    idxList = []
    refVecList = copy.deepcopy(referenceVecs.T)
    if isinstance(indexKet, list):
        for ket in indexKet:
            innerProd = [vec for vec in refVecList @ ket]
            innerVal = max(innerProd)
            index = innerProd.index(innerVal)
            idxList.append(index)
        return idxList
    else:
        innerProd = [vec for vec in refVecList @ indexKet]
        innerVal = max(innerProd)
        index = innerProd.index(innerVal)
        return index
def findIndex ( referenceVecs : ndarray , indexKet : Union [ List [ ndarray ] , ndarray ] ) : idxList = [ ] refVecList = copy . deepcopy ( referenceVecs . T ) if isinstance ( indexKet , list ) : for ket in indexKet : innerProd = [ vec for vec in refVecList @ ket ] innerVal = max ( innerProd ) index = innerProd . index ( innerVal ) idxList . append ( index ) return idxList else : innerProd = [ vec for vec in refVecList @ indexKet ] innerVal = max ( innerProd ) index = innerProd . index ( innerVal ) return index
Find the index of the given kets in the indexKet using inner product.
Find the index of the given kets in the indexKet using inner product .
"""
    Find the index of the given kets in the indexKet using inner product.

    :param referenceVecs: ndarray of reference vectors.
    :param indexKet: target ket or kets list.
    :return: list of index number.
    """ # initialize index list
list of index number.
list of index number .
referenceVecs
ndarray
ndarray of reference vectors.
ndarray of reference vectors .
indexKet
Union[List[ndarray], ndarray]
target ket or kets list.
target ket or kets list .