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 = BellTest.Run(qsim, 1000, initial).Result; /** * Using estimator estimate of how many resources (qubits or certain gates) the program will use on a quantum computer */ // var estimator = new ResourcesEstimator(); // var res = BellTest.Run(estimator, 1000, initial).Result; // System.Console.WriteLine(estimator.ToTSV()); 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..."); Console.ReadKey(); }
static void Main(string[] args) { // The C# driver has four parts:+ // Construct a quantum simulator. In the example, sim is the simulator. // Compute any arguments required for the quantum algorithm.In the example, count is fixed at a 1000 and initial is the initial value of the qubit. // 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. // Process the result of the operation. In the example, res receives the result of the operation. // Here the result is a tuple of the number of zeros(numZeros) and number of ones(numOnes) measured by the simulator. // This is returned as a ValueTuple in C#. We deconstruct the tuple to get the two fields, print the results, and then wait for a keypress. using (var sim = new QuantumSimulator()) { // Try initial values Result[] initals = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initals) { var res = BellTest.Run(sim, 1000, initial).Result; var(numZeros, numOnes, agree) = res; Console.WriteLine($"Init: {initial, -4} 0s={numZeros, -4} 1s={numOnes, -4} agree={agree, -4}"); } } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
static void Main(string[] args) { // construct the quantum simulator using (var sim = new QuantumSimulator()) { // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { // we pass the simulator, initial count of 1000, and an initial qubit value // Note that the run method is asynchronous. // Each Q# operation has a corresponding C# class, for which a Run method belongs to the class // the Run method performs asynchronous executions of the given operations // note that our results for BellTest are strored in a tuple var results1 = XGate.Run(sim, 1000, initial).Result; // here we perform a Hadamard gate operation, for which our qubit is placed from the ground or exited state into // a superposition state of either |0> or |1> var results2 = HGate.Run(sim, 1000, initial).Result; // Places two bits a Bell State, which is in essence a superposition of two qubits that are entangled var res = BellTest.Run(sim, 1000, initial).Result; // caste results into a tuple, for easy access var(numZeros, numOnes, agree) = res; var play = Playground.Run(sim, 1000, initial).Result; var(nOnes, nZeros, agreement) = play; // System.Console.WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree, -4}"); System.Console.WriteLine($"Init:{initial,-4} 0s={nZeros,-4} 1s={nOnes,-4} agree={agreement,-4}"); } } System.Console.WriteLine("Press any key to continue..."); System.Console.ReadKey(); }
static void Main(string[] args) { //Construct a quantum simulator sim -- scope inside using statement only using (var sim = new QuantumSimulator()) { Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { //Run method is used to call Quantum operation from C#-- it is asynchronously execution -- it means when fetch the Result property of Q# operation BellTest to variable res, this blocks execution until the task complets and return result synchronously var res = BellTest.Run(sim, 1000, initial).Result; var(numZeros, numOnes) = res; System.Console.WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}"); } } using (var sim = new QuantumSimulator()) { Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { //Run method is used to call Quantum operation from C#-- it is asynchronously execution -- it means when fetch the Result property of Q# operation BellTest2 to variable res, this blocks execution until the task complets and return result synchronously var res = BellTest_2.Run(sim, 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..."); System.Console.ReadKey(); }
static void Main(string[] args) { // Estimate quantum resources. Console.WriteLine("Resource estimation"); Console.WriteLine("-------------------"); var estimator = new ResourcesEstimator(); BellTest.Run(estimator, 1000, Result.Zero).Wait(); Console.WriteLine(estimator.ToTSV()); // Actually run the experiment (assuming the resources are enough). Console.WriteLine(); Console.WriteLine("Experiment"); Console.WriteLine("----------"); using (var qsim = new QuantumSimulator()) { // Try initial values var initials = new Result[] { Result.Zero, Result.One }; foreach (var initial in initials) { var res = BellTest.Run(qsim, 1000, initial).Result; var(numZeros, numOnes, agree) = res; Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}"); } } Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
// Bell Test private static void Bell() { System.Console.WriteLine("Press any key to measure some Bell states"); System.Console.ReadKey(); var n = 1000; using (var sim = new QuantumSimulator()) { System.Console.WriteLine($" ========== Bell State & Teleportation =========="); System.Console.WriteLine($"The following uses a Hadamard gate (no entanglement), " + $"to get a superposition of states that, when measured, agree ~50% of the time"); // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = BellTest.Run(sim, n, initial, false).Result; var(numZeros, numOnes, agree) = res; System.Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree * 100 / n}%"); } System.Console.WriteLine($"Now we add a CNOT Gate to get entanglement, and get agreement 100% of the time"); System.Console.WriteLine("Press any key..."); System.Console.ReadKey(); foreach (Result initial in initials) { var res = BellTest.Run(sim, n, initial, true).Result; var(numZeros, numOnes, agree) = res; System.Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree * 100/n}%"); } } System.Console.ReadKey(); System.Console.WriteLine(); }
private static void RunBellTest(SimulatorBase simulator) { // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = BellTest.Run(simulator, 1000, initial).Result; var(numZeros, numOnes, agree) = res; Console.WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}"); } }
static void Main(string[] args) { var estimator = new ResourcesEstimator(); BellTest.Run(estimator, 1000, Result.Zero).Wait(); System.Console.WriteLine(estimator.ToTSV()); System.Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
static void Main(string[] args) { Task <(long, long)> task = null; using (var qsim = new QuantumSimulator()) { task = BellTest.Run(qsim, 100, Result.One); task.Wait(); } Console.WriteLine("Num of zeroes : {0}, num of ones : {1}", task.Result.Item1, task.Result.Item2); Console.ReadLine(); }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { // Try initial values var res = BellTest.Run(qsim).Result; var(numZeros, numOnes, agree) = res; Console.WriteLine($"# of 0s={numZeros,-4}"); Console.WriteLine($"# of 1s={numOnes,-4}"); Console.WriteLine($"agree={agree,-4}"); System.Console.WriteLine(); } }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { Result[] initals = new Result[] { Result.Zero, Result.One }; foreach (Result inital in initals) { var res = BellTest.Run(qsim, 1000, inital).Result; Console.WriteLine("for inital of {2} ==> 0: {0} 1: {1} - Agree:{3}", res.Item1, res.Item2, inital, res.Item3); } Console.ReadKey(); } }
static void Main(string[] args) { using (var sim = new QuantumSimulator()) { for (int i = 0; i < 100; i++) { var(s1, s2) = BellTest.Run(sim).Result; Console.WriteLine($"第{i}次:Q1状态 {s1,-5} Q2状态 {s2,-5}"); } } Console.WriteLine("按任意键继续..."); Console.ReadKey(); }
static void Main(string[] args) { /* * Объявление переменной `sim`, отвечающей за квантовый симулятор. * После выхода из блока `using` память, выделенная под `sim`, освобождается. */ using (var sim = new QuantumSimulator()) { /* * Объявление массива из двух элементов типа `Result`: * `Zero` и `One`. */ Result[] initials = new Result[] { Result.Zero, Result.One }; /* * Для каждого элемента массива `initials` провести 1000 * экспериментов программы `BellTest`. */ foreach (Result initial in initials) { /* * `BellTest` представляет собой класс, у которого есть * метод `Run` - для запуска эксперимента на симуляторе `sim`. * * Следующими аргументами передаются параметры для самой * операции `BellTest` из Q#-файла `Bell.qs` - число * экспериментов и начальное состояние нулевого кубита. */ var res = BellTest.Run(sim, 1000, initial).Result; /* * Переменная `res` - это кортеж (tuple) из: * числа измерений, в которых был получен ноль (|0>), * числа измерений, в которых была получена единица (|1>), * числа измерений, в которых состояния нулевого и первого кубитов совпадают. */ 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..."); System.Console.ReadKey(); }
static void Main(string[] args) { using (var sim = new QuantumSimulator()) { Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = BellTest.Run(sim, 1000, initial).Result; var(numZeros, numOnes) = res; System.Console.WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}"); } } System.Console.WriteLine("Press any key to continue"); System.Console.ReadKey(); }
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 = BellTest.Run(qsim, 1000, initial).Result; var(numZeros, numOnes) = res; System.Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}"); } } }
static void Main(string[] args) { using (var qsim = new QuantumSimulator()) { var initials = new [] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = BellTest.Run(qsim, 1000, initial).Result; var(numZeros, numOnes, agree) = res; Console.WriteLine($"初期状態:{initial,-4} |0>={numZeros,-4} |1>={numOnes,-4} 同一={agree,-4}"); } } Console.WriteLine("キーを押したら終了します..."); Console.ReadKey(); }
static void Main(string[] args) { // Task 2 - add code here using (var sim = new QuantumSimulator()) { Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var count = 1000; var (numZeros, numOnes, same) = BellTest.Run(sim, count, initial).Result; System.Console.WriteLine($"Init:{initial,-4} 0s={numZeros, -4} 1s={numOnes, -4} same={same, -4}"); // System.Console.WriteLine("Press any key to continue..."); // System.Console.ReadKey(); } } }
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 = BellTest.Run(qsim, 1000, initial).Result; var(numZeros, numOnes, agree) = res; Console.WriteLine($"Init: {initial, -4} 0s={numZeros, -4} 1s={numOnes, -4}, agree={agree, -4}"); } } Console.WriteLine("Press any key to continue..."); Console.ReadLine(); }
private static void Main() { using (var qsim = new QuantumSimulator()) { Clear(); HelloQ.Run(qsim).Wait(); // prova i valori iniziali Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = BellTest.Run(qsim, 1000, initial).Result; var(numZeros, numOnes, agree) = res; WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}"); } } ReadKey(); }
static void Main(string[] args) { //Erzeugen des Quantumsimulators using (var quantumSimulator = new QuantumSimulator()) { //Erzeugung zweier anfänglicher Messergebnisse(Resultate) von Null und Eins Result[] initials = new Result[] { Result.Zero, Result.One }; //Für jedes Messergebnis(Resultat), zwei an der Zahl, wird der Quantensimulator gestartet foreach (Result initial in initials) { var result = BellTest.Run(quantumSimulator, 1000, initial).Result; var(numZeros, numOnes, agree) = result; System.Console.WriteLine($"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree, -4}"); } } System.Console.WriteLine("Press any key to continue..."); System.Console.ReadKey(); }
static void Main(string[] args) { using (var sim = new QuantumSimulator()) // 'sim' is the Q# quantum simulator { // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) { var res = BellTest.Run(sim, 1000, initial).Result; // 'Run' is the method to run the quantum simulation // 'Run' is asynchronous, but fetching the 'Result' property blocks // execution until the task completes and makes this synchronous. 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..."); System.Console.ReadKey(); }
static void Main(string[] args) { using (var sim = new QuantumSimulator()) // sim is the simulator { // Try initial values Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (Result initial in initials) //Compute any arguments required for the quantum algorithm. { var res = BellTest.Run(sim, 1000, initial).Result; //In the example, count is fixed at a 1000 and initial is the initial value of the qubit. var(numZeros, numOnes) = res; // var (numZeros, numOnes, agree) = res; System.Console.WriteLine( $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4}"); //System.Console.WriteLine( // $"Init:{initial,-4} 0s={numZeros,-4} 1s={numOnes,-4} agree={agree,-4}"); } } System.Console.WriteLine("Press any key to continue..."); System.Console.ReadKey(); }
static void Main(string[] args) { // aloca dinamicamente um simulador para executar o código quantico using (var SIM = new QuantumSimulator()) { Result[] estados_iniciais = new Result[] { Result.Zero, Result.One }; foreach (Result estado in estados_iniciais) { // computa o teste: cont=1000 inicial=estados_iniciais var resp = BellTest.Run(SIM, 1000, estado).Result; var(numZeros, numUns) = resp; System.Console.WriteLine($"Resultado:{estado, -4} 0s={numZeros, -4} 1s={numUns, -4}"); } } System.Console.WriteLine("Pressione qualquer tecla para continuar..."); System.Console.ReadKey(); }
static void Main(string[] args) { var estimator = new ResourcesEstimator(); BellTest.Run(estimator, 1000, Result.Zero).Wait(); System.Console.WriteLine(estimator.ToTSV()); /*using (var qsim = new QuantumSimulator()) * { * Result[] initials = new Result[] { Result.Zero, Result.One }; * foreach(Result initial in initials) * { * var res = BellTest.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..."); Console.ReadKey(); }
static void Main(string[] args) { var qsim = new ResourcesEstimator(); BellTest.Run(qsim, 1000, Result.Zero).Wait(); System.Console.WriteLine(qsim.ToTSV()); //using (var qsim = new QuantumSimulator()) //{ // //Try initial values // Result[] initials = new Result[] { Result.Zero, Result.One }; // foreach (Result initial in initials) // { // var res = BellTest.Run(qsim, 1000, initial).Result; // var (numZeroes, numOnes, agree) = res; // System.Console.WriteLine($"Init:{initial,-4} 0s={numZeroes,-4} 1s={numOnes,-4} agree={agree, -4}"); // } //} System.Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
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 = BellTest.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}"); } } //run this instead of the above using block for resource estimation //var estimator = new ResourcesEstimator(); //BellTest.Run(estimator, 1000, Result.Zero).Wait(); //System.Console.WriteLine(estimator.ToTSV()); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
private static void Main() //****************************************************************************80 // // Purpose: // // MAIN is the main program for SUBSET_TEST. // // Discussion: // // SUBSET_TEST tests SUBSET. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 20 November 2019 // // Author: // // John Burkardt // { Console.WriteLine(""); Console.WriteLine("SUBSET_TEST"); Console.WriteLine(" Test the SUBSET library."); AlternatingSignMatrixTest.asm_enum_test(); AlternatingSignMatrixTest.asm_triangle_test(); BellTest.bell_test(); CatalanTest.catalan_test(); CatalanTest.catalan_row_next_test(); FractionTest.cfrac_to_rat_test(); FractionTest.cfrac_to_rfrac_test(); CombTest.comb_next_test(); CombTest.comb_row_next_test(); CombTest.comb_unrank_test(); CompTest.comp_enum_test(); CompTest.comp_next_test(); CompTest.comp_next_grlex_test(); CompTest.comp_random_test(); CompTest.comp_random_grlex_test(); CompTest.comp_rank_grlex_test(); CompTest.comp_to_ksub_test(); CompTest.comp_unrank_grlex_test(); CompTest.compnz_next_test(); CompTest.compnz_random_test(); CompTest.compnz_to_ksub_test(); CongruenceTest.congruence_test(); DebruijnTest.debruijn_test(); DecMatTest.decmat_det_test(); DecMatTest.decmat_print_test(); DerangeTest.derange_enum_test(); DerangeTest.derange_enum2_test(); DerangeTest.derange_enum3_test(); DerangeTest.derange0_back_next_test(); DerangeTest.derange0_check_test(); DerangeTest.derange0_weed_next_test(); DigraphTest.digraph_arc_euler_test(); DigraphTest.digraph_arc_print_test(); DiophantineTest.diophantine_test(); DiophantineTest.diophantine_solution_minimize_test(); DVecTest.dvec_add_test(); DVecTest.dvec_complementx_test(); DVecTest.dvec_mul_test(); DVecTest.dvec_print_test(); DVecTest.dvec_sub_test(); DVecTest.dvec_to_i4_test(); EquivTest.equiv_next_test(); EquivTest.equiv_next2_test(); EquivTest.equiv_print_test(); EquivTest.equiv_print2_test(); EquivTest.equiv_random_test(); EulerTest.euler_row_test(); FrobeniusTest.frobenius_number_order2_test(); GrayTest.gray_next_test(); GrayTest.gray_rank_test(); GrayTest.gray_rank2_test(); GrayTest.gray_unrank_test(); GrayTest.gray_unrank2_test(); i4Test.i4_bclr_test(); i4Test.i4_bset_test(); i4Test.i4_btest_test(); i4Test.i4_choose_test(); i4Test.i4_factor_test(); i4Test.i4_fall_test(); i4Test.i4_gcd_test(); i4Test.i4_huge_test(); i4Test.i4_log_10_test(); i4Test.i4_modp_test(); i4Test.i4_moebius_test(); i4Test.i4_partition_conj_test(); i4Test.i4_partition_count_test(); i4Test.i4_partition_count2_test(); i4Test.i4_partition_next_test(); i4Test.i4_partition_next2_test(); i4Test.i4_partition_print_test(); i4Test.i4_partition_random_test(); i4Test.i4_partitions_next_test(); i4Test.i4_rise_test(); i4Test.i4_sqrt_test(); i4Test.i4_sqrt_cf_test(); i4Test.i4_to_dvec_test(); i4Test.i4_to_i4poly_test(); i4Test.i4_to_van_der_corput_test(); i4Test.i4mat_01_rowcolsum_test(); i4Test.i4mat_u1_inverse_test(); i4Test.i4mat_perm0_test(); i4Test.i4mat_2perm0_test(); i4Test.i4poly_test(); i4Test.i4poly_add_test(); i4Test.i4poly_cyclo_test(); i4Test.i4poly_degree_test(); i4Test.i4poly_dif_test(); i4Test.i4poly_div_test(); i4Test.i4poly_mul_test(); i4Test.i4poly_print_test(); i4Test.i4poly_to_i4_test(); i4Test.i4vec_backtrack_test(); i4Test.i4vec_descends_test(); i4Test.i4vec_frac_test(); i4Test.i4vec_index_test(); i4Test.i4vec_maxloc_last_test(); i4Test.i4vec_pairwise_prime_test(); i4Test.i4vec_reverse_test(); i4Test.i4vec_sort_bubble_a_test(); i4Test.i4vec_sort_heap_index_d_test(); i4Test.i4vec_transpose_print_test(); i4Test.i4vec_uniform_ab_test(); IndexTest.index_box_next_2d_test(); IndexTest.index_box_next_3d_test(); IndexTest.index_box2_next_2d_test(); IndexTest.index_box2_next_3d_test(); IndexTest.index_next0_test(); IndexTest.index_next1_test(); IndexTest.index_next2_test(); IndexTest.index_rank0_test(); IndexTest.index_rank1_test(); IndexTest.index_rank2_test(); IndexTest.index_unrank0_test(); IndexTest.index_unrank1_test(); IndexTest.index_unrank2_test(); InverseTest.inverse_mod_n_test(); PermTest.inversion_to_perm0_test(); InvoluteTest.involute_enum_test(); FractionTest.jfrac_to_rfrac_test(); JosephusTest.josephus_test(); KsubTest.ksub_next_test(); KsubTest.ksub_next2_test(); KsubTest.ksub_next3_test(); KsubTest.ksub_next4_test(); KsubTest.ksub_random_test(); KsubTest.ksub_random2_test(); KsubTest.ksub_random3_test(); KsubTest.ksub_random4_test(); KsubTest.ksub_random5_test(); KsubTest.ksub_rank_test(); KsubTest.ksub_to_comp_test(); KsubTest.ksub_to_compnz_test(); KsubTest.ksub_unrank_test(); l4Test.l4vec_next_test(); MatrixTest.matrix_product_opt_test(); MoebiusMatrixTest.moebius_matrix_test(); MonomialTest.monomial_count_test(); MonomialTest.monomial_counts_test(); MorseThueTest.morse_thue_test(); MultinomialTest.multinomial_coef1_test(); MultinomialTest.multinomial_coef2_test(); PermTest.multiperm_enum_test(); PermTest.multiperm_next_test(); UnsignTest.nim_sum_test(); PadovanTest.padovan_test(); PellTest.pell_basic_test(); PellTest.pell_next_test(); PentEnumTest.pent_enum_test(); PermTest.perm_ascend_test(); PermTest.perm_fixed_enum_test(); PermTest.perm0_break_count_test(); PermTest.perm0_check_test(); PermTest.perm0_cycle_test(); PermTest.perm0_distance_test(); PermTest.perm0_free_test(); PermTest.perm0_inverse_test(); PermTest.perm0_inverse2_test(); PermTest.perm0_inverse3_new_test(); PermTest.perm0_lex_next_test(); PermTest.perm0_mul_test(); PermTest.perm0_next_test(); PermTest.perm0_next2_test(); PermTest.perm0_next3_test(); PermTest.perm0_print_test(); PermTest.perm0_random_test(); PermTest.perm0_random2_test(); PermTest.perm0_rank_test(); PermTest.perm0_sign_test(); PermTest.perm0_to_equiv_test(); PermTest.perm0_to_inversion_test(); PermTest.perm0_to_ytb_test(); PermTest.perm0_unrank_test(); PermTest.perm1_canon_to_cycle_test(); PermTest.perm1_check_test(); PermTest.perm1_cycle_to_canon_test(); PermTest.perm1_cycle_to_index_test(); PermTest.perm1_index_to_cycle_test(); PermTest.perm1_print_test(); PerrinTest.perrin_test(); PartialOrderingTest.pord_check_test(); PowerTest.power_mod_test(); PowerTest.power_series1_test(); PowerTest.power_series2_test(); PowerTest.power_series3_test(); PowerTest.power_series4_test(); PrimeTest.prime_test(); PythagorusTest.pythag_triple_next_test(); r8Test.r8_agm_test(); r8Test.r8_choose_test(); r8Test.r8_epsilon_test(); r8Test.r8_fall_test(); r8Test.r8_rise_test(); r8Test.r8_to_cfrac_test(); r8Test.r8_to_dec_test(); r8Test.r8_to_rat_test(); r8Test.r8mat_det_test(); r8Test.r8mat_perm0_test(); r8Test.r8mat_2perm0_test(); r8Test.r8mat_permanent_test(); r8Test.r8poly_test(); r8Test.r8poly_f2p_test(); r8Test.r8poly_fval_test(); r8Test.r8poly_n2p_test(); r8Test.r8poly_nval_test(); r8Test.r8poly_nx_test(); r8Test.r8poly_p2f_test(); r8Test.r8poly_p2n_test(); r8Test.r8poly_p2t_test(); r8Test.r8poly_print_test(); r8Test.r8poly_pval_test(); r8Test.r8poly_t2p_test(); r8Test.r8vec_backtrack_test(); r8Test.r8vec_frac_test(); r8Test.r8vec_mirror_next_test(); RationalTest.rat_add_test(); RationalTest.rat_div_test(); RationalTest.rat_farey_test(); RationalTest.rat_farey2_test(); RationalTest.rat_mul_test(); RationalTest.rat_normalize_test(); RationalTest.rat_sum_formula_test(); RationalTest.rat_to_cfrac_test(); RationalTest.rat_to_dec_test(); RationalTest.rat_to_r8_test(); RationalTest.rat_to_s_test(); RationalTest.rat_width_test(); RationalTest.ratmat_det_test(); RationalTest.ratmat_print_test(); RestrictedGrowthTest.regro_next_test(); FractionTest.rfrac_to_cfrac_test(); FractionTest.rfrac_to_jfrac_test(); SchroederTest.schroeder_test(); SortHeapExternalTest.sort_heap_external_test(); SubsetTest.subset_by_size_next_test(); SubsetTest.subset_lex_next_test(); SubsetTest.subset_gray_next_test(); SubsetTest.subset_random_test(); SubsetTest.subset_gray_rank_test(); SubsetTest.subset_gray_unrank_test(); SubcompTest.subcomp_next_test(); SubcompTest.subcompnz_next_test(); SubcompTest.subcompnz2_next_test(); TriangleTest.subtriangle_next_test(); Thuetest.thue_binary_next_test(); Thuetest.thue_ternary_next_test(); TriangTest.triang_test(); TupleTest.tuple_next_test(); TupleTest.tuple_next_fast_test(); TupleTest.tuple_next_ge_test(); TupleTest.tuple_next2_test(); UnsignTest.ubvec_add_test(); UnsignTest.ubvec_print_test(); UnsignTest.ubvec_to_ui4_test(); UnsignTest.ubvec_xor_test(); UnsignTest.ui4_to_ubvec_test(); VectorTest.vec_colex_next_test(); VectorTest.vec_colex_next2_test(); VectorTest.vec_colex_next3_test(); VectorTest.vec_gray_next_test(); VectorTest.vec_gray_rank_test(); VectorTest.vec_gray_unrank_test(); VectorTest.vec_lex_next_test(); VectorTest.vec_random_test(); VectorTest.vector_constrained_next_test(); VectorTest.vector_constrained_next2_test(); VectorTest.vector_constrained_next3_test(); VectorTest.vector_constrained_next4_test(); VectorTest.vector_constrained_next5_test(); VectorTest.vector_constrained_next6_test(); VectorTest.vector_constrained_next7_test(); VectorTest.vector_next_test(); YoungTableauTest.ytb_enum_test(); YoungTableauTest.ytb_next_test(); YoungTableauTest.ytb_random_test(); Console.WriteLine(""); Console.WriteLine("SUBSET_TEST"); Console.WriteLine(" Normal end of execution."); Console.WriteLine(""); }
static void Main(string[] args) { void PressKey(string name) { Console.WriteLine($"\n\nPress any key to start {name}\n\n"); Console.ReadKey(); } using (var qsim = new QuantumSimulator()) { PressKey("Reversable gate"); for (int i = 0; i < 5; ++i) { var initialValue = i % 2 == 0 ? Result.Zero : Result.One; var result = ReversableGate.Run(qsim, initialValue).Result; Console.WriteLine($"Reversable gate result is: " + $"{result}. Initial value: {initialValue}"); } PressKey("Measurement superposition collapsing"); for (int i = 0; i < 15; ++i) { var initialValue = i % 2 == 0 ? Result.One : Result.Zero; var result = MeasurementCollapsingSuperposition .Run(qsim, initialValue).Result; Console.WriteLine( $"Reversable gate result is: {result.Item1}. " + $"Result2: {result.Item2}. Inital value: {initialValue}"); } PressKey("Random number generator"); for (int i = 0; i < 10; ++i) { var randomNumber = GenerateRandomNumber.Run(qsim).Result; Console.WriteLine($"Random number is: {randomNumber}"); } PressKey("Bell test"); Result[] initials = new Result[] { Result.Zero, Result.One }; foreach (var initial in initials) { var res = BellTest.Run(qsim, 1000, initial).Result; var(numZeros, numOnes, agrees) = res; Console.WriteLine($"" + $"Init:{initial,-4} " + $"0s={numZeros,-4} " + $"1s={numOnes,-4} " + $"Agrees = {agrees,-4}"); } PressKey("Deutsch-Jozsa"); var const0Result = Constant0.Run(qsim).Result; var const1Result = Constant1.Run(qsim).Result; var negationResult = Negation.Run(qsim).Result; var identityResult = Identity.Run(qsim).Result; Console.WriteLine($"Const0: " + $"{const0Result.Item1} " + $"{const0Result.Item2} " + $"{const0Result.Item3}"); Console.WriteLine($"Const1: " + $"{const1Result.Item1} " + $"{const1Result.Item2} " + $"{const1Result.Item3}"); Console.WriteLine($"Identity: " + $"{identityResult.Item1} " + $"{identityResult.Item2} " + $"{identityResult.Item3}"); Console.WriteLine($"Negation: " + $"{negationResult.Item1} " + $"{negationResult.Item2} " + $"{negationResult.Item3}"); PressKey("Teleportation part 1"); for (int i = 0; i < 5; ++i) { Console.WriteLine($"Teleport (msg==false): " + $"{SendMessage.Run(qsim, false).Result}"); } PressKey("Teleportation part 2"); for (int i = 0; i < 5; ++i) { Console.WriteLine($"Teleport (msg==true): " + $"{SendMessage.Run(qsim, true).Result}"); } } Console.WriteLine("\n\nEnd"); Console.ReadKey(); }