Skip to content

Commit eb1722f

Browse files
committed
🏎️ Faster Lanczos
1 parent 9318d2f commit eb1722f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

β€Ždocs/src/resources/api.mdβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ spectrum_correlation_fft
248248
spectrum
249249
ExponentialSeries
250250
PseudoInverse
251+
Lanczos
251252
```
252253

253254
## [Entropy and Metrics](@id doc-API:Entropy-and-Metrics)

β€Žsrc/spectrum.jlβ€Ž

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ S(\omega) = \int_{-\infty}^\infty \lim_{t \rightarrow \infty} \left\langle \hat{
5959
See also the following list for `SpectrumSolver` docstrings:
6060
- [`ExponentialSeries`](@ref)
6161
- [`PseudoInverse`](@ref)
62+
- [`Lanczos`](@ref)
6263
"""
6364
function spectrum(
6465
H::QuantumObject{HOpType},
@@ -228,7 +229,8 @@ function _spectrum(
228229
# Loop over the Krylov subspace(s)
229230
for k in 1:solver.maxiter
230231
# k-th diagonal element
231-
Ξ±β‚– = (wβ‚– * L.data) * vβ‚–
232+
wβ‚Šβ‚ = wβ‚– * L.data
233+
Ξ±β‚– = wβ‚Šβ‚ * vβ‚–
232234

233235
# Update A(k), B(k) and continuous fraction; normalization avoids overflow
234236
Aβ‚– .= (-1im .* Ο‰List .+ Ξ±β‚–) .* A₋₁ .- (Ξ²β‚– * Ξ΄β‚–) .* Aβ‚‹β‚‚
@@ -257,8 +259,9 @@ function _spectrum(
257259

258260
# (k+1)-th left/right vectors, orthogonal to previous ones
259261
# Consider using explicit BLAS calls
260-
vβ‚Šβ‚ .= L.data * vβ‚– .- Ξ±β‚– .* vβ‚– .- Ξ²β‚– .* v₋₁
261-
wβ‚Šβ‚ .= wβ‚– * L.data .- Ξ±β‚– .* wβ‚– .- Ξ΄β‚– .* w₋₁
262+
vβ‚Šβ‚ = L.data * vβ‚–
263+
vβ‚Šβ‚ .= vβ‚Šβ‚ .- Ξ±β‚– .* vβ‚– .- Ξ²β‚– .* v₋₁
264+
wβ‚Šβ‚ .= wβ‚Šβ‚ .- Ξ±β‚– .* wβ‚– .- Ξ΄β‚– .* w₋₁
262265
v₋₁ .= vβ‚–
263266
w₋₁ .= wβ‚–
264267
vβ‚– .= vβ‚Šβ‚

0 commit comments

Comments
Β (0)