system_parameters.py 文件源码

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

项目:quantum-optimal-control 作者: SchusterLab 项目源码 文件源码
def approx_expm(self,M,exp_t, scaling_terms): 
        #approximate the exp at the beginning to estimate the number of taylor terms and scaling and squaring needed
        U=np.identity(len(M),dtype=M.dtype)
        Mt=np.identity(len(M),dtype=M.dtype)
        factorial=1.0 #for factorials

        for ii in xrange(1,exp_t):
            factorial*=ii
            Mt=np.dot(Mt,M)
            U+=Mt/((2.**float(ii*scaling_terms))*factorial) #scaling by 2**scaling_terms


        for ii in xrange(scaling_terms):
            U=np.dot(U,U) #squaring scaling times

        return U
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号