static void Main(string[] args) { #region Concepts de base using (var qsim = new QuantumSimulator()) { // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var(numZerosNeutre, numOnesNeutre) = TestBellState.Run(qsim, 1000, initial).Result; var(numZerosFlip, numOnesFlip) = TestBellStateFlip.Run(qsim, 1000, initial).Result; var(numZerosHadamard, numOnesFlipHadamard) = TestBellStateHadamard.Run(qsim, 1000, initial).Result; System.Console.WriteLine($"============ {initial} ============"); System.Console.WriteLine($"Neutre : 0s={numZerosNeutre} 1s={numOnesNeutre}"); System.Console.WriteLine($"Flip : 0s={numZerosFlip} 1s={numOnesFlip}"); System.Console.WriteLine($"Hadamard: 0s={numZerosHadamard} 1s={numOnesFlipHadamard}"); } } System.Console.WriteLine("Press any key to continue..."); Console.ReadKey(); #endregion }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = TestBellState.Run(qsim, 1000, initial).Result; //Run the quantum algorithm. //Each Q# operation generates a C# class with the same name. //This class has a Run method that asynchronously executes the operation. //The execution is asynchronous because execution on actual hardware will be asynchronous. //Because the Run method is asynchronous, we fetch the Result property; //this blocks execution until the task completes and returns the result synchronously. var(numZeros, numOnes) = res; System.Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}"); } } System.Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
static async Task Main(string[] args) { using(var qsim = new QuantumSimulator()) { var result = await TestBellState.Run(qsim, args); } System.Windows.Forms.MessageBox.Show($"{result}"); }
////////////////// ///////////////// public static void ExecTestBellStates(Result initialState, int shots = 1024) { Helper.Print("Test Bell State"); using (var qsim = new QuantumSimulator()) { var res = TestBellState.Run(qsim, shots, initialState).Result; var(numZeros, numOnes, agree) = res; Console.WriteLine( $"Init: {initialState , -4} 0s = {numZeros, -4} 1s = {numOnes, -4} agrees = {agree, -4}" ); Console.WriteLine(); } }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = TestBellState.Run(qsim, 1000, initial).Result; var(numZeros, numOnes, agree) = res; System.Console.WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}"); } } Console.WriteLine("Done"); Console.Read(); }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { //(1000rounds, initial could be 1 or 0) var res = TestBellState.Run(qsim, 1000, initial).Result; var(numZeros, numOnes, agree) = res; System.Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}"); } } System.Console.WriteLine("Press any key to continue..."); }