Skip to content

Commit

Permalink
[ITensors] Make sure polar preserves the input element type (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlevy authored Apr 2, 2024
1 parent ce5203b commit 7902cd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tensor_operations/matrix_decomposition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ function polar(A::ITensor, Linds...)
U, S, V = svd(A, Linds...)
u = commoninds(S, U)
v = commoninds(S, V)
δᵤᵥ′ = δ(u..., v'...)
δᵤᵥ′ = δ(eltype(A), u..., v'...)
Q = U * δᵤᵥ′ * V'
P = dag(V') * dag(δᵤᵥ′) * S * V
return Q, P, commoninds(Q, P)
Expand Down
5 changes: 5 additions & 0 deletions test/base/test_itensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,12 @@ end

@testset "Test polar decomposition of an ITensor" begin
U, P, u = polar(A, (k, l))

@test eltype(U) == eltype(A)
@test eltype(P) == eltype(A)

@test A U * P atol = atol

#Note: this is only satisfied when left dimensions
#are greater than right dimensions
UUᵀ = U * dag(prime(U, u))
Expand Down

0 comments on commit 7902cd4

Please sign in to comment.