Liking cljdoc? Tell your friends :D

QClojure

The QClojure library provides a Clojure interface to quantum computing concepts. It allows us to create and manipulate quantum states, gates, and circuits in a functional programming style. QClojure can also be used to simulate quantum circuits and, by implementing backends, run them on quantum hardware.

The API is in alpha state, I expect the api to change!

Clojars Project cljdoc badge GitHub

Main Features of QClojure

  1. Pure Functional Quantum Circuit Construction

    Build quantum circuits using immutable data structures and functional composition with convenience gate functions (H, X, Y, Z, CNOT, etc.)

  2. Comprehensive Gate Library

    Support for 20+ quantum gates including single-qubit gates (Pauli, Hadamard, phase), controlled gates (CNOT, CZ, CY), rotation gates (RX, RY, RZ), and multi-qubit gates (Toffoli, Fredkin, SWAP)

  3. Quantum Algorithm Implementations

    Built-in implementations of classic quantum algorithms including Deutsch, Grover's search, Bernstein-Vazirani, and Simon's algorithms

  4. Extensible Backend System

    Protocol-based architecture allowing integration with different quantum simulators and hardware backends

  5. Circuit Transformation & Optimization

    Automatic gate decomposition and circuit transformation to match backend-supported gate sets

  6. Local Quantum Simulator Backend

    High-performance local simulator with job submission, status tracking, and statistical measurement results with configurable shot counts

  7. OpenQASM 2.0 Integration

    Bidirectional conversion between quantum circuits and OpenQASM format for interoperability with other quantum computing platforms

  8. Visualization

    Vizualization of quantum states and quantum circuits as ASCII, SVG or HTML.

  9. Comprehensive Testing & Validation

    Extensive test suite with statistical validation of quantum circuit behavior and measurement outcomes

Usage

QClojure is a library to be used in programs or interactive within the REPL.

This small example show the creation of a quantum circuit in a functional way and the execution on the simulator.

(require '[org.soulspace.qclojure.domain.quantum-circuit :as qc])
(require '[org.soulspace.qclojure.application.quantum-backend :as qb])
(require '[org.soulspace.qclojure.adapter.backend.quantum-simulator :as sim])

;; Create a simple circuit
(def circuit (-> (qc/create-circuit 2)
                 (qc/h-gate 0)
                 (qc/cnot-gate 0 1)))

;; Run the circuit on the simulator
(def simulator (sim/create-simulator))
(def result (qb/execute-circuit simulator circuit {:shots 1000}))

;; Examine the results
(:final-state result)
(:measurement-results result)

Examples

Some examples are provided in the examples folder.

Build

QClojure is currently build with Leiningen.

Compile the code with:

lein compile

Run the test suite with:

lein test

Copyright

© 2025 Ludger Solbach

License

Eclipse Public License 1.0 (EPL1.0)

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close