Open jk977 opened 4 years ago
Quick update: if the first option was chosen, I'm thinking the matrix would need to be forced before mapping, unless the callback was changed from type (Int, Int) -> a -> b
to (Int, Int) -> a -> a
. The former would sacrifice performance, but the latter is a breaking change to the API and would sacrifice flexibility. Although forcing would cause the function to take a performance hit, it could be mitigated slightly by checking if ncols
is equal to vcols
before forcing. The matrix is not a submatrix if they're equal, so no forcing would be necessary.
Overview
Using
mapPos
on submatrices does not generate the expected indices. I'm fairly sure this occurs because the function doesn't factor in the column offset when callingdecode
.Versions
Example
The following gives unexpected results:
This assigns the following to
unexpected
:This could have one of two possible expected results. The first is to have the upper-left element be (1,1):
The second is to have the upper-left element be (2,1), consistent with the submatrix offset:
In my opinion, the first option provides more consistent results. It would prevent divergent behavior when, for example, calling
mapPos
on a 2x2 submatrix vs. a 2x2 matrix with no internal offsets.