protected RemovalInfo RecursiveRemoveableChecks(Matrix m, bool bThoroughComparison) { if (m.Rank == m.Columns - 1) { Fraction[] vals = m.getVariableValues(); bool AllPositive = true; for (int j = 0; j < vals.Length; j++) if (vals[j] < 0 && !m.m_CanGoNegative[j]) { AllPositive = false; break; } if (AllPositive) return new RemovalInfo(true); else return new RemovalInfo(false); } else if (m.Rank < m.Columns - 1) { bool[] removeables = m.ColumnsRemoveable(); RemovalInfo ret = new RemovalInfo(m.Columns - 1); for (int i = 0; i < removeables.Length; i++) { bool found = false; if (!removeables[i] || (!bThoroughComparison && found)) ret.m_IfRemoved[i] = new RemovalInfo(false); else { Matrix OneColRemoved = m.RemoveColumn(i); ret.SetIfRemoved(i, RecursiveRemoveableChecks(OneColRemoved, bThoroughComparison)); } } return ret; } else return new RemovalInfo(false); //If we call this on a matrix with too high Rank, it's not solveable (And so nothing is removeable) }