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 an experimental library for simulating quantum algorithms. This library is currently under development. Among the MVP's features are qubit declaration, application of classical gates (X,Y,Z,H), measurement, and visualization.
Important
Status: This library is currently in early development and may change significantly.
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_ppxThe 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/bloch_sphere.exe to visualize a superposition state on the Bloch sphere:
(* examples/bloch_sphere.ml *)
open Quantum
let () =
let q = Qubit.plus () in
Visualization.plot_bloch q;
Measurement.measure q;
Printf.printf "%s\n" (Qubit.print () q); |
|
| 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 |
| Advanced Gate | In progress.. | Extended gate set (Phase and rotation gates) |
| Circuit Builder | ○ Planned | High-level API for composing and optimizing quantum circuits |
| Multi-Qubit Operations | ○ Planned | Efficient tensor product operations for n-qubit systems |
| Simulator | ○ Planned (I will never have time) | Export circuits to standard formats (QASM, diagram generation) |
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


