qube-core
v0.1.1
Published
Lightweight JS quantum simulator + circuit builder + example algorithms (Grover, QFT). Modular backend adapter for real quantum providers.
Maintainers
Readme
qube-core
Lightweight JavaScript quantum simulator + circuit builder + sample algorithms (Grover, QFT).
Features
- Pure-JS state-vector simulator (no native deps)
- Circuit builder (expand single-qubit gates, controlled gates)
- Algorithms: Grover (single marked item), QFT (dense matrix builder)
- Simple simulator API with measurement sampling
- Modular design for potential backend adapters
Note: This is a simulator. Real quantum speedups require hardware and problem-specific constraints.
Quickstart
1. Installation (Assuming you are in the project root)
# install dependencies (if any) and link the package
npm install
# To run the example:
npm run example
# To run the basic test:
npm run test2.Usage Example
- You can import the core classes and functions directly from the package entry point (index.js).
import { buildGroverCircuit } from 'qube-core';
import { Simulator } from 'qube-core';
import { basis } from 'qube-core';
// Build a 3-qubit Grover circuit to find the marked state '5' (|101>)
const nQubits = 3;
const markedStateIndex = 5;
const circ = buildGroverCircuit(nQubits, markedStateIndex);
const sim = new Simulator(nQubits);
// Load the initial state |000>
sim.loadState(basis(1 << nQubits, 0));
// Run the circuit
sim.runCircuit(circ);
// Sample the result 1024 times
const results = sim.sample(1024);
console.log(results);
// Expected output: A Map where key 5 has the highest count (e.g., 1020)