当前位置: 首页>>代码示例>>Python>>正文


Python Block.add_operator方法代码示例

本文整理汇总了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
开发者ID:chanul13,项目名称:hubbard_dimer,代码行数:34,代码来源:system.py


注:本文中的block.Block.add_operator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。