My problem is that I have a Matrix where the sum of all rows, and the sum of all columns is zero. All numbers are rounded to x decimals.
Then I multiply the entire matrix with a number between 0 and 1 (eg. 1/6) and round all the numbers to x decimals. Now I cannot be sure that the sum of the rows and columns will be zero. I want the sums to be zero again with the smallest possible adjustment (or at least very small adjustment)
Does there exist a algoritm that can fix such a problem?
Example (very simple): matrix:
200 -200 0
400 400 -800
-600 -200 800
round2( (1/6)*matrix)
33.33 -33.33 0
66.67 66.67 -133.33
-100 -33.33 133.33