项目作者: indisoluble

项目描述 :
Quantum circuit simulator in Swift
高级语言: Swift
项目地址: git://github.com/indisoluble/SwiftQuantumComputing.git
创建时间: 2018-08-07T18:04:38Z
项目社区:https://github.com/indisoluble/SwiftQuantumComputing

开源协议:Apache License 2.0

下载


Quantum circuit simulator in Swift

CI Status
codecov
platforms
Documentation

Usage

Circuit

Usage

Check code in Circuit.playground.

Circuit with noise

  1. import SwiftQuantumComputing // for macOS
  2. //: 1. Compose a list of quantum gates & noises
  3. let quantumOperators: [QuantumOperatorConvertible] = [
  4. Gate.hadamard(target: 0),
  5. Noise.bitFlip(probability: 0.35, target: 0),
  6. Gate.phaseShift(radians: 0.25, target: 2),
  7. Noise.phaseDamping(probability: 0.75, target: 2),
  8. Gate.controlled(gate: .hadamard(target: 1), controls: [2, 0]),
  9. Noise.bitFlip(probability: 0.8, target: 1)
  10. ]
  11. //: 2. Build a quantum circuit with noise using the list
  12. let circuit = MainNoiseCircuitFactory().makeNoiseCircuit(quantumOperators: quantumOperators)
  13. //: 3. Use the quantum circuit with noise
  14. let result = try circuit.densityMatrix().get()
  15. print("Density matrix: \(result)\n")
  16. print("Probabilities: \(result.probabilities())\n")

Check code in NoiseCircuit.playground.

Performance

  1. ~/SwiftQuantumComputing % swift run sqc-measure-performance

Run this application to check the performance of this simulator in your computer. Execute swift run sqc-measure-performance -h to see all available options.

Check code in SQCMeasurePerformance/main.swift.

Algorithms

  • Use a genetic algorithm to automatically generate a quantum circuit - Check example in Genetic.playground.
  • Two-level decomposition: Decompose any gate into an equivalent sequence of not gates and fully controlled phase shifts, z-rotations, y-rotations & not gates - Check example in TwoLevelDecomposition.playground.

Other algorithms

More examples

Documentation

Documentation for the project can be found here.

References

SwiftPM dependencies

Linux

This package depends on BLAS & LAPACK if running on Linux, more exactly, Ubuntu.

These dependencies are reflected in Package.swift with:

  • CBLAS-Linux, which in turn expects to find: /usr/include/x86_64-linux-gnu/cblas-netlib.h
  • CLapacke-Linux, which in turn expects to find: /usr/include/lapacke.h

So, after installing BLAS & LAPACK (in case they are not already there):

  1. sudo apt-get install libblas-dev liblapacke-dev

Check cblas-netlib.h & lapacke.h are in the expected locations.