A quantum circuit simulator in Swift
In this repository you can find a quantum circuit simulator written in Swift and speeded up with Accelerate.framework in iOS/macOS and BLAS in Linux. Along side the simulator there is also a genetic algorithm to automatically generate circuits able to solve a given quantum problem.
The code written so far is mostly based on the content of: Quantum Computing for Computer Scientists, with a few tips from Automatic Quantum Computer Programming: A Genetic Programming Approach. It is also inspired by IBM Qiskit.
To create a circuit gate by gate:
DeutschAlgorithm.playground for the actual code.
Previous playground shows how to produce a statevector for a given circuit. To get the unitary matrix that represents a circuit:
Full code is in
Genetic.playground to see how to configure the genetic algorithm to produce a quantum circuit:
This dependency is reflected in
Package.swift with CBLAS-Linux, which in turn expects to find the following file:
/usr/include/x86_64-linux-gnu/cblas-netlib.h. So, after installing BLAS (in case it is not already there):
sudo apt-get install libblas-dev
cblas-netlib.h is in the expected location.