static void Main(string[] args) { Dictionary <long, int> results = new Dictionary <long, int>(); var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); QArray <bool> bits = new QArray <bool>() { true, false, true, true, true }; for (int i = 0; i < 2048; i++) { long result = TestOperation.Run(sim, bits).Result; if (results.ContainsKey(result)) { results[result]++; } else { results[result] = 1; } } foreach (KeyValuePair <long, int> result in results) { Console.WriteLine($"{Convert.ToString(result.Key, 2), 3} - {result.Value}"); } Console.Read(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); Random rnd = new Random(); for (int j = 0; j < 10; j++) { Dictionary <long, int> results = new Dictionary <long, int>(); int int0 = rnd.Next(0, 256); int int1 = rnd.Next(0, 256); string bitString0 = Convert.ToString(int0, 2); string bitString1 = Convert.ToString(int1, 2); int length = Math.Max(bitString0.Length, bitString1.Length); bitString0 = LeadingZeros(bitString0, length); bitString1 = LeadingZeros(bitString1, length); Console.WriteLine($"{bitString0} {bitString1}"); QArray <bool> bitArray0 = new QArray <bool>(); QArray <bool> bitArray1 = new QArray <bool>(); foreach (char bit in bitString0.ToCharArray().Reverse()) { bitArray0.Add(bit == '1'); } foreach (char bit in bitString1.ToCharArray().Reverse()) { bitArray1.Add(bit == '1'); } for (int i = 0; i < 2048; i++) { long result = TestOperation.Run(sim, bitArray0, bitArray1).Result; if (results.ContainsKey(result)) { results[result]++; } else { results[result] = 1; } } foreach (KeyValuePair <long, int> result in results) { Console.Write($"{LeadingZeros(Convert.ToString(result.Key, 2), bitString0.Length)} "); } Console.WriteLine("\n"); } Console.Read(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); for (int state = 0; state < 4; state++) { //Dictionary<long, int> results = new Dictionary<long, int>(); //for (int i = 0; i < 2048; i++) //{ // long result = TestGenerate.Run(sim, state).Result; // if (results.ContainsKey(result)) // results[result]++; // else // results[result] = 1; //} //Console.WriteLine($"{state}:"); //foreach (KeyValuePair<long, int> result in results) // Console.WriteLine($" {LeadingZeros(Convert.ToString(result.Key, 2), 2)} - {result.Value / 2048m}"); //Console.WriteLine(); Console.WriteLine($"{state} - {TestOperation.Run(sim, state).Result}"); } Console.Read(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); for (int i = 0; i < 10; i++) { Console.WriteLine($"{TestOperation.Run(sim).Result}"); } Console.Read(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); Dictionary <Validities, int> results = new Dictionary <Validities, int>() { { Validities.Correct, 0 }, { Validities.Incorrect, 0 }, { Validities.Inconclusive, 0 } }; Random rnd = new Random(); for (int i = 0; i < 1000; i++) { int state = rnd.Next(0, 2); long result = TestOperation.Run(sim, state).Result; if (result == 2) { results[Validities.Inconclusive]++; } else { if (result == state) { results[Validities.Correct]++; } else { results[Validities.Incorrect]++; } } } foreach (KeyValuePair <Validities, int> result in results) { Console.WriteLine($"{result.Key} - {result.Value / 10m}"); } Console.Read(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); Dictionary <bool, int> results = new Dictionary <bool, int>() { { false, 0 }, { true, 0 } }; Dictionary <int, int> states = new Dictionary <int, int>() { { 0, 0 }, { 1, 0 } }; Random rnd = new Random(); for (int i = 0; i < 10000; i++) { int state = rnd.Next(0, 2); states[state]++; long result = TestOperation.Run(sim, state).Result; results[state == result]++; } foreach (KeyValuePair <int, int> state in states) { Console.WriteLine($"{state.Key} - {state.Value / 100m}"); } Console.WriteLine(); foreach (KeyValuePair <bool, int> result in results) { Console.WriteLine($"{result.Key} - {result.Value / 100m}"); } Console.Read(); }
static void Main(string[] args) { var sim = new QuantumSimulator(throwOnReleasingQubitsNotInZeroState: true); Random rnd = new Random(); for (int j = 0; j < 10; j++) { Dictionary <long, int> results = new Dictionary <long, int>(); int k = 2;// rnd.Next(0, 5); for (int i = 0; i < 2048; i++) { long result = TestOperation.Run(sim, (int)Math.Pow(2, k)).Result; if (results.ContainsKey(result)) { results[result]++; } else { results[result] = 1; } } foreach (KeyValuePair <long, int> result in results) { Console.WriteLine($"{LeadingZeros(Convert.ToString(result.Key, 2), (int)Math.Pow(2, k))} - {result.Value / 2048m}"); } Console.WriteLine(); } Console.Read(); }