Page
Library
Module
Module type
Parameter
Class
Class type
Source

A lightweight OCaml library to experiment with quantum states, gates and measurements. For learning quantum computing concepts and visualizing qubit states on the Bloch sphere.
QCaml for Quantum (O)Caml is a library for simulating quantum algorithms. It provides n-qubit registers, quantum gates (Pauli, Hadamard, rotations, CNOT), measurement with state collapse, and interactive Bloch sphere visualization.
You need the opam package manager to install the OCaml build tools.
$ sudo apt install opam # debian/ubuntu
$ opam init
$ opam switch create 5.2.0
$ eval $(opam env)
$ opam install dune odoc alcotest bisect_ppx raylibQCaml is now available on the official OPAM repository, so you can install it directly:
$ opam install qcamlIf you want to work on QCaml locally (for development, testing, or contributing), you can still clone and build the repository manually.
The following will clone the repository, build QCaml and install it into your opam.
$ git clone https://github.com/elias-utf8/qcaml.git
$ cd qcaml/
$ make
$ opam install .Try this simple example by running dune exec examples/superposition.exe to visualize a qubit in superposition on the Bloch sphere:
|
|
| Feature | Status | Description |
|---|---|---|
| Qubit Initialization | ✓ Completed | Single and multi-qubit state initialization with arbitrary amplitudes |
| Basic Quantum Gates | ✓ Completed | Implementation of fundamental gates (Hadamard, Pauli-X/Y/Z) |
| Quantum Measurements | ✓ Completed | Computational basis measurements with probability calculations |
| Bloch sphere visualization | ✓ Completed | Visualization of qubit states on the Bloch sphere |
| Rotation Gates | ✓ Completed | Rx, Ry, Rz with arbitrary angle rotations |
| Multi-Qubit Operations | ✓ Completed | N-qubit registers with CNOT entangling gate |
| Simulator | ○ Planned | Circuit builder API, QASM export |
API Reference: Generated documentation at _build/default/_doc/_html/index.html (after running dune build @doc) or see online documentation )
Quantum Computing Course – Math and Theory for Beginners : https://youtu.be/tsbCSkvHhMo?si=XTbz10_b1v1aAS-3