Open mhoemmen opened 2 years ago
I don't think this is possible in general. I.e. uniqueness is NOT enough to guarantee that there IS an inverse mapping you can express without explicitly generating it, by computing all forward mapping values or?
In particular if it is not exhaustive.
Right, it's OK if the inverse doesn't always exist. I think it would be fine for the function to be constrained on is_always_unique()
.
A colleague requested that all unique layout mappings have an inverse mapping function. This would map a 1-D offset to the corresponding multidimensional index tuple, if the offset corresponds to a valid multidimensional index tuple.
My colleague proposed it as a nonmember function, constrained on
is_always_unique()
and preconditioned onis_unique()
.An interesting use case would be to change iteration order in a flattened loop. For example, one might be iterating over [0,
required_span_size()
) on a 2-D square domain, but might want to view the domain using a 2-D space-filling curve. One could do this by inverting thelayout_left
mapping, and then giving the resulting (i,j) index pair to a space-filling curve's layout mapping.