File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -126,18 +126,20 @@ function _spectrum(
126126 _tr_A = transpose (_tr) * spre (A). data
127127
128128 cache = nothing
129- I_cache = I (D^ 2 )
129+ Id = I (D^ 2 )
130+
131+ # DO the idx = 1 case
132+ ω = ωList[1 ]
133+ cache = init (LinearProblem (L. data - 1im * ω * Id, b), solver. alg, kwargs... )
134+ sol = solve! (cache)
135+ spec[1 ] = - 2 * real (dot (_tr_A, sol. u))
136+ popfirst! (ωList)
130137 for (idx, ω) in enumerate (ωList)
131- if idx == 1
132- cache = init (LinearProblem (L. data - 1im * ω * I_cache, b), solver. alg, kwargs... )
133- sol = solve! (cache)
134- else
135- cache. A = L. data - 1im * ω * I_cache
136- sol = solve! (cache)
137- end
138+ cache. A = L. data - 1im * ω * Id
139+ sol = solve! (cache)
138140
139141 # trace over the Hilbert space of system (expectation value)
140- spec[idx] = - 2 * real (dot (_tr_A, sol. u))
142+ spec[idx+ 1 ] = - 2 * real (dot (_tr_A, sol. u))
141143 end
142144
143145 return spec
You can’t perform that action at this time.
0 commit comments