All Projects → adamisntdead → Qusimpy

adamisntdead / Qusimpy

Licence: agpl-3.0
A Multi-Qubit Ideal Quantum Computer Simulator

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Qusimpy

Blueqat
Quantum Computer Library for Everyone
Stars: ✭ 298 (-56.69%)
Mutual labels:  quantum-computing
Quantumcomputingbook
Companion site for the textbook Quantum Computing: An Applied Approach
Stars: ✭ 386 (-43.9%)
Mutual labels:  quantum-computing
Quantumcomputing
This is an implementation of IBM's Quantum Experience in simulation; a 5-qubit quantum computer with a limited set of gates. Please cite me if you end up using this academically.
Stars: ✭ 534 (-22.38%)
Mutual labels:  quantum-computing
Quantumlibraries
Q# libraries for the Quantum Development Kit
Stars: ✭ 316 (-54.07%)
Mutual labels:  quantum-computing
Quilc
The @rigetti optimizing Quil compiler.
Stars: ✭ 336 (-51.16%)
Mutual labels:  quantum-computing
Qiskit Api Py
This repository and the qiskit-api-py package are deprecated, and no longer supported. A Python library for the Quantum Experience API
Stars: ✭ 458 (-33.43%)
Mutual labels:  quantum-computing
Grassmann.jl
⟨Leibniz-Grassmann-Clifford⟩ differential geometric algebra / multivector simplicial complex
Stars: ✭ 289 (-57.99%)
Mutual labels:  quantum-computing
Quirk
A drag-and-drop quantum circuit simulator that runs in your browser. A toy for exploring and understanding small quantum circuits.
Stars: ✭ 593 (-13.81%)
Mutual labels:  quantum-computing
Qcgpu
High Performance Tools for Quantum Computing
Stars: ✭ 380 (-44.77%)
Mutual labels:  quantum-computing
Yao.jl
Extensible, Efficient Quantum Algorithm Design for Humans.
Stars: ✭ 514 (-25.29%)
Mutual labels:  quantum-computing
Quantum
Microsoft Quantum Development Kit Samples
Stars: ✭ 3,453 (+401.89%)
Mutual labels:  quantum-computing
Grove
Quantum algorithms built using pyQuil.
Stars: ✭ 332 (-51.74%)
Mutual labels:  quantum-computing
Strawberryfields
Strawberry Fields is a full-stack Python library for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.
Stars: ✭ 505 (-26.6%)
Mutual labels:  quantum-computing
Qmasm
Quantum macro assembler for D-Wave systems
Stars: ✭ 315 (-54.22%)
Mutual labels:  quantum-computing
Cs Video Courses
List of Computer Science courses with video lectures.
Stars: ✭ 27,209 (+3854.8%)
Mutual labels:  quantum-computing
Qvm
The @rigetti high-performance quantum virtual machine.
Stars: ✭ 300 (-56.4%)
Mutual labels:  quantum-computing
Qiskit Textbook
A university quantum algorithms/computation course supplement based on Qiskit
Stars: ✭ 404 (-41.28%)
Mutual labels:  quantum-computing
Awesome Quantum Software
Curated list of open-source quantum software projects.
Stars: ✭ 647 (-5.96%)
Mutual labels:  quantum-computing
Openqasm
Gate and operation specification for quantum circuits
Stars: ✭ 582 (-15.41%)
Mutual labels:  quantum-computing
Qiskit Aqua
Quantum Algorithms & Applications in Python
Stars: ✭ 514 (-25.29%)
Mutual labels:  quantum-computing

QuSim.py

Build Status

Qusim.py is a toy multi-qubit quantum computer simulator, written in 150 lines of python

This code makes it easy for you to see how a quantum computer computes by following the linear algebra!

from QuSim import QuantumRegister

#############################################
#                 Introduction              #
#############################################
# Here Will Be A Few Example of Different
# Quantum States / Algorithms, So You Can
# Get A Feel For How The Module Works, and  
# Some Algorithmic Ideas


#############################################
#            Quantum Measurement            #
#############################################
# This experiment will prepare 2 states, of a
# Single qubit, and of 5 qubits, and will just
# Measure them

OneQubit = QuantumRegister(1)  # New Quantum Register of 1 Qubit
print('One Qubit: ' + OneQubit.measure())  # Should Print 'One Qubit: 0'

FiveQubits = QuantumRegister(5)  # New Quantum Register of 5 Qubits
# Should Print 'Five Qubits: 00000'
print('Five Qubits: ' + FiveQubits.measure())

#############################################
#                 Swap 2 Qubits             #
#############################################
# Here, We Will Apply a Pauli-X Gate / NOT Gate
# To the first qubit, and then after the algorithm,
# it will be swapped to the second qubit.

Swap = QuantumRegister(2)  # New Quantum Register of 2 qubits
Swap.applyGate('X', 1)  # Apply The NOT Gate. If Measured Now, it should be 10

# Start the swap algorithm
Swap.applyGate('CNOT', 1, 2)
Swap.applyGate('H', 1)
Swap.applyGate('H', 2)
Swap.applyGate('CNOT', 1, 2)
Swap.applyGate('H', 1)
Swap.applyGate('H', 2)
Swap.applyGate('CNOT', 1, 2)
# End the swap algorithm

print('SWAP: |' + Swap.measure() + '>')  # Measure the State, Should be 01

#############################################
#               Fair Coin Flip              #
#############################################
# Shown in this 'Experiment', is a so called 'Fair Coin Flip',
# Where a state will be prepared, that has an equal chance of
# Flipping to Each Possible State. to do this, the Hadamard
# Gate will be used.

# New Quantum Register of 1 Qubit (As a coin has only 2 states)
FairCoinFlip = QuantumRegister(1)
# If measured at this point, it should be |0>

# Apply the hadamard gate, now theres an even chance of measuring 0 or 1
FairCoinFlip.applyGate('H', 1)

# Now, the state will be measured, flipping the state to
# either 0 or 1. If its 0, we will say "Heads", or if its
# 1, we will say "Tails"
FairCoinFlipAnswer = FairCoinFlip.measure()  # Now its flipped, so we can test
if FairCoinFlipAnswer == '0':
    print('FairCoinFlip: Heads')
elif FairCoinFlipAnswer == '1':
    print('FairCoinFlip: Tails')

#############################################
#             CNOT Gate                     #
#############################################
# In this experiment, 4 states will be prepared, {00, 01, 10, 11}
# And then the same CNOT Gate will be run on them,
# To Show The Effects of the CNOT. The Target Qubit will be 2, and the control 1

# New Quantum Register of 2 Qubits, done 4 times.
# If any are measured at this time, the result will be 00
ZeroZero = QuantumRegister(2)
ZeroOne = QuantumRegister(2)
OneZero = QuantumRegister(2)
OneOne = QuantumRegister(2)

# Now prepare Each Into The State Based On Their Name
# ZeroZero Will be left, as thats the first state anyway
ZeroOne.applyGate('X', 2)
OneZero.applyGate('X', 1)
OneOne.applyGate('X', 1)
OneOne.applyGate('X', 2)

# Now, a CNOT Will Be Applied To Each.
ZeroZero.applyGate('CNOT', 1, 2)
ZeroOne.applyGate('CNOT', 1, 2)
OneZero.applyGate('CNOT', 1, 2)
OneOne.applyGate('CNOT', 1, 2)

# Print the results.
print('CNOT on 00: |' + ZeroZero.measure() + '>')
print('CNOT on 01: |' + ZeroOne.measure() + '>')
print('CNOT on 10: |' + OneZero.measure() + '>')
print('CNOT on 11: |' + OneOne.measure() + '>')

Largely based on the code from corbett/QuantumComputing.

If you are interested in a efficient, high performance, hardware accelerated quantum computer simulator written in Rust, please check out QCGPU

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].