crysquant
Version, currently main branch1 version
- main branchlatestDec 7, 2020
github.com/Hadeweka/CrysQuant
Quantum gate simulation library for Crystal
Installation
# Add this to your shard.yml
dependencies:
crysquant:
github: Hadeweka/CrysQuant
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
>= 0.35.1- License
- MIT
- Author
- Hadeweka
Dependencies
Runtime Dependencies
- matrix*github: Exilor/matrix, branch: master
README
CrysQuant
CrysQuant is a quantum gate simulation library in development.
Description
CrysQuant is based on an older project (https://github.com/Hadeweka/HDWQuantum), which was written in Ruby at that time. However, the computation speed of Crystal allows for much more complex scenarios than in Ruby.
Features
- Basic range of quantum gates
- Custom quantum gates can be added easily using matrices
- Measuring of registers (with and without wave-function collapse)
- Inspection of the full quantum state of registers
Installing
CrysQuant is a shard which can be installed by including it into your shard.yml file.
How to use
The following code creates a 5-Qubit register with the initial state |11000⟩ and then puts the 0th bit into a superposition of 0 and 1 using a Hadamard gate:
qreg = CrysQuant::Register.new(5, 0b11000)
qreg[0].apply(CrysQuant::Gate::Hadamard)
puts 10000.times.sum {|i| qreg.probe} / 10000
The last line probes the state of the register 10000 times and averages the results, without collapsing the quantum state. Since the initial state |11000⟩ equals the decimal number 24, and the other part of the superposition has the state |11001⟩ (representing 25), the result will be approximately 24.5.
Note that quantum gate computations require absurdly large matrices, so your memory will probably overflow at about 30 qubits, maybe even earlier. Generally, computations up to about 15 qubits should not pose any problems on regular machines, while higher numbers might lead to massive calculation times.
Roadmap
- [X] Fast Qubit swapping without matrices
- [X] Memory-efficient gate operations
- [ ] Measurements of single Qubits
- [ ] Proc-powered matrices
- [ ] Support for Anyolite to allow for scripting
- [ ] Add examples and specs
- [ ] Parallelization
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- Dec 7, 2020
- Crystal
>= 0.35.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/Hadeweka/CrysQuant
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 31, 2026
- Synced
- Aug 31, 2026
- Versions
- 1