當前位置: 首頁>>代碼示例>>Python>>正文


Python PauliClass.pauli_group方法代碼示例

本文整理匯總了Python中PauliClass.pauli_group方法的典型用法代碼示例。如果您正苦於以下問題:Python PauliClass.pauli_group方法的具體用法?Python PauliClass.pauli_group怎麽用?Python PauliClass.pauli_group使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PauliClass的用法示例。


在下文中一共展示了PauliClass.pauli_group方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: list

# 需要導入模塊: import PauliClass [as 別名]
# 或者: from PauliClass import pauli_group [as 別名]
    # Warning: This is inefficient for large groups!
    paulis = list(map(pc.ensure_pauli, paulis))
    
    return PauliMembershipPredicate(pc.from_generators(paulis), ignore_phase=True)
        
## TEST ##

if __name__ == "__main__":
    p = Predicate(lambda x: x > 0)
    q = Predicate(lambda x: x < 3)
    
    p_and_q = p & q
    p_or_q  = p | q
    not_p   = ~p
    
    for test in [2, 4, -1]:
        print(test, p(test), q(test), p_and_q(test), p_or_q(test), not_p(test))
        
    print(list(filter(p_and_q, list(range(-4,5)))))
    
    S = set([1, 2, 3])
    in_S = SetMembershipPredicate(S)
    
    print(list(map(in_S, list(range(-1, 5)))))
    
    print(list(filter(
        commutes_with('XX', 'ZZ') & ~in_group_generated_by('XX'),
        pc.pauli_group(2)
        )))
    
開發者ID:cgranade,項目名稱:python-quaec,代碼行數:31,代碼來源:pred.py

示例2: map

# 需要導入模塊: import PauliClass [as 別名]
# 或者: from PauliClass import pauli_group [as 別名]
    Returns a predicate that selects Pauli operators in the group generated by
    a given list of generators.
    """
    # Warning: This is inefficient for large groups!
    paulis = map(pc.ensure_pauli, paulis)

    return PauliMembershipPredicate(pc.from_generators(paulis), ignore_phase=True)


## TEST ##

if __name__ == "__main__":
    p = Predicate(lambda x: x > 0)
    q = Predicate(lambda x: x < 3)

    p_and_q = p & q
    p_or_q = p | q
    not_p = ~p

    for test in [2, 4, -1]:
        print test, p(test), q(test), p_and_q(test), p_or_q(test), not_p(test)

    print filter(p_and_q, range(-4, 5))

    S = set([1, 2, 3])
    in_S = SetMembershipPredicate(S)

    print map(in_S, range(-1, 5))

    print filter(commutes_with("XX", "ZZ") & ~in_group_generated_by("XX"), pc.pauli_group(2))
開發者ID:bcriger,項目名稱:python-quaec,代碼行數:32,代碼來源:pred.py


注:本文中的PauliClass.pauli_group方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。