exp() function in trotter gate creation giving errors

Hi there, I am trying to make trotter gates to calculate the dynamical structure factor for a model, and have encountered an error when I needed to exponentiate the terms to be included in the gates.

The error I got is for the line

Gj = exp(-im * tau / 2 * hj)

which I got from following the MPS time evolution tutorial for julia. The error I got was:

ERROR: LoadError: MethodError: no method matching exp(::NDTensors.DenseTensor{ComplexF64, 0, Tuple{}, NDTensors.Dense{ComplexF64, Vector{ComplexF64}}})

Closest candidates are:
  exp(::NDTensors.DenseTensor{ElT, N}, ::Tuple{Vararg{Int64, NL}}, ::Tuple{Vararg{Int64, NR}}; ishermitian) where {ElT, N, NL, NR}
   @ NDTensors C:\Users\.julia\packages\NDTensors\vDdB4\src\dense\linearalgebra\decompositions.jl:84
  exp(::ComplexF16)
   @ Base math.jl:1564
  exp(::Zeros.Zero)
   @ Zeros C:\Users\.julia\packages\Zeros\eEqdd\src\Zeros.jl:133
  ...

Stacktrace:
 [1] exp(A::ITensor, Linds::Tuple{}, Rinds::Tuple{}; ishermitian::Bool)
   @ ITensors C:\Users\.julia\packages\ITensors\iifFp\src\tensor_operations\matrix_algebra.jl:79
 [2] exp(A::ITensor, Linds::Tuple{}, Rinds::Tuple{})
   @ ITensors C:\Users\.julia\packages\ITensors\iifFp\src\tensor_operations\matrix_algebra.jl:39
 [3] exp(A::ITensor; kwargs::@Kwargs{})
   @ ITensors C:\Users\.julia\packages\ITensors\iifFp\src\tensor_operations\matrix_algebra.jl:86
 [4] exp(A::ITensor)
   @ ITensors C:\Users\.julia\packages\ITensors\iifFp\src\tensor_operations\matrix_algebra.jl:83
 [5] dsfOp(model_params::@NamedTuple{…}, sites::Vector{…}, tau::Float64)
   @ Main C:\Users\Desktop\PO_stuff\current_build\test\julia\site_user.jl:208
 [6] top-level scope
   @ C:\Users\Desktop\PO_stuff\current_build\test\julia\run.jl:120
 [7] include(fname::String)
   @ Base.MainInclude .\client.jl:489
 [8] top-level scope
   @ REPL[8]:1
in expression starting at C:\Users\Desktop\PO_stuff\current_build\test\julia\run.jl:6
Some type information was truncated. Use `show(err)` to see complete types.

Please help me and thanks!

Can you please provide a minimal working example? What are tau and hj?
It appears hj may be constructed incorrectly

Hi Ryan, thanks for the reply. You are right, I just found the bug to be an incorrect hj construction. I was applying both the Sz and identity on the same site. The code is working now thanks

Weird that it isn’t working. It looks like you are trying to take the exponential of a scalar because the the function call above says that there are no indices and has an order of 0. I was able to replicate the problem like this

A = ITensor(NDTensors.Dense(ComplexF32, undef, 1), ())
fill!(A, ComplexF32(1.0))
exp(NDTensors.tensor(A))

And you can solve the problem by extracting the data from the tensor like this A[]
Can you please let me know what version of ITensors.jl you are using becuase I don’t see the file src\tensor_operations\matrix_algebra.jl in the latest release. Thanks!