Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.jl.mem
deps/deps.jl
Manifest.toml
.vscode
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, you can set up global gitignore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tip, should I revert this file?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, it's fine.

7 changes: 4 additions & 3 deletions src/arnoldi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ function arnoldi(A, b; m=min(30, size(A, 1)), ishermitian=LinearAlgebra.ishermit
n = length(b)
U = ishermitian ? real(T) : T

V = similar(A, T, (n, m + 1))
H = similar(A, U, (m+1, m))
fill!(H, zero(U))
# V stores the Krylov vectors
V = similar(b, T, (n, m + 1))
# H is a small dense array in tridiagonal form
H = zeros(U, (m+1, m))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

H will alway be Matrix if you don't use similar. Is that intended?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is intended. This matrix is usually a very small one that can be easily diagonalized on CPU.
Also, there are a lot of element-wise operations to it.


Ks = KrylovSubspace{T, U, real(T), typeof(V), typeof(H)}(m, m, false, zero(real(T)), V, H)

Expand Down
4 changes: 3 additions & 1 deletion src/krylov_phiv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ function expv!(w::AbstractVector{Complex{Tw}}, t::Complex{Tt}, Ks::KrylovSubspac
expH = exponential!(t * cache,expmethod)
expHe = @view(expH[:, 1])
end
lmul!(beta, mul!(w, @view(V[:, 1:m]), expHe)) # exp(A) ≈ norm(b) * V * exp(H)e
# `ArrayInterface.restructure` will convert the `expHe` to the target matrix type that can interact with `V`.
lmul!(beta, mul!(w, @view(V[:, 1:m]), compatible_multiplicative_operand(V, expHe))) # exp(A) ≈ norm(b) * V * exp(H)e
end

compatible_multiplicative_operand(::AbstractArray, source::AbstractArray) = source

############################
# Cache for phiv
Expand Down