JoeyT1994 / ITensorNumericalAnalysis.jl

MIT License
3 stars 0 forks source link

ComplexIndexMap #40

Closed JoeyT1994 closed 2 weeks ago

JoeyT1994 commented 3 weeks ago

This PR adds the ability to use complex arguments within the library by introducing the ComplexIndexMap type.

The ComplexIndexMap works by containing an additional dictionary, in comparison to the RealIndexMap, which keeps track of whether an index is imaginary of real. The index_to_scalar function is then overloaded and will return an imaginary vs real number depending on the nature of the index.

All elementary functions now can be constructed as complex versions and this will be automatic based on whether s::IndsNetworkMap wraps a ComplexIndexMap or a RealIndexMap. Extensive testing is added and examples/construct_multidimensional_function.jl has been modified to do complex version of the functions.

Operators (such as differentiation, boundary operators etc) are not tested within this framework and currently assume the underlying IndexMap is real (maybe we should add a check for this).

Complex numbers can be accessed by calling complex_continuous_siteinds(g, args...; kwargs...) which will build an IndsNetworkMap wrapping a ComplexIndexMap. One should pass the arguments complex_continuous_siteinds(g, real_dimension_vertices::Vector{Vector{V}}, imag_dimension_vertices::Vector{Vector{V}}) to specify on which vertices of the graph g the real indices should be placed and on which vertices the imaginary indices should be placed. These nested vectors should ordered by dimension and then digit as usual.

There is complete flexibility here over the placement and multiple indices and can be placed on the same vertex, a lot of the special tensor constructors in utils.jl and polynomial_utils.jl have been modified to allow for multiple site indices.

The library has been updated to the latest version of ITensorNetworks with this PR.

This PR supercedes #32 which I will close.

@ryanlevy @ryboselm @emstoudenmire

JoeyT1994 commented 3 weeks ago

@ryanlevy I added support for complex delta functions by changing the delta_p constructor to not assume that there is only one index per vertex. With that generalization everything seems to work and I added tests

JoeyT1994 commented 2 weeks ago

@ryanlevy any further comments or ready to merge?