Matrix cache corruption
Rayhawk11 opened this issue · 3 comments
Link to file to reproduce the issue.
The fastSplitMatrix() method is supposed to split a Matrix and output a list of 4 new matrices, each representing a quadrant of the original Matrix. The first matrix in the list is the upper left quadrant, second is the upper right quadrant, third is the lower left quadrant, fourth is the lower right quadrant.
The provided file tries to split a matrix consisting of 1s in the top row, 2s in the second row, 3s in the third row, and 4s in the fourth row. It then prints out the upper-left quadrant (split[0]); this correctly yields the matrix [1, 1; 2, 2].
Examining the cache of split[0] at this point using the Dart debugger shows that rowsCache contains the rows [3, 3] and [4, 4]: these are wrong. The matrix split[0] also has attribute areAllRowsCached set to true, so my guess is the library thinks that the cache is valid.
This behavior manifests when trying to add split[0] to itself: you get a result of [6, 6; 8, 8], presumably from operating on the incorrect cached values.
EDIT: System Details
This is with ml_linalg version 12.17.3.
Interestingly, this file does not exhibit the bug. The difference here is that the temporary variables t1 and t2 are not reused when creating the bottom matrices; instead, new variables, t3 and t4 are used.
@Rayhawk11 Thank you for creating the issue. I will look at this and let you know if I can do something to solve your problem, just keep tracking the updates in this thread.
@Rayhawk11 please check out new version of the library - 12.17.4, the issue was fixed.