Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FusionTensors"
uuid = "e16ca583-1f51-4df0-8e12-57d32947d33e"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.5.1"
version = "0.5.2"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
10 changes: 8 additions & 2 deletions src/fusiontensor/base_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,20 @@ function Base.getindex(ft::FusionTensor, f1::SectorFusionTree, f2::SectorFusionT
return reshape(charge_matrix, charge_block_size(ft, f1, f2))
end

Base.imag(ft::FusionTensor{<:Real}) = ft # same object
Base.imag(ft::FusionTensor) = set_data_matrix(ft, imag(data_matrix(ft)))

Base.permutedims(ft::FusionTensor, args...) = fusiontensor_permutedims(ft, args...)

Base.real(ft::FusionTensor{<:Real}) = ft # same object
Base.real(ft::FusionTensor) = set_data_matrix(ft, real(data_matrix(ft)))

function Base.setindex!(
ft::FusionTensor, a::AbstractArray, f1::SectorFusionTree, f2::SectorFusionTree
)
return view(ft, f1, f2) .= a
end

Base.permutedims(ft::FusionTensor, args...) = fusiontensor_permutedims(ft, args...)

function Base.similar(ft::FusionTensor, T::Type)
# reuse trees_block_mapping

Expand Down
14 changes: 11 additions & 3 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,24 @@ end
@test isnothing(check_sanity(ft4))
@test eltype(ft4) == Float64

ft5 = 2.0im * ft3
ft5 = (1.0 + 2.0im) * ft3
@test codomain_axes(ft5) === codomain_axes(ft3)
@test domain_axes(ft5) === domain_axes(ft3)
@test space_isequal(codomain_axis(ft5), codomain_axis(ft3))
@test space_isequal(domain_axis(ft5), domain_axis(ft3))
@test isnothing(check_sanity(ft4))
@test eltype(ft5) == ComplexF64

ft4 = conj(ft3)
@test ft4 === ft3 # same object
@test conj(ft3) === ft3 # same object
@test real(ft3) === ft3
@test all(==(0.0), data_matrix(imag(ft3)))

@test conj(ft5) isa FusionTensor{ComplexF64,4}
@test real(ft5) isa FusionTensor{Float64,4}
@test imag(ft3) isa FusionTensor{Float64,4}
@test conj(ft5) ≈ (1.0 - 2.0im) * ft3
@test real(ft5) ≈ ft3
@test imag(ft3) ≈ 2ft3

ft6 = conj(ft5)
@test ft6 !== ft5 # different object
Expand Down
Loading