Skip to content

elias-utf8/qcaml

Repository files navigation

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 CI Status

Presentation

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.


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

Build and install

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/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);
Bloch Sphere

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
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)

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

About

A lightweight OCaml library to experiment with quantum states, gates and measurements.

Topics

Resources

License

Stars

Watchers

Forks