Closed valentin-pinkau closed 5 years ago
@amotta filling the buffers with zeros does not solve the problem, so I don't think it is necessary to zero them.
The bug comes due to the fact that the existing data is first read in colum-major order into a buffer and the data to write (c order) is loaded in the very same buffer.
@valentin-pinkau Ahh, now I get :) Thank you.
I will try to review the pull request tomorrow.
@philippotto @amotta Thank you for your reviews! Please have another look at the code.
I refactored the File::write_mat
method and moved the order handling into the copy_from_order_agnostic
method. I like the code much better now.
I added and refactored the tests based on your feedback.
This PR implements a fix for the case that an incomplete row-major (c order) block is written. When writing an incomplete block, the current implementation writes the data correctly but fills the rest of the block with scrambled data. The scrambled data origins from the block which is overwritten if it was empty, no harm is done. The bug comes due to the fact that the existing data is first read in colum-major order into a buffer and the data to write (c order) is loaded in the very same buffer.
I added two tests to catch this bug and implemented a fix by filling the correct
block_buf
.