I was looking at various parts of the ITensors.jl code, and I happened to notice something I really don't understand.
In the file ITensors.jl/src/physics/sitetype.jl, it seems that the more involved siteind() methods calls this space() method (and the other siteind() methods call one of these more involved ones). But the first space() method just returns nothing, and the second one seems to just call the first one. As such, I really don't know what the point of this method is.
Could someone clarify what is going on here? For convenience, I have put below the entire block of code for the siteind system. Any help on this would be greatly appreciated.
#---------------------------------------
#
# siteind system
#
#---------------------------------------
space(st::SiteType; kwargs...) = nothing
space(st::SiteType, n::Int; kwargs...) =
space(st; kwargs...)
function space_error_message(st::SiteType)
return "Overload of \"space\",\"siteind\", or \"siteinds\" functions not found for Index tag: $(tag(st))"
end
function siteind(st::SiteType; addtags = "", kwargs...)
sp = space(st; kwargs...)
isnothing(sp) && return nothing
return Index(sp, "Site, $(tag(st)), $addtags")
end
function siteind(st::SiteType, n; kwargs...)
s = siteind(st; kwargs...)
!isnothing(s) && return addtags(s, "n=$n")
sp = space(st, n; kwargs...)
isnothing(sp) && error(space_error_message(st))
return Index(sp, "Site, $(tag(st)), n=$n")
end
siteind(tag::String; kwargs...) =
siteind(SiteType(tag); kwargs...)
siteind(tag::String, n; kwargs...) =
siteind(SiteType(tag), n; kwargs...)
# Special case of `siteind` where integer (dim) provided
# instead of a tag string
siteind(d::Integer,n::Integer; kwargs...) = Index(d,"Site,n=$n")