{"id":13449383,"url":"https://github.com/adamisntdead/QuSimPy","last_synced_at":"2025-03-22T22:32:52.161Z","repository":{"id":50088515,"uuid":"66118414","full_name":"adamisntdead/QuSimPy","owner":"adamisntdead","description":"A Multi-Qubit Ideal Quantum Computer Simulator","archived":false,"fork":false,"pushed_at":"2021-06-04T17:57:44.000Z","size":53,"stargazers_count":719,"open_issues_count":2,"forks_count":66,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-10-25T03:58:54.783Z","etag":null,"topics":["quantum-computing","quantum-simulator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adamisntdead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-19T23:34:25.000Z","updated_at":"2024-08-23T00:26:59.000Z","dependencies_parsed_at":"2022-09-19T07:30:32.128Z","dependency_job_id":null,"html_url":"https://github.com/adamisntdead/QuSimPy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamisntdead%2FQuSimPy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamisntdead%2FQuSimPy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamisntdead%2FQuSimPy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamisntdead%2FQuSimPy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamisntdead","download_url":"https://codeload.github.com/adamisntdead/QuSimPy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221840634,"owners_count":16889834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["quantum-computing","quantum-simulator"],"created_at":"2024-07-31T06:00:36.780Z","updated_at":"2024-10-28T14:30:49.729Z","avatar_url":"https://github.com/adamisntdead.png","language":"Python","funding_links":[],"categories":["Python","Abandoned projects"],"sub_categories":[],"readme":"# QuSim.py\n\n[![Build Status](https://travis-ci.org/adamisntdead/QuSimPy.svg?branch=master)](https://travis-ci.org/adamisntdead/QuSimPy)\n\nQusim.py is a toy multi-qubit quantum computer simulator, written in 150 lines of python\n\nThis code makes it easy for you to see how a quantum computer computes by\nfollowing the linear algebra!\n\n```python\nfrom QuSim import QuantumRegister\n\n#############################################\n#                 Introduction              #\n#############################################\n# Here Will Be A Few Example of Different\n# Quantum States / Algorithms, So You Can\n# Get A Feel For How The Module Works, and  \n# Some Algorithmic Ideas\n\n\n#############################################\n#            Quantum Measurement            #\n#############################################\n# This experiment will prepare 2 states, of a\n# Single qubit, and of 5 qubits, and will just\n# Measure them\n\nOneQubit = QuantumRegister(1)  # New Quantum Register of 1 Qubit\nprint('One Qubit: ' + OneQubit.measure())  # Should Print 'One Qubit: 0'\n\nFiveQubits = QuantumRegister(5)  # New Quantum Register of 5 Qubits\n# Should Print 'Five Qubits: 00000'\nprint('Five Qubits: ' + FiveQubits.measure())\n\n#############################################\n#                 Swap 2 Qubits             #\n#############################################\n# Here, We Will Apply a Pauli-X Gate / NOT Gate\n# To the first qubit, and then after the algorithm,\n# it will be swapped to the second qubit.\n\nSwap = QuantumRegister(2)  # New Quantum Register of 2 qubits\nSwap.applyGate('X', 1)  # Apply The NOT Gate. If Measured Now, it should be 10\n\n# Start the swap algorithm\nSwap.applyGate('CNOT', 1, 2)\nSwap.applyGate('H', 1)\nSwap.applyGate('H', 2)\nSwap.applyGate('CNOT', 1, 2)\nSwap.applyGate('H', 1)\nSwap.applyGate('H', 2)\nSwap.applyGate('CNOT', 1, 2)\n# End the swap algorithm\n\nprint('SWAP: |' + Swap.measure() + '\u003e')  # Measure the State, Should be 01\n\n#############################################\n#               Fair Coin Flip              #\n#############################################\n# Shown in this 'Experiment', is a so called 'Fair Coin Flip',\n# Where a state will be prepared, that has an equal chance of\n# Flipping to Each Possible State. to do this, the Hadamard\n# Gate will be used.\n\n# New Quantum Register of 1 Qubit (As a coin has only 2 states)\nFairCoinFlip = QuantumRegister(1)\n# If measured at this point, it should be |0\u003e\n\n# Apply the hadamard gate, now theres an even chance of measuring 0 or 1\nFairCoinFlip.applyGate('H', 1)\n\n# Now, the state will be measured, flipping the state to\n# either 0 or 1. If its 0, we will say \"Heads\", or if its\n# 1, we will say \"Tails\"\nFairCoinFlipAnswer = FairCoinFlip.measure()  # Now its flipped, so we can test\nif FairCoinFlipAnswer == '0':\n    print('FairCoinFlip: Heads')\nelif FairCoinFlipAnswer == '1':\n    print('FairCoinFlip: Tails')\n\n#############################################\n#             CNOT Gate                     #\n#############################################\n# In this experiment, 4 states will be prepared, {00, 01, 10, 11}\n# And then the same CNOT Gate will be run on them,\n# To Show The Effects of the CNOT. The Target Qubit will be 2, and the control 1\n\n# New Quantum Register of 2 Qubits, done 4 times.\n# If any are measured at this time, the result will be 00\nZeroZero = QuantumRegister(2)\nZeroOne = QuantumRegister(2)\nOneZero = QuantumRegister(2)\nOneOne = QuantumRegister(2)\n\n# Now prepare Each Into The State Based On Their Name\n# ZeroZero Will be left, as thats the first state anyway\nZeroOne.applyGate('X', 2)\nOneZero.applyGate('X', 1)\nOneOne.applyGate('X', 1)\nOneOne.applyGate('X', 2)\n\n# Now, a CNOT Will Be Applied To Each.\nZeroZero.applyGate('CNOT', 1, 2)\nZeroOne.applyGate('CNOT', 1, 2)\nOneZero.applyGate('CNOT', 1, 2)\nOneOne.applyGate('CNOT', 1, 2)\n\n# Print the results.\nprint('CNOT on 00: |' + ZeroZero.measure() + '\u003e')\nprint('CNOT on 01: |' + ZeroOne.measure() + '\u003e')\nprint('CNOT on 10: |' + OneZero.measure() + '\u003e')\nprint('CNOT on 11: |' + OneOne.measure() + '\u003e')\n```\n\nLargely based on the code from [corbett/QuantumComputing](https://github.com/corbett/QuantumComputing).\n\nIf you are interested in a efficient, high performance, hardware accelerated\nquantum computer simulator written in Rust, please check out [QCGPU](https://github.com/qcgpu/qcgpu-rust)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamisntdead%2FQuSimPy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamisntdead%2FQuSimPy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamisntdead%2FQuSimPy/lists"}