Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor sqrt_inv_sqrt #158

Merged
merged 25 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0679931
Move ITensorsExt to external module
JoeyT1994 Apr 5, 2024
9529c9c
Refactor apply interface, simplify.
JoeyT1994 Apr 9, 2024
dc781c7
Refactor map_ITensor to be based on Eigen
JoeyT1994 Apr 12, 2024
e2eec89
Merge remote-tracking branch 'upstream/main' into sqrt_inv_sqrt
JoeyT1994 Apr 12, 2024
cb3616a
Added testing
JoeyT1994 Apr 12, 2024
cc55807
Restored ModelHamiltonians.jl
JoeyT1994 Apr 12, 2024
6951df4
Remove utils.jl from include list
JoeyT1994 Apr 12, 2024
fc687af
Add utils.jl back into include list
JoeyT1994 Apr 12, 2024
79bc623
Merge branch 'main' into sqrt_inv_sqrt
JoeyT1994 Apr 12, 2024
5b76d34
Removed ishermitian flag
JoeyT1994 Apr 12, 2024
0dc6016
Fix Bug. Lower computational expense of test_apply.jl
JoeyT1994 Apr 12, 2024
513921b
Switch to Eigen. No regularization. Better name
JoeyT1994 Apr 15, 2024
8e15f0b
Separate logic out in map_eigvals and use default eigen inds setting
JoeyT1994 Apr 15, 2024
5d0477d
Add QNS to test of map_eigvals
JoeyT1994 Apr 15, 2024
678284f
Tidy namespace in test_itensorsextensions.jl
JoeyT1994 Apr 15, 2024
27b002b
Update test/test_itensorsextensions.jl
JoeyT1994 Apr 15, 2024
8f3f164
Update test/test_itensorsextensions.jl
JoeyT1994 Apr 15, 2024
05d6a24
Update test/test_itensorsextensions.jl
JoeyT1994 Apr 15, 2024
4ff8d77
Update test/test_itensorsextensions.jl
JoeyT1994 Apr 15, 2024
e03748b
Update test/test_itensorsextensions.jl
JoeyT1994 Apr 15, 2024
bc3e500
Update test/test_itensorsextensions.jl
JoeyT1994 Apr 15, 2024
1e99c3c
Better test names in test_itensorsextensions
JoeyT1994 Apr 15, 2024
4fa0d16
Update src/apply.jl
JoeyT1994 Apr 22, 2024
5b918fe
Check envs have ndim == 2 in apply.jl
JoeyT1994 Apr 22, 2024
80ab9fc
Update src/ITensorsExtensions/ITensorsExtensions.jl
JoeyT1994 Apr 22, 2024
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
2 changes: 1 addition & 1 deletion src/ITensorNetworks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ include("caches/beliefpropagationcache.jl")
include("contraction_tree_to_graph.jl")
include("gauging.jl")
include("utils.jl")
include("ITensorsExt/itensorutils.jl")
include("ITensorsExtensions/ITensorsExtensions.jl")
include("solvers/local_solvers/eigsolve.jl")
include("solvers/local_solvers/exponentiate.jl")
include("solvers/local_solvers/dmrg_x.jl")
Expand Down
90 changes: 0 additions & 90 deletions src/ITensorsExt/itensorutils.jl

This file was deleted.

30 changes: 20 additions & 10 deletions src/ITensorsExtensions/ITensorsExtensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ using ITensors:
map_diag,
noncommonind,
noprime,
replaceind,
replaceinds,
sim,
space,
sqrt_decomp
using ITensors.NDTensors:
Expand Down Expand Up @@ -52,16 +54,24 @@ invsqrt_diag(it::ITensor) = map_diag(inv ∘ sqrt, it)
pinv_diag(it::ITensor) = map_diag(pinv, it)
pinvsqrt_diag(it::ITensor) = map_diag(pinv ∘ sqrt, it)

function map_itensor(
f::Function, A::ITensor, lind=first(inds(A)); regularization=nothing, kwargs...
)
USV = svd(A, lind; kwargs...)
U, S, V, spec, u, v = USV
S = map_diag(s -> f(s + regularization), S)
sqrtDL, δᵤᵥ, sqrtDR = sqrt_decomp(S, u, v)
sqrtDR = denseblocks(sqrtDR) * denseblocks(δᵤᵥ)
L, R = U * sqrtDL, V * sqrtDR
return L * R
#TODO: Make this work for non-hermitian A
function eigendecomp(A::ITensor, linds, rinds; ishermitian=false, kwargs...)
@assert ishermitian
D, U = eigen(A, linds, rinds; ishermitian, kwargs...)
ul, ur = noncommonind(D, U), commonind(D, U)
Ul = replaceinds(U, vcat(rinds, ur), vcat(linds, ul))

return Ul, D, dag(U)
end

function map_eigvals(f::Function, A::ITensor, inds...; ishermitian=false, kwargs...)
if isdiag(A)
return map_diag(f, A)
end

Ul, D, Ur = eigendecomp(A, inds...; ishermitian, kwargs...)

return Ul * map_diag(f, D) * Ur
end

# Analagous to `denseblocks`.
Expand Down
Loading
Loading