pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/indisoluble/SwiftQuantumComputing

all" rel="stylesheet" href="https://github.githubassets.com/assets/primer-0b53c3bf3393e2ed.css" /> GitHub - indisoluble/SwiftQuantumComputing: Quantum circuit simulator in Swift
Skip to content

indisoluble/SwiftQuantumComputing

Repository files navigation

Quantum circuit simulator in Swift

CI Status codecov platforms Documentation

Usage

Circuit

Usage

Check code in Circuit.playground.

Circuit with noise

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

Check code in NoiseCircuit.playground.

Performance

~/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):

sudo apt-get install libblas-dev liblapacke-dev

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

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy