fwcd / quantumlisp Goto Github PK
View Code? Open in Web Editor NEWQuantum computing simulation for Common Lisp
License: MIT License
Quantum computing simulation for Common Lisp
License: MIT License
Below is some quick code I've put together while playing with this library. I've just started reading up on Quantum computing, so I'm not 100% clear on how the kronecker product is to be applied when working with a subset of qubits, but I've validated that it works properly for the spanning/parallel case. I.e. apply-qgate with H*H matrix works properly for the Hadamard to a two-qubit pair.
; More efficient construction of the superposition. On my test system constructing a 14-bit
; superposition takes 3.5 seconds with the original code. This code takes 3 milliseconds.
(defun superpos (bits &optional (zero 0))
(let ((outrep (make-list (expt 2 (length bits)) :initial-element zero))
(index (reduce (lambda (current previous) (+ (* current 2) previous)) bits)))
(setf (elt outrep index) (+ zero 1))
outrep))
; Kronecker / tensor product
(defun kronecker-product(A B)
(matrix-create
(lambda (i j)
(let ((p (matrix-row-count B))
(q (matrix-column-count B)))
(* (elt (elt A (floor i p)) (floor j q))
(elt (elt B (mod i p)) (mod j q)))))
(* (matrix-row-count A) (matrix-row-count B))
(* (matrix-column-count A) (matrix-column-count B))))
Integrate this project with QuantumFlow and investigate support for other quantum computing toolkits like Q# or QISKit.
Implement tensor multiplication and factorization to operate separately on qubit superpositions.
Currently an array of 3 qubits (thus a vector of 2^3 = 8 possible states) can only be used to apply three-qubit-gates (CCNOT or CSWAP), because the matrix representing the gate has to have the same side length as the superposition vector. To allow 1-qubit-gates (like the Pauli-X gate) to operate on multiple qubits, the tensor product is necessary to appropriately modify the gate matrix.
Still, the size of the superposition vector will grow exponentially to the amount of qubits. As long as these qubits are not entangled, they could be treated (and measured) separately. To implement this, tensor factorization is required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.