package qcaml

  1. Overview
  2. Docs
OCaml library for quantum computing simulation

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v1.0.0.tar.gz
md5=9a6fe4303f5e6bc1cbc159fc3e8992aa
sha512=e428ad7f3c0c9529c77c6d397c9c352a3ab883f9b94a9e9a49b57bea7a2b7119786da3647b9082b3ea686a7a9a9df6ea49d133d61bbc1e43a6bbb8bc20e52482

doc/README.html

QCaml logo

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.

License OCaml GitHub Actions Workflow Status GitHub Release

Presentation

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.

Installation

Prerequisites

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 raylib

Install from OPAM (recommended)

QCaml is now available on the official OPAM repository, so you can install it directly:

$ opam install qcaml

Develop locally

If 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 .

Quick start

Try this simple example by running dune exec examples/superposition.exe to visualize a qubit in superposition on the Bloch sphere:

(* examples/superposition.ml *)
open Quantum
let () =
  let reg = Register.allocate 1 in
  Register.display_qubit reg 0;
  Gate.h reg 0;
  Register.display_qubit reg 0;
  Visualization.plot_bloch reg 0 ()
Bloch Sphere

Architecture

QCaml architecture diagram

Features

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

Documentation

API Reference: Generated documentation at _build/default/_doc/_html/index.html (after running dune build @doc) or see online documentation )

Resources

Quantum Computing Course – Math and Theory for Beginners : https://youtu.be/tsbCSkvHhMo?si=XTbz10_b1v1aAS-3