Skip to content

Commit bbbc2fe

Browse files
committed
fixed compatibility issues and missing file
1 parent 2eecea1 commit bbbc2fe

File tree

3 files changed

+71
-4
lines changed

3 files changed

+71
-4
lines changed

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ TCIITensorConversion = ["ITensors", "ITensorMPS"]
2020
[compat]
2121
BitIntegers = "0.3.5"
2222
EllipsisNotation = "1"
23-
ITensorMPS = "0.3"
24-
ITensors = "0.7, 0.8, 0.9"
23+
ITensorMPS = "0.2, 0.3"
24+
ITensors = "0.6, 0.7, 0.8, 0.9"
2525
QuadGK = "2.9"
26-
Random = "1.10.0"
26+
Random = "1.9.0"
2727
julia = "1.9"
2828

2929
[extras]
@@ -37,4 +37,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3737
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
3838

3939
[targets]
40-
test = ["Aqua", "Test", "Random", "ITensors", "Zygote", "Optim", "QuanticsGrids", "JET"]
40+
test = ["Aqua", "Test", "Random", "ITensors", "ITensorMPS", "Zygote", "Optim", "QuanticsGrids", "JET"]

docs/src/extensions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Extensions
2+
3+
This page documents extensions to [TensorCrossInterpolation](https://github.com/tensor4all/TensorCrossInterpolation.jl).
4+
5+
Currently, there is only one extension, TCIITensorConversion.
6+
7+
## TCIITensorConversion
8+
9+
Dependencies:
10+
- [ITensors.jl](https://github.com/ITensor/ITensors.jl)
11+
- [ITensorMPS.jl](https://github.com/ITensor/ITensorMPS.jl)
12+
13+
This module is automatically loaded when ITensors and ITensorMPS are present in addition to TensorCrossInterpolation. It offers conversion constructors between ITensorMPS types and TensorCrossInterpolation types, and an analogue of the [`evaluate`](@ref) function for ITensor types.
14+
15+
```@autodocs
16+
Modules = [Base.get_extension(TensorCrossInterpolation, :TCIITensorConversion)]
17+
```
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@doc raw"""
2+
function evaluate(
3+
mps::Union{ITensorMPS.MPS,ITensorMPS.MPO},
4+
indexspecs::Vararg{AbstractVector{<:Tuple{ITensorMPS.Index,Int}}}
5+
)
6+
7+
Evaluates an MPS or MPO for a given set of index values.
8+
9+
- `indexspec` is a list of tuples, where each tuple contains an `ITensorMPS.Index` object specifying an index, and an `Int` corresponding to the value of the specified index.
10+
11+
If many evaluations are necessary, it may be advantageous to convert your MPS to a [`TensorCrossInterpolation.TTCache`](@ref) object first.
12+
"""
13+
function evaluate(
14+
mps::Union{ITensorMPS.MPS,ITensorMPS.MPO},
15+
indexspecs::Vararg{AbstractVector{<:Tuple{ITensors.Index,Int}}}
16+
)
17+
if isempty(indexspecs)
18+
error("Please specify at which indices you wish to evaluate the MPS.")
19+
elseif any(length.(indexspecs) .!= length(mps))
20+
error("Need one index per MPS leg")
21+
end
22+
23+
V = ITensor(1.0)
24+
for j in eachindex(indexspecs[1])
25+
states = prod(ITensorMPS.state(spec[j]...) for spec in indexspecs)
26+
V *= mps[j] * states
27+
end
28+
return scalar(V)
29+
end
30+
@doc raw"""
31+
function evaluate(
32+
mps::Union{ITensorMPS.MPS,ITensorMPS.MPO},
33+
indices::AbstractVector{<:ITensors.Index},
34+
indexvalues::AbstractVector{Int}
35+
)
36+
37+
Evaluates an MPS or MPO for a given set of index values.
38+
39+
- `indices` is a list of `ITensors.Index` objects that specifies the order in which indices are given.
40+
- `indexvalues` is a list of integer values in the same order as `indices`.
41+
42+
If many evaluations are necessary, it may be advantageous to convert your MPS to a [`TensorCrossInterpolation.TTCache`](@ref) object first.
43+
"""
44+
function evaluate(
45+
mps::Union{ITensorMPS.MPS,ITensorMPS.MPO},
46+
indices::AbstractVector{<:ITensors.Index},
47+
indexvalues::AbstractVector{Int}
48+
)
49+
return evaluate(mps, collect(zip(indices, indexvalues)))
50+
end

0 commit comments

Comments
 (0)