Skip to content

Slow down due to translatecell #78

@LHerviou

Description

@LHerviou

During the creation of MPOMatrices, I experienced some significant slowdown, in particular when not using the base translate function (though not only) because accessing a tensor in fact often creates a copy of it.

Would it not be better to add a small modification in all our translatecell such that if we ask a translation of 0, it directly return the original tensor. Something akin to (in the celledvectors.jl file):

#Transfer the functional properties
#translatecell(translator, T::ITensor, n::Integer) = translator(T, n)
function translatecell(translator::Function, T::ITensor, n::Integer)
  if n == 0
      return T
  end
  return ITensors.setinds(T, translatecell(translator, inds(T), n))
end
translatecell(translator::Function, T::MPO, n::Integer) = n==0 ? T : translatecell.(translator, T, n)
function translatecell(translator::Function, T::Matrix{ITensor}, n::Integer)
  if n == 0
      return T
  end
  return translatecell.(translator, T, n)
end  ###etc

This should drastically reduce the memory footprint and speed up some parts of the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions