CombinatoricsTruthTable Method (Int32) |
Namespace: Accord.Math
Suppose we would like to generate a truth table for a binary problem. In this case, we are only interested in two symbols: 0 and 1. Let's then generate the table for three binary values
int length = 3; // The number of variables; or number // of columns in the generated table. // Generate the table using Combinatorics.TruthTable(3) int[][] table = Combinatorics.TruthTable(length); // The generated table will be: { new int[] { 0, 0, 0 }, new int[] { 0, 0, 1 }, new int[] { 0, 1, 0 }, new int[] { 0, 1, 1 }, new int[] { 1, 0, 0 }, new int[] { 1, 0, 1 }, new int[] { 1, 1, 0 }, new int[] { 1, 1, 1 }, };