// 初期化 public QuineMcCluskey (TruthTable table) { Source = table; var trues = table.Columns.Where (x => x.Result); var trueCount = trues.Count (); trueCols = trues.Select((x, i) => { var col = new QMColumn(x, trueCount); col.Flags[i] = true; return col; }).ToArray (); combined = new IEnumerable<IEnumerable<QMColumn>>[table.Columns[0].Size + 1]; }
public static QMColumn TryCombine (QMColumn a, QMColumn b) { var c = new QMColumn (a.Size, a.Flags.Length); if (a.Result == b.Result) { c.Result = a.Result; } else { return null; } var already = false; for (int i = 0; i < a.Size; i++) { if (a [i] == b [i]) { c [i] = a [i]; } else if (!already && a [i].HasValue && b [i].HasValue) { c [i] = null; already = true; } else { return null; } } c.Flags |= a.Flags; c.Flags |= b.Flags; return c; }