I am looking for an efficient way of representing symmetric tensors with all zero diagonals (any combination of two indices, that is). Since these tensors are going to be fairly small, a fair number of entries are going to be zero or duplicates (especially above rank 2), so I have been representing them as vectors of the unique non-zero items. However, manual indexing has become tedious and operations such as multiplication don’t play nicely with reverse mode AD.
I would like to avoid allocations as much as possible since these tensors are used in a tight loop. Just wondered if anyone else had faced a similar problem and whether you’d have any tips to share.