Esempio n. 1
0
        static async Task Main(string[] args)
        {
            using var qsim = new QuantumSimulator();
            var truePhase = 0.314;
            var est       = await PhaseEstimationSample.Run(qsim, truePhase);

            Console.WriteLine($"True phase was {truePhase}, estimated {est}.");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // We begin by defining a quantum simulator to be our target
            // machine.
            var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true);

            // Next, we pick an arbitrary value for the eigenphase to be
            // estimated. Note that we have assumed in the Q# operations that
            // the prior for the phase φ is supported only on the interval
            // [0, 1], so you might get inconsistent answers if you violate
            // that constraint. Try it out!
            const Double eigenphase = 0.344;

            System.Console.WriteLine("Bayesian Phase Estimation w/ Random Walk:");
            var est = PhaseEstimationSample.Run(sim, eigenphase).Result;

            System.Console.WriteLine($"Expected {eigenphase}, estimated {est}.");
            System.Console.ReadLine();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            using (var qsim = new QuantumSimulator())
            {
                Double eigenphase;
                Double est;

                var rand = new Random(1);

                eigenphase = rand.NextDouble() * 3 * 2;
                est        = PhaseEstimationSample.Run(qsim, eigenphase).Result;
                Console.WriteLine($"Expected {eigenphase}, estimated {est}.");

                eigenphase = rand.NextDouble() * 3 * 2;
                est        = PhaseEstimationSample.Run(qsim, eigenphase).Result;
                Console.WriteLine($"Expected {eigenphase}, estimated {est}.");

                eigenphase = rand.NextDouble() * 3 * 2;
                est        = PhaseEstimationSample.Run(qsim, eigenphase).Result;
                Console.WriteLine($"Expected {eigenphase}, estimated {est}.");
            }

            Console.ReadLine();
        }