Example #1
0
        public static LogicTable FromText(string txtTable, int numVarsX, int numVarsY)
        {
            string[] entries = txtTable.Split(new char[] {'\n','\r'}, StringSplitOptions.RemoveEmptyEntries);
            int numEntries   = entries.Length;
            int numBits      = entries[0].Length;

            int numRows    = 1 << numVarsY;
            int numColumns = 1 << numVarsX;
            if (numEntries != numRows * numColumns)
                throw new ArgumentException();

            BitNumber[,] table = new BitNumber[numRows, numColumns];
            for (int r = 0; r < numRows; r++) {
                for (int c = 0; c < numColumns; c++) {
                    table[r, c] = BitNumber.FromString(entries[r * numColumns + c]);
                    if (table[r, c].NumBits != numBits)
                        throw new ArgumentException();
                }
            }

            return new LogicTable(table);
        }
Example #2
0
 private LogicTable(BitNumber[,] table)
 {
     this.table = table;
 }