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
system_parameters.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录