MPO.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:HamiltonianPy 作者: waltergu 项目源码 文件源码
def __iadd__(self,other):
        '''
        Overloaded self addition(+) operator, which supports the self addition by an instance of Opt.
        '''
        assert other.site==self.site
        if self.tag=='0':
            return other
        elif other.tag=='0':
            return self
        else:
            if self.tag==other.tag:
                self.value+=other.value
            else:
                self.value=np.array(1.0,dtype=np.find_common_type([self.value.dtype,other.value.dtype],[]))
                self.tag='%s(%s)+%s(%s)'%(self.value,self.tag,other.value,other.tag)
                self.matrix*=self.value
                self.matrix+=other.value*other.matrix
            return self
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号