ITensor / NDTensors.jl

A Julia package for n-dimensional sparse tensors.
Apache License 2.0
27 stars 7 forks source link

supporting generic types #43

Closed GiggleLiu closed 3 years ago

GiggleLiu commented 3 years ago

Supporting generic types in ITensor. Generic types can be used for the following purpose

julia> using ITensors, TropicalNumbers

julia> it = ITensor(TropicalF64, [Index(2) for i=1:3]...)
ITensor ord=3 (dim=2|id=852) (dim=2|id=30) (dim=2|id=299)
NDTensors.Dense{Tropical{Float64},Array{Tropical{Float64},1}}

julia> it * it
ITensor ord=0
NDTensors.Dense{Tropical{Float64},Array{Tropical{Float64},1}}
GiggleLiu commented 3 years ago

@mtfishman Hi, is anyone going to review this PR?

mtfishman commented 3 years ago

@GiggleLiu, for some reason I didn't get a notification about the PR, thanks for the reminder about it. Looks good, glad it is such a minimal change. I'll merge this.

Do other operations work as well? For example, does a full DMRG run work?

GiggleLiu commented 3 years ago

No worries. I haven't tried a full DMRG. I was using it for contracting random tensor networks. I can try DMRG later.

mtfishman commented 3 years ago

Perhaps we should move to using LinearAlgebra's 5-arg mul! instead of an explicit gemm! call to make this more generic (and possibly more efficient, since hopefully for custom element types it fuses all of the operations together without temporary arrays).

No rush, thanks.