Hi,
I just encounter a small problem about MPO. Suppose I use a MPO to represent an operator A
and I want to divide it by a number likeA/k
. Then I have
using ITensors
let
n = 4
s = siteinds("Qubit",n)
rho = MPO(s,"Id")
rho = rho/2
end
Then I got the error
ERROR: MethodError: no method matching /(::MPO, ::Int64)
Closest candidates are:
/(::Any, ::ChainRulesCore.AbstractThunk) at C:\Users\jisut\.julia\packages\ChainRulesCore\ksvfu\src\tangent_types\thunks.jl:35
/(::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}, ::Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8}) at D:\Julia-1.7.2\share\julia\base\int.jl:93
/(::StridedArray{P}, ::Real) where P<:Dates.Period at D:\Julia-1.7.2\share\julia\stdlib\v1.7\Dates\src\deprecated.jl:44
...
But if I use
using ITensors
let
n = 4
s = siteinds("Qubit",n)
rho = MPO(s,"Id")
rho = rho *0.5
end
It seems that there is no error. Is only multiplication of MPO with a number allowed?
Thanks
miles
April 29, 2022, 4:24am
2
Yes, but probably only because we did not think to add that function. If you think it would be useful to have, please file an issue on our Github issue tracker and it would remind us to add it in the future, or you could submit a pull requst (PR) if you’d like to add this function yourself. Thanks!
1 Like
What version of ITensor are you using? That should be defined in the latest version:
julia> using ITensors
julia> s = siteinds("Qubit", 4);
julia> rho = MPO(s, "Id");
julia> rho / 2
MPO
[1] ((dim=2|id=149|"Qubit,Site,n=1")', (dim=2|id=149|"Qubit,Site,n=1"), (dim=1|id=522|"Link,l=1"))
[2] ((dim=2|id=854|"Qubit,Site,n=2")', (dim=2|id=854|"Qubit,Site,n=2"), (dim=1|id=984|"Link,l=2"), (dim=1|id=522|"Link,l=1"))
[3] ((dim=2|id=215|"Qubit,Site,n=3")', (dim=2|id=215|"Qubit,Site,n=3"), (dim=1|id=460|"Link,l=3"), (dim=1|id=984|"Link,l=2"))
[4] ((dim=2|id=689|"Qubit,Site,n=4")', (dim=2|id=689|"Qubit,Site,n=4"), (dim=1|id=460|"Link,l=3"))
julia> norm(rho)
4.0
julia> norm(rho / 2)
2.0
julia> using Pkg
julia> Pkg.status("ITensors")
Status `~/.julia/environments/v1.7/Project.toml`
[9136182c] ITensors v0.3.10
2 Likes
Oh I just found that I am still using the v0.2.15 version. I will update it to the latest version. Thanks for reminding me.
1 Like