Never ending loop when number rows > cols in matrix
I stumbled upon a never ending loop, easy to reproduce like:
var matrix1 = new int[,]{
{0,0,0},
{0,0,0}
};
var matrix2 = new int[,]{
{0,0},
{0,0},
{0,0}
};
var assignments = matrix1.FindAssignments();
Console.WriteLine($"Found {assignments.Length} assignments in matrix 1");
var assignments2 = matrix2.FindAssignments();
Console.WriteLine($"Found {assignments.Length} assignments in matrix 2"); // we never get here
Run live from dotnetfiddle.
I'm not really sure how to fix this but I assume it is unexpected behaviour?
I will try to reproduce it.
Hi
Sorry for the long delay, but I haven't forgotten the issue.
I have reproduced the problem, and I recall from many years ago I had the same problem. I am not an expert in the algorithm, and I haven't written the original source-code. I used to handle it by using the Array extension SquareArray, before invoking the algorithm.
I am not able to fix it, but feel free to submit a PR
I also met this problem and found out one way to resolve it. See the pull request :)
I will check it out Good work fixing it 😀
I have merged the PR. Also I removed the SquareArray method, as it should not be needed anymore.