本文整理汇总了Python中block.Block.add_operator方法的典型用法代码示例。如果您正苦于以下问题:Python Block.add_operator方法的具体用法?Python Block.add_operator怎么用?Python Block.add_operator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block.Block
的用法示例。
在下文中一共展示了Block.add_operator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_updated_block_for_site
# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import add_operator [as 别名]
def make_updated_block_for_site(transformation_matrix,
operators_to_add_to_block):
"""Make a new block for a list of operators.
Takes a dictionary of operator names and matrices and makes a new
block inserting in the `operators` block dictionary the result of
transforming the matrices in the original dictionary accoring to the
transformation matrix.
You use this function everytime you want to create a new block by
transforming the current operators to a truncated basis.
Parameters
----------
transformation_matrix : a numpy array of ndim = 2.
The transformation matrix coming from a (truncated) unitary
transformation.
operators_to_add_to_block : a dict of strings and numpy arrays of ndim = 2.
The list of operators to transform.
Returns
-------
result : a Block.
A block with the new transformed operators.
"""
cols_of_transformation_matrix = transformation_matrix.shape[1]
result = Block(cols_of_transformation_matrix)
for key in operators_to_add_to_block.keys():
result.add_operator(key)
result.operators[key] = transform_matrix(operators_to_add_to_block[key],
transformation_matrix)
return result