C Quantum Computing

Pure-Quanta

A quantum computer simulator in pure C, using state vectors of double-precision complex numbers.

C Quantum Computing Simulation
GitHub →
2n complex amplitudes per n qubits
5 quantum gates implemented
0 dependencies

Overview

Pure-Quanta is a quantum computer simulator written in pure C. Rather than using a library or framework, the simulator represents quantum state directly as a vector of 2n double-precision complex numbers and applies gate operations as linear transformations over that vector. This makes the quantum mechanics fully explicit in the code.

The project was motivated by wanting to understand quantum computing fundamentals from first principles — not just calling qiskit.execute(), but actually implementing the matrix operations that underpin every quantum gate.

How It Works

An n-qubit system is represented as a state vector of 2n complex amplitudes. The system initialises in the |0…0⟩ state. Gate operations are applied by transforming the state vector according to the gate's unitary matrix. All arithmetic is double-precision complex number arithmetic in C.

Gates Implemented

  • Hadamard (H) — creates equal superposition: |0⟩ → (|0⟩ + |1⟩) / √2
  • Pauli-X — quantum NOT gate: flips |0⟩ ↔ |1⟩
  • Pauli-Y — phase-shifted flip with ±i factors
  • Pauli-Z — phase flip: applies −1 phase to |1⟩
  • CNOT — two-qubit controlled-NOT; flips target qubit when control is |1⟩

Usage

make
./pure-quanta 4    # simulate a 4-qubit system

Planned

  • Quantum measurement with probabilistic state collapse
  • Additional gates and circuit composition
  • Performance optimisations for larger qubit counts