sparse
sparse copied to clipboard
COO.transpose() is not cheap
Transposing a COO
array results in a reordering of all the data elements.
Would it be possible to avoid doing this?
One way would be to make a small "library"/submodule that handled views of COO. But I cannot think of a clean way without breaking the current guarantee that COO will always have ordered elements.
We were evaluating using the TACO compiler, (#326) which would in theory make this O(1), but that's an even larger undertaking, and at least with my current knowledge, beyond my skills.
without breaking the current guarantee that COO will always have ordered elements
You could relax the guarantee to "Elements of self.transpose(self._axis_order)
" are ordered, which would mean storing an extra property.
You could define a TransposedCOO
wrapper class that re-writes axes before passing through to the underlying COO class. This is essentially the approach we use for CSR/CSC matrices in scipy.sparse.