Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fwcd/swift-quantum
Quantum computing simulation library for Swift
https://github.com/fwcd/swift-quantum
quantum-computing swift
Last synced: 10 days ago
JSON representation
Quantum computing simulation library for Swift
- Host: GitHub
- URL: https://github.com/fwcd/swift-quantum
- Owner: fwcd
- License: mpl-2.0
- Created: 2024-07-16T15:20:15.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-17T20:12:46.000Z (3 months ago)
- Last Synced: 2024-10-02T12:41:16.503Z (3 months ago)
- Topics: quantum-computing, swift
- Language: Swift
- Homepage: https://fwcd.github.io/swift-quantum/documentation/quantum
- Size: 87.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swift Quantum
[![Build](https://github.com/fwcd/swift-quantum/actions/workflows/build.yml/badge.svg)](https://github.com/fwcd/swift-quantum/actions/workflows/build.yml)
[![Docs](https://github.com/fwcd/swift-quantum/actions/workflows/docs.yml/badge.svg)](https://fwcd.github.io/swift-quantum/documentation/quantum)A library for simulating quantum computations in Swift.
The library is split into two modules:
- `Quantum`, the main library
- `QuantumBuilder`, an ergonomic (result builder-based) DSL for expressing quantum compuations`QuantumBuilder` re-exports `Quantum`, so you only have to import one of the two, depending on what you need.
## Example
A simple coin flip that outputs `true` or `false` with equal probability can be implemented as follows:
```swift
import QuantumBuilderlet program = QuantumProgram {
Hadamard()
Measure()
}for _ in 0..<8 {
print(try program.measuredState(for: [false]))
}
```To try this example, run
```sh
swift run CoinFlip
```An example output would be:
```
[true]
[true]
[true]
[false]
[false]
[true]
[false]
[true]
```More examples can be found under [`Snippets`](Snippets).