I’ve been looking at extending functions to work with a self-defined data type. Most of them I got working no problem but I am struggling to get one of them working.
I define a type
mutable struct ImagTimeEvolution{N,Tt,HT<:AbstractBlock{N}} <: PrimitiveBlock{N}
....
end
and then the extension of the function apply_back!
function YaoBase.apply_back!(st, block::ImagTimeEvolution{N}, collector) where {N}
....
end
When I run it by itself it works as expected but when I run
_, grad = expect'(heisenberg(10), rand_state(10)=>imag_time_evolve(heisenberg(10), 10))
Which calls the function I’m trying to extend I receive the error
no method matching apply_back(::Tuple{ArrayReg{1,Complex{Float64},Array{Complex{Float64},2}},ArrayReg{1,Complex{Float64},Array{Complex{Float64},2}}}, ::ImagTimeEvolution{10,Int64,Add{10}}, ::Array{Any,1})
I’ve had a google and it seems this problem is generally resolved by explicitly importing the function being extended but I believe I’m doing that as I am using YaoBase.apply_back! . One thought I had is the error message doesn’t include the ! mark but where the error is being called is calling the function with ! so don’t think that’s the issue.
Any help would be greatly appreciated! (Also this is my first time posting here so if the formating is way off or I’m missing some necessary info I apologise, and please let me know. I will then try to correct it)