Contracting diagonal tensors

Hi,

I am using the C++ version (and don’t intend on changing that) and have encountered a slight problem. Specifically, when trying to multiply two diagonal tensors ITensor reports that doTask is not implemented for that operation. Digging deeper this seems to be true, in fact in diag.h only Diag-Dense contractions are implemented. Given that I did not initially define these tensors as diagonal and I can’t guarantee that they will also be such, ITensor does it automatically, there does not seem to be a nice way to proceed from this point. Perhaps there are some options available to solve this problem in a clean way?

Thank you.

You could try to convert one or both of them to dense before performing the contraction.

Hi Matt!

Thanks for your response. However, it is not clear to me how I can do that nicely. The toDense function fails when called on an already dense tensor and there is no implemented “isDense” or “isDiag” function that I can find. For now I have put together a sort of hack that works for the one case I’ve tested, but for more generic cases I would need to know exactly what ITensor considers dense versus diagonal, otherwise strange edge cases may apply. In fairness, the ideal solution would be if I could somehow inspect the underlying type, which I am sure is possible, I just haven’t found a nice way to do that either.

Thanks for your help!