本文整理汇总了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)
)))
示例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))