From a9b999c7dfd2a91746fcb43a4a4472d2cbda6124 Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Sun, 23 Oct 2022 18:28:21 +0530 Subject: [PATCH 1/2] Revert "Create superdense_coding.py (#7349)" This reverts commit a5362799a5e73e199cda7f1acec71d1e97addc97. --- quantum/superdense_coding.py | 102 ----------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 quantum/superdense_coding.py diff --git a/quantum/superdense_coding.py b/quantum/superdense_coding.py deleted file mode 100644 index c8eda381158b..000000000000 --- a/quantum/superdense_coding.py +++ /dev/null @@ -1,102 +0,0 @@ -""" -Build the superdense coding protocol. This quantum -circuit can send two classical bits using one quantum -bit. This circuit is designed using the Qiskit -framework. This experiment run in IBM Q simulator -with 1000 shots. -. -References: -https://qiskit.org/textbook/ch-algorithms/superdense-coding.html -https://en.wikipedia.org/wiki/Superdense_coding -""" - -import math - -import qiskit -from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute - - -def superdense_coding(bit_1: int = 1, bit_2: int = 1) -> qiskit.result.counts.Counts: - """ - The input refer to the classical message - that you wants to send. {'00','01','10','11'} - result for default values: {11: 1000} - ┌───┐ ┌───┐ - qr_0: ─────┤ X ├──────────┤ X ├───── - ┌───┐└─┬─┘┌───┐┌───┐└─┬─┘┌───┐ - qr_1: ┤ H ├──■──┤ X ├┤ Z ├──■──┤ H ├ - └───┘ └───┘└───┘ └───┘ - cr: 2/══════════════════════════════ - Args: - bit_1: bit 1 of classical information to send. - bit_2: bit 2 of classical information to send. - Returns: - qiskit.result.counts.Counts: counts of send state. - >>> superdense_coding(0,0) - {'00': 1000} - >>> superdense_coding(0,1) - {'01': 1000} - >>> superdense_coding(-1,0) - Traceback (most recent call last): - ... - ValueError: inputs must be positive. - >>> superdense_coding(1,'j') - Traceback (most recent call last): - ... - TypeError: inputs must be integers. - >>> superdense_coding(1,0.5) - Traceback (most recent call last): - ... - ValueError: inputs must be exact integers. - >>> superdense_coding(2,1) - Traceback (most recent call last): - ... - ValueError: inputs must be less or equal to 1. - """ - if (type(bit_1) == str) or (type(bit_2) == str): - raise TypeError("inputs must be integers.") - if (bit_1 < 0) or (bit_2 < 0): - raise ValueError("inputs must be positive.") - if (math.floor(bit_1) != bit_1) or (math.floor(bit_2) != bit_2): - raise ValueError("inputs must be exact integers.") - if (bit_1 > 1) or (bit_2 > 1): - raise ValueError("inputs must be less or equal to 1.") - - # build registers - qr = QuantumRegister(2, "qr") - cr = ClassicalRegister(2, "cr") - - quantum_circuit = QuantumCircuit(qr, cr) - - # entanglement the qubits - quantum_circuit.h(1) - quantum_circuit.cx(1, 0) - - # send the information - c_information = str(bit_1) + str(bit_2) - - if c_information == "11": - quantum_circuit.x(1) - quantum_circuit.z(1) - elif c_information == "10": - quantum_circuit.z(1) - elif c_information == "01": - quantum_circuit.x(1) - else: - quantum_circuit.i(1) - - # unentangled the circuit - quantum_circuit.cx(1, 0) - quantum_circuit.h(1) - - # measure the circuit - quantum_circuit.measure(qr, cr) - - backend = Aer.get_backend("qasm_simulator") - job = execute(quantum_circuit, backend, shots=1000) - - return job.result().get_counts(quantum_circuit) - - -if __name__ == "__main__": - print(f"Counts for classical state send: {superdense_coding(1,1)}") From f8153491a67bcc6378b894ed1653266e5f46bcb9 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 23 Oct 2022 12:58:36 +0000 Subject: [PATCH 2/2] updating DIRECTORY.md --- DIRECTORY.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 70644d0639dc..d084a5a23f49 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -461,6 +461,7 @@ * [Similarity Search](machine_learning/similarity_search.py) * [Support Vector Machines](machine_learning/support_vector_machines.py) * [Word Frequency Functions](machine_learning/word_frequency_functions.py) + * [Xgboost Regressor](machine_learning/xgboost_regressor.py) * [Xgboostclassifier](machine_learning/xgboostclassifier.py) ## Maths @@ -536,7 +537,7 @@ * [Line Length](maths/line_length.py) * [Lucas Lehmer Primality Test](maths/lucas_lehmer_primality_test.py) * [Lucas Series](maths/lucas_series.py) - * [Maclaurin Sin](maths/maclaurin_sin.py) + * [Maclaurin Series](maths/maclaurin_series.py) * [Matrix Exponentiation](maths/matrix_exponentiation.py) * [Max Sum Sliding Window](maths/max_sum_sliding_window.py) * [Median Of Two Arrays](maths/median_of_two_arrays.py) @@ -582,6 +583,7 @@ * [P Series](maths/series/p_series.py) * [Sieve Of Eratosthenes](maths/sieve_of_eratosthenes.py) * [Sigmoid](maths/sigmoid.py) + * [Signum](maths/signum.py) * [Simpson Rule](maths/simpson_rule.py) * [Sin](maths/sin.py) * [Sock Merchant](maths/sock_merchant.py) @@ -590,6 +592,7 @@ * [Sum Of Arithmetic Series](maths/sum_of_arithmetic_series.py) * [Sum Of Digits](maths/sum_of_digits.py) * [Sum Of Geometric Progression](maths/sum_of_geometric_progression.py) + * [Sum Of Harmonic Series](maths/sum_of_harmonic_series.py) * [Sylvester Sequence](maths/sylvester_sequence.py) * [Test Prime Check](maths/test_prime_check.py) * [Trapezoidal Rule](maths/trapezoidal_rule.py)