/// <summary> /// The main entry point for emulation of a permutation oracle: /// Apply the permutation defined by the oracle function /// f: (x, y) -> (x, f(x, y)). /// </summary> public static void ApplyOracle(QuantumSimulator simulator, Func <Int64, Int64, Int64, Int64> oracle, Int64 nLayers, IQArray <Qubit> xbits, Qubit ybit, bool adjoint = false) { var permutation = BuildPermutationTable(oracle, nLayers, (int)xbits.Length, 1); simulator.CheckQubits(xbits, "x"); simulator.CheckQubit(ybit, "y"); Debug.Assert(CheckPermutation(permutation)); IQArray <Qubit> ybits = new QArray <Qubit>(ybit); var qbits = QArray <Qubit> .Add(xbits, ybits).GetIds(); if (adjoint) { AdjPermuteBasisTable(simulator.Id, (uint)qbits.Length, qbits, permutation.LongLength, permutation); } else { PermuteBasisTable(simulator.Id, (uint)qbits.Length, qbits, permutation.LongLength, permutation); } }