私は2つの行列を構築しました。 1つは行列指数関数を計算しますが、もう1つは計算できません。彼らは同様に構築され、同じ構造と次元を持っています。私は本当になぜ働くことができるのか分からないが、他はできない。私は下に私のコードを入れました。行列類似の2つの行列の指数指数
import numpy as np
import math as math
from scipy.sparse import csc_matrix
from scipy.sparse.linalg import *
sigmax = [[0, 1], [1, 0]]
sigmay = [[0, -1j], [1j, 0]]
sigmaz = [[1, 0], [0, -1]]
sigmaxx = np.kron(sigmax,sigmax)
sigmayy = np.kron(sigmay,sigmay)
sigmazz = np.kron(sigmaz,sigmaz)
sigmaxxyy = np.mat(sigmaxx) + np.mat(sigmayy)
N = 6
Hxxyy = 0
for i in range (0,N-2+1):
Hxxyy = np.mat(Hxxyy) + np.mat(np.kron(np.kron(np.identity(2**i),2*np.mat(sigmaxxyy)),np.identity(2**(N-i-2))))
Hxxyy = np.mat(Hxxyy) + np.mat(np.kron(np.kron(2*np.mat(sigmax),np.identity(2**(N-2))),sigmax))+np.mat(np.kron(np.kron(2*np.mat(sigmay),np.identity(2**(N-2))),sigmay))
print(expm(Hxxyy))
Hhi = 0
for j in range (0,N-1+1):
Hhi = np.mat(Hhi) + np.mat(np.kron(np.kron(np.identity(2**j),3*np.mat(sigmaz)),np.identity(2**(N-1-j))))
print(expm(Hhi))
エラーメッセージは次のとおりです。
Traceback (most recent call last):
File "new test.py", line 20, in <module>
print(expm(Hhi))
File "/Users/sherlock/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/scipy/sparse/linalg/matfuncs.py", line 582, in expm
return _expm(A, use_exact_onenorm='auto')
File "/Users/sherlock/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/scipy/sparse/linalg/matfuncs.py", line 637, in _expm
X = _fragment_2_1(X, h.A, s)
File "/Users/sherlock/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/scipy/sparse/linalg/matfuncs.py", line 755, in _fragment_2_1
X[k, k] = exp_diag[k]
ValueError: setting an array element with a sequence.
で
を交換 になるでしょうか? – VBB
@VBBエラーメッセージが追加されました。基本的に、問題はexpm(Hhi)を計算できないことです。しかし、expm(Hxxyy)はうまく動作します。 – JoeJackJessieJames