@ruvector/ruqu 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +22 -26
- package/bin/cli.js +170 -100
- package/package.json +13 -4
- package/wasm/package.json +1 -0
- package/wasm/ruqu_wasm.d.ts +207 -0
- package/wasm/ruqu_wasm.js +672 -0
- package/wasm/ruqu_wasm_bg.wasm +0 -0
- package/wasm/ruqu_wasm_bg.wasm.d.ts +38 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Ruvector Team
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ruvector Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,39 +1,35 @@
|
|
|
1
|
-
# ruqu
|
|
1
|
+
# @ruvector/ruqu
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
witness-signed evolution log.
|
|
3
|
+
**Quantum computing from your terminal** — a state-vector quantum circuit simulator compiled to
|
|
4
|
+
**WebAssembly** (the pure-Rust [`ruqu`](https://github.com/ruvnet/ruqu) crates), wrapped in a
|
|
5
|
+
[metaharness](https://github.com/ruvnet/agent-harness-generator) agent CLI.
|
|
7
6
|
|
|
8
7
|
```bash
|
|
9
|
-
npx @ruvector/ruqu
|
|
10
|
-
npx @ruvector/ruqu
|
|
8
|
+
npx @ruvector/ruqu capabilities # what it can do
|
|
9
|
+
npx @ruvector/ruqu simulate --qubits 4 # GHZ state-vector simulation
|
|
10
|
+
npx @ruvector/ruqu grover --qubits 3 --target 5
|
|
11
|
+
npx @ruvector/ruqu qaoa --nodes 4 # QAOA MaxCut on a ring
|
|
12
|
+
npx @ruvector/ruqu doctor # verify kernel + quantum WASM
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
## Commands
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
npm install -g @ruvector/ruqu
|
|
17
|
-
ruqu doctor
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Agents
|
|
21
|
-
|
|
22
|
-
| Agent | Role |
|
|
17
|
+
| Command | What it does |
|
|
23
18
|
|---|---|
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
19
|
+
| `simulate [--qubits N]` | Run a GHZ/Bell circuit on the WASM state-vector simulator (up to 25 qubits). |
|
|
20
|
+
| `grover [--qubits N --target T --seed S]` | Grover amplitude amplification / search. |
|
|
21
|
+
| `qaoa [--nodes N --p P]` | QAOA MaxCut on a ring graph. |
|
|
22
|
+
| `capabilities` | List gates, algorithms, qubit/memory limits. |
|
|
23
|
+
| `init` · `doctor` | Boot / verify the agent-harness kernel **and** the quantum WASM. |
|
|
24
|
+
| `version` | Kernel + WASM versions. |
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
Gates: `h x y z s t rx ry rz cnot cz swap rzz measure reset barrier`. Up to **25 qubits**.
|
|
29
27
|
|
|
30
|
-
##
|
|
28
|
+
## How it works
|
|
31
29
|
|
|
32
|
-
The
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
package yet, so `ruqu doctor` currently reports the **`js`** backend. It will pick up native/WASM
|
|
36
|
-
automatically once those kernel artifacts are published — no change needed here.
|
|
30
|
+
The CLI bundles a `--target nodejs` WebAssembly build of the `ruqu-wasm` crate (real state-vector
|
|
31
|
+
simulation in Rust → WASM) and loads it directly in Node — no native addon, no Python. It also boots
|
|
32
|
+
the metaharness kernel + Claude Code host adapter for the agent-harness commands (`init`/`doctor`).
|
|
37
33
|
|
|
38
34
|
## License
|
|
39
35
|
|
package/bin/cli.js
CHANGED
|
@@ -1,100 +1,170 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
const HARNESS_NAME = 'ruqu';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// The `ruqu` CLI — an agent harness over the metaharness kernel PLUS real
|
|
4
|
+
// quantum-circuit execution via the bundled ruqu-wasm WebAssembly module.
|
|
5
|
+
//
|
|
6
|
+
// Plain ESM JS: runs as-is via `npx @ruvector/ruqu` with no build step.
|
|
7
|
+
|
|
8
|
+
import { loadKernel } from '@metaharness/kernel';
|
|
9
|
+
import adapter from '@metaharness/host-claude-code';
|
|
10
|
+
import { createRequire } from 'node:module';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { dirname, join } from 'node:path';
|
|
13
|
+
|
|
14
|
+
const HARNESS_NAME = 'ruqu';
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
|
|
18
|
+
/** Lazily load the bundled nodejs-target quantum WASM (ruqu-wasm crate). */
|
|
19
|
+
let _wasm;
|
|
20
|
+
function quantum() {
|
|
21
|
+
if (!_wasm) _wasm = require(join(HERE, '..', 'wasm', 'ruqu_wasm.js'));
|
|
22
|
+
return _wasm;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function arg(args, flag, def) {
|
|
26
|
+
const i = args.indexOf(flag);
|
|
27
|
+
return i >= 0 && args[i + 1] !== undefined ? args[i + 1] : def;
|
|
28
|
+
}
|
|
29
|
+
function intArg(args, flag, def) {
|
|
30
|
+
const v = arg(args, flag, undefined);
|
|
31
|
+
return v === undefined ? def : parseInt(v, 10);
|
|
32
|
+
}
|
|
33
|
+
/** Top-k computational basis states by probability, as [bitstring, p]. */
|
|
34
|
+
function topStates(probs, n, k = 8) {
|
|
35
|
+
return probs
|
|
36
|
+
.map((p, i) => [i.toString(2).padStart(n, '0'), p])
|
|
37
|
+
.filter(([, p]) => p > 1e-9)
|
|
38
|
+
.sort((a, b) => b[1] - a[1])
|
|
39
|
+
.slice(0, k);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** `ruqu init` — boot the agent-harness kernel + host adapter. */
|
|
43
|
+
async function init() {
|
|
44
|
+
const kernel = await loadKernel();
|
|
45
|
+
const info = kernel.kernelInfo();
|
|
46
|
+
console.log(`${HARNESS_NAME} — kernel ${info.version} (${kernel.backend}) · host ${adapter.name}`);
|
|
47
|
+
console.log(`Quantum WASM: ${quantum().max_qubits()} qubits max. Try \`${HARNESS_NAME} capabilities\`.`);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** `ruqu doctor` — verify the harness kernel AND the quantum WASM end-to-end. */
|
|
52
|
+
async function doctor() {
|
|
53
|
+
const kernel = await loadKernel();
|
|
54
|
+
const info = kernel.kernelInfo();
|
|
55
|
+
let maxq = 0;
|
|
56
|
+
try { maxq = quantum().max_qubits(); } catch { maxq = 0; }
|
|
57
|
+
const checks = [
|
|
58
|
+
['metaharness kernel loads', !!kernel],
|
|
59
|
+
['kernel reports a version', typeof info.version === 'string' && info.version.length > 0],
|
|
60
|
+
['host adapter has a name', typeof adapter?.name === 'string' && adapter.name.length > 0],
|
|
61
|
+
['quantum WASM loads (ruqu-wasm)', maxq > 0],
|
|
62
|
+
[`quantum WASM runs a Bell state`, runsBell()],
|
|
63
|
+
];
|
|
64
|
+
let ok = true;
|
|
65
|
+
for (const [label, pass] of checks) { console.log(`${pass ? 'PASS' : 'FAIL'} ${label}`); if (!pass) ok = false; }
|
|
66
|
+
console.log(ok
|
|
67
|
+
? `\n${HARNESS_NAME}: all checks passed (kernel ${info.version} ${kernel.backend}; quantum WASM ${maxq} qubits)`
|
|
68
|
+
: `\n${HARNESS_NAME}: doctor found problems`);
|
|
69
|
+
return ok ? 0 : 1;
|
|
70
|
+
}
|
|
71
|
+
function runsBell() {
|
|
72
|
+
try {
|
|
73
|
+
const q = quantum();
|
|
74
|
+
const c = new q.WasmQuantumCircuit(2); c.h(0); c.cnot(0, 1);
|
|
75
|
+
const r = q.simulate(c);
|
|
76
|
+
return Math.abs(r.probabilities[0] - 0.5) < 1e-6 && Math.abs(r.probabilities[3] - 0.5) < 1e-6;
|
|
77
|
+
} catch { return false; }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** `ruqu capabilities` — list the quantum capabilities this CLI exposes. */
|
|
81
|
+
function capabilities() {
|
|
82
|
+
const q = quantum();
|
|
83
|
+
const mem = q.estimate_memory(q.max_qubits());
|
|
84
|
+
console.log(`${HARNESS_NAME} — quantum capabilities (pure-Rust → WebAssembly)`);
|
|
85
|
+
console.log(` max qubits ${q.max_qubits()}`);
|
|
86
|
+
console.log(` state @ max ~${(mem / 1e6).toFixed(1)} MB`);
|
|
87
|
+
console.log(` gates h x y z s t rx ry rz cnot cz swap rzz measure reset barrier`);
|
|
88
|
+
console.log(` algorithms simulate · grover · qaoa`);
|
|
89
|
+
console.log(` commands init · doctor · capabilities · simulate · grover · qaoa · version`);
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** `ruqu simulate [--qubits N]` — run a GHZ/Bell circuit and show the distribution. */
|
|
94
|
+
function simulate(args) {
|
|
95
|
+
const q = quantum();
|
|
96
|
+
const n = intArg(args, '--qubits', 2);
|
|
97
|
+
const c = new q.WasmQuantumCircuit(n);
|
|
98
|
+
c.h(0);
|
|
99
|
+
for (let i = 1; i < n; i++) c.cnot(0, i);
|
|
100
|
+
const r = q.simulate(c);
|
|
101
|
+
console.log(`${HARNESS_NAME} simulate — ${n}-qubit GHZ · ${r.gate_count} gates · ${r.execution_time_ms.toFixed(2)} ms`);
|
|
102
|
+
for (const [bits, p] of topStates(r.probabilities, n)) console.log(` |${bits}⟩ ${(p * 100).toFixed(1)}%`);
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** `ruqu grover [--qubits N] [--target T] [--seed S]` — amplitude amplification. */
|
|
107
|
+
function grover(args) {
|
|
108
|
+
const q = quantum();
|
|
109
|
+
const n = intArg(args, '--qubits', 3);
|
|
110
|
+
const target = intArg(args, '--target', (1 << n) - 1);
|
|
111
|
+
const seed = args.includes('--seed') ? intArg(args, '--seed', 0) : null;
|
|
112
|
+
const r = q.grover_search(n, [target], seed);
|
|
113
|
+
console.log(`${HARNESS_NAME} grover — ${n} qubits, target=${target}`);
|
|
114
|
+
console.log(` iterations ${r.num_iterations}`);
|
|
115
|
+
console.log(` success probability ${(r.success_probability * 100).toFixed(1)}%`);
|
|
116
|
+
console.log(` measured state ${r.measured_state}`);
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** `ruqu qaoa [--nodes N] [--p P]` — QAOA MaxCut on a ring graph. */
|
|
121
|
+
function qaoa(args) {
|
|
122
|
+
const q = quantum();
|
|
123
|
+
const nodes = intArg(args, '--nodes', 4);
|
|
124
|
+
const edges = [];
|
|
125
|
+
for (let i = 0; i < nodes; i++) { edges.push(i, (i + 1) % nodes); }
|
|
126
|
+
const p = intArg(args, '--p', 1);
|
|
127
|
+
const gammas = Array.from({ length: p }, () => 0.8);
|
|
128
|
+
const betas = Array.from({ length: p }, () => 0.6);
|
|
129
|
+
const r = q.qaoa_maxcut(nodes, edges, p, gammas, betas, null);
|
|
130
|
+
console.log(`${HARNESS_NAME} qaoa — ${nodes}-node ring MaxCut, p=${p}`);
|
|
131
|
+
for (const [bits, prob] of topStates(r.probabilities, nodes, 5)) console.log(` cut ${bits} ${(prob * 100).toFixed(1)}%`);
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function version() {
|
|
136
|
+
const k = await loadKernel();
|
|
137
|
+
console.log(`${HARNESS_NAME} CLI — metaharness kernel ${k.kernelInfo().version} (${k.backend}) · quantum WASM ${quantum().max_qubits()}q`);
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export async function run(argv) {
|
|
142
|
+
const [cmd, ...rest] = argv;
|
|
143
|
+
switch (cmd) {
|
|
144
|
+
case undefined:
|
|
145
|
+
case 'init': return init();
|
|
146
|
+
case 'doctor': return doctor();
|
|
147
|
+
case 'capabilities': case 'caps': return capabilities();
|
|
148
|
+
case 'simulate': case 'sim': return simulate(rest);
|
|
149
|
+
case 'grover': return grover(rest);
|
|
150
|
+
case 'qaoa': return qaoa(rest);
|
|
151
|
+
case 'version': case '--version': return version();
|
|
152
|
+
case 'help': case '--help':
|
|
153
|
+
console.log(`Usage: ${HARNESS_NAME} <command>\n\n init boot the kernel + host adapter (default)\n doctor verify kernel + quantum WASM end-to-end\n capabilities list quantum capabilities\n simulate run a GHZ/Bell circuit [--qubits N]\n grover Grover search [--qubits N --target T --seed S]\n qaoa QAOA MaxCut on a ring [--nodes N --p P]\n version print versions`);
|
|
154
|
+
return 0;
|
|
155
|
+
default:
|
|
156
|
+
console.error(`Unknown command: ${cmd}. Try \`${HARNESS_NAME} --help\`.`);
|
|
157
|
+
return 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Execute only when invoked directly (not when imported by a test).
|
|
162
|
+
import { realpathSync } from 'node:fs';
|
|
163
|
+
import { argv } from 'node:process';
|
|
164
|
+
const invokedDirectly = (() => {
|
|
165
|
+
try { return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(argv[1]); }
|
|
166
|
+
catch { return false; }
|
|
167
|
+
})();
|
|
168
|
+
if (invokedDirectly) {
|
|
169
|
+
run(argv.slice(2)).then((code) => process.exit(code)).catch((e) => { console.error(e); process.exit(1); });
|
|
170
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruvector/ruqu",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Quantum circuit simulator in WebAssembly + agent harness CLI — run state-vector simulation, Grover search, and QAOA MaxCut from your terminal. npx @ruvector/ruqu",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ruqu": "bin/cli.js"
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
".claude/**",
|
|
14
14
|
"CLAUDE.md",
|
|
15
15
|
"README.md",
|
|
16
|
-
"LICENSE"
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"wasm/**"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
20
|
"build": "tsc",
|
|
@@ -57,6 +58,14 @@
|
|
|
57
58
|
"claude-code",
|
|
58
59
|
"quantum",
|
|
59
60
|
"harness",
|
|
60
|
-
"npx"
|
|
61
|
+
"npx",
|
|
62
|
+
"quantum-computing",
|
|
63
|
+
"quantum-simulator",
|
|
64
|
+
"webassembly",
|
|
65
|
+
"wasm",
|
|
66
|
+
"qaoa",
|
|
67
|
+
"grover",
|
|
68
|
+
"state-vector",
|
|
69
|
+
"quantum-circuit"
|
|
61
70
|
]
|
|
62
71
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A JavaScript-friendly quantum circuit builder.
|
|
6
|
+
*
|
|
7
|
+
* Wraps `ruqu_core::circuit::QuantumCircuit` with wasm-bindgen annotations.
|
|
8
|
+
* All gate methods validate qubit indices against the circuit size internally
|
|
9
|
+
* via the core library.
|
|
10
|
+
*
|
|
11
|
+
* ## JavaScript Example
|
|
12
|
+
*
|
|
13
|
+
* ```javascript
|
|
14
|
+
* const qc = new WasmQuantumCircuit(3);
|
|
15
|
+
* qc.h(0); // Hadamard on qubit 0
|
|
16
|
+
* qc.cnot(0, 1); // CNOT: control=0, target=1
|
|
17
|
+
* qc.rz(2, Math.PI); // Rz rotation on qubit 2
|
|
18
|
+
* qc.measure_all();
|
|
19
|
+
*
|
|
20
|
+
* console.log(`Qubits: ${qc.num_qubits}`);
|
|
21
|
+
* console.log(`Gates: ${qc.gate_count}`);
|
|
22
|
+
* console.log(`Depth: ${qc.depth}`);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class WasmQuantumCircuit {
|
|
26
|
+
free(): void;
|
|
27
|
+
[Symbol.dispose](): void;
|
|
28
|
+
/**
|
|
29
|
+
* Insert a barrier (prevents gate reordering across this point).
|
|
30
|
+
*/
|
|
31
|
+
barrier(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Apply CNOT (controlled-X) gate.
|
|
34
|
+
*/
|
|
35
|
+
cnot(control: number, target: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Apply controlled-Z gate.
|
|
38
|
+
*/
|
|
39
|
+
cz(q1: number, q2: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Apply Hadamard gate to the target qubit.
|
|
42
|
+
*/
|
|
43
|
+
h(qubit: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Add a measurement operation on a single qubit.
|
|
46
|
+
*/
|
|
47
|
+
measure(qubit: number): void;
|
|
48
|
+
/**
|
|
49
|
+
* Add measurement operations on all qubits.
|
|
50
|
+
*/
|
|
51
|
+
measure_all(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Create a new quantum circuit with the given number of qubits.
|
|
54
|
+
*
|
|
55
|
+
* Returns an error if `num_qubits` exceeds the WASM limit (25).
|
|
56
|
+
*/
|
|
57
|
+
constructor(num_qubits: number);
|
|
58
|
+
/**
|
|
59
|
+
* Reset a qubit to the |0> state.
|
|
60
|
+
*/
|
|
61
|
+
reset(qubit: number): void;
|
|
62
|
+
/**
|
|
63
|
+
* Apply Rx rotation gate with the given angle (radians).
|
|
64
|
+
*/
|
|
65
|
+
rx(qubit: number, angle: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Apply Ry rotation gate with the given angle (radians).
|
|
68
|
+
*/
|
|
69
|
+
ry(qubit: number, angle: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* Apply Rz rotation gate with the given angle (radians).
|
|
72
|
+
*/
|
|
73
|
+
rz(qubit: number, angle: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* Apply Rzz (ZZ-rotation) gate with the given angle (radians).
|
|
76
|
+
*/
|
|
77
|
+
rzz(q1: number, q2: number, angle: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Apply S (phase) gate to the target qubit.
|
|
80
|
+
*/
|
|
81
|
+
s(qubit: number): void;
|
|
82
|
+
/**
|
|
83
|
+
* Apply SWAP gate.
|
|
84
|
+
*/
|
|
85
|
+
swap(q1: number, q2: number): void;
|
|
86
|
+
/**
|
|
87
|
+
* Apply T gate to the target qubit.
|
|
88
|
+
*/
|
|
89
|
+
t(qubit: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Apply Pauli-X (NOT) gate to the target qubit.
|
|
92
|
+
*/
|
|
93
|
+
x(qubit: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Apply Pauli-Y gate to the target qubit.
|
|
96
|
+
*/
|
|
97
|
+
y(qubit: number): void;
|
|
98
|
+
/**
|
|
99
|
+
* Apply Pauli-Z gate to the target qubit.
|
|
100
|
+
*/
|
|
101
|
+
z(qubit: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* The circuit depth (longest path through the gate DAG).
|
|
104
|
+
*/
|
|
105
|
+
readonly depth: number;
|
|
106
|
+
/**
|
|
107
|
+
* The total number of gates applied so far.
|
|
108
|
+
*/
|
|
109
|
+
readonly gate_count: number;
|
|
110
|
+
/**
|
|
111
|
+
* The number of qubits in this circuit.
|
|
112
|
+
*/
|
|
113
|
+
readonly num_qubits: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Estimate memory usage (in bytes) for a state vector of `num_qubits` qubits.
|
|
118
|
+
*
|
|
119
|
+
* Each qubit doubles the state vector size. The formula is `2^n * 16` bytes
|
|
120
|
+
* (two f64 values per complex amplitude).
|
|
121
|
+
*/
|
|
122
|
+
export function estimate_memory(num_qubits: number): number;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Run Grover's quantum search algorithm.
|
|
126
|
+
*
|
|
127
|
+
* Searches for one or more target states in a space of `2^num_qubits` items.
|
|
128
|
+
* The optimal number of iterations is computed automatically when not specified.
|
|
129
|
+
*
|
|
130
|
+
* ## Parameters
|
|
131
|
+
*
|
|
132
|
+
* - `num_qubits` - Number of qubits (search space = 2^num_qubits).
|
|
133
|
+
* - `target_states` - Array of target state indices to search for (as u32 values).
|
|
134
|
+
* - `seed` - Optional RNG seed for reproducibility. Pass `null` or `undefined`
|
|
135
|
+
* for non-deterministic execution. If provided, interpreted as a
|
|
136
|
+
* floating-point number and truncated to a 64-bit unsigned integer.
|
|
137
|
+
*
|
|
138
|
+
* ## Returns
|
|
139
|
+
*
|
|
140
|
+
* A JS object:
|
|
141
|
+
* ```typescript
|
|
142
|
+
* {
|
|
143
|
+
* measured_state: number,
|
|
144
|
+
* target_found: boolean,
|
|
145
|
+
* success_probability: number,
|
|
146
|
+
* num_iterations: number,
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export function grover_search(num_qubits: number, target_states: Uint32Array, seed: any): any;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Called automatically when the WASM module is instantiated.
|
|
154
|
+
*
|
|
155
|
+
* Sets up `console_error_panic_hook` (when the feature is enabled) so that
|
|
156
|
+
* Rust panics produce readable stack traces in the browser console instead
|
|
157
|
+
* of opaque "unreachable" errors.
|
|
158
|
+
*/
|
|
159
|
+
export function init(): void;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get the maximum number of qubits supported in the WASM environment.
|
|
163
|
+
*/
|
|
164
|
+
export function max_qubits(): number;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Build and simulate a QAOA (Quantum Approximate Optimization Algorithm)
|
|
168
|
+
* circuit for the MaxCut problem on an undirected graph.
|
|
169
|
+
*
|
|
170
|
+
* ## Parameters
|
|
171
|
+
*
|
|
172
|
+
* - `num_nodes` - Number of graph nodes (one qubit per node).
|
|
173
|
+
* - `edges_flat` - Flattened edge list as consecutive pairs: `[i1, j1, i2, j2, ...]`.
|
|
174
|
+
* Each `(i, j)` pair defines an undirected edge with unit weight.
|
|
175
|
+
* - `p` - Number of QAOA rounds (circuit depth parameter).
|
|
176
|
+
* - `gammas` - Problem-unitary angles, length must equal `p`.
|
|
177
|
+
* - `betas` - Mixer-unitary angles, length must equal `p`.
|
|
178
|
+
* - `seed` - Optional RNG seed. Pass `null` or `undefined` for non-deterministic
|
|
179
|
+
* execution.
|
|
180
|
+
*
|
|
181
|
+
* ## Returns
|
|
182
|
+
*
|
|
183
|
+
* A JS object:
|
|
184
|
+
* ```typescript
|
|
185
|
+
* {
|
|
186
|
+
* probabilities: number[], // length = 2^num_nodes
|
|
187
|
+
* expected_cut: number, // expected cut value from the output state
|
|
188
|
+
* }
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export function qaoa_maxcut(num_nodes: number, edges_flat: Uint32Array, p: number, gammas: Float64Array, betas: Float64Array, seed: any): any;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Run a quantum circuit simulation and return the results as a JS object.
|
|
195
|
+
*
|
|
196
|
+
* The returned object has the shape:
|
|
197
|
+
* ```typescript
|
|
198
|
+
* {
|
|
199
|
+
* probabilities: number[], // length = 2^num_qubits
|
|
200
|
+
* measurements: Array<{ qubit: number, result: boolean, probability: number }>,
|
|
201
|
+
* num_qubits: number,
|
|
202
|
+
* gate_count: number,
|
|
203
|
+
* execution_time_ms: number,
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export function simulate(circuit: WasmQuantumCircuit): any;
|
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
/* @ts-self-types="./ruqu_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A JavaScript-friendly quantum circuit builder.
|
|
5
|
+
*
|
|
6
|
+
* Wraps `ruqu_core::circuit::QuantumCircuit` with wasm-bindgen annotations.
|
|
7
|
+
* All gate methods validate qubit indices against the circuit size internally
|
|
8
|
+
* via the core library.
|
|
9
|
+
*
|
|
10
|
+
* ## JavaScript Example
|
|
11
|
+
*
|
|
12
|
+
* ```javascript
|
|
13
|
+
* const qc = new WasmQuantumCircuit(3);
|
|
14
|
+
* qc.h(0); // Hadamard on qubit 0
|
|
15
|
+
* qc.cnot(0, 1); // CNOT: control=0, target=1
|
|
16
|
+
* qc.rz(2, Math.PI); // Rz rotation on qubit 2
|
|
17
|
+
* qc.measure_all();
|
|
18
|
+
*
|
|
19
|
+
* console.log(`Qubits: ${qc.num_qubits}`);
|
|
20
|
+
* console.log(`Gates: ${qc.gate_count}`);
|
|
21
|
+
* console.log(`Depth: ${qc.depth}`);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class WasmQuantumCircuit {
|
|
25
|
+
__destroy_into_raw() {
|
|
26
|
+
const ptr = this.__wbg_ptr;
|
|
27
|
+
this.__wbg_ptr = 0;
|
|
28
|
+
WasmQuantumCircuitFinalization.unregister(this);
|
|
29
|
+
return ptr;
|
|
30
|
+
}
|
|
31
|
+
free() {
|
|
32
|
+
const ptr = this.__destroy_into_raw();
|
|
33
|
+
wasm.__wbg_wasmquantumcircuit_free(ptr, 0);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Insert a barrier (prevents gate reordering across this point).
|
|
37
|
+
*/
|
|
38
|
+
barrier() {
|
|
39
|
+
wasm.wasmquantumcircuit_barrier(this.__wbg_ptr);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Apply CNOT (controlled-X) gate.
|
|
43
|
+
* @param {number} control
|
|
44
|
+
* @param {number} target
|
|
45
|
+
*/
|
|
46
|
+
cnot(control, target) {
|
|
47
|
+
wasm.wasmquantumcircuit_cnot(this.__wbg_ptr, control, target);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Apply controlled-Z gate.
|
|
51
|
+
* @param {number} q1
|
|
52
|
+
* @param {number} q2
|
|
53
|
+
*/
|
|
54
|
+
cz(q1, q2) {
|
|
55
|
+
wasm.wasmquantumcircuit_cz(this.__wbg_ptr, q1, q2);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The circuit depth (longest path through the gate DAG).
|
|
59
|
+
* @returns {number}
|
|
60
|
+
*/
|
|
61
|
+
get depth() {
|
|
62
|
+
const ret = wasm.wasmquantumcircuit_depth(this.__wbg_ptr);
|
|
63
|
+
return ret >>> 0;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The total number of gates applied so far.
|
|
67
|
+
* @returns {number}
|
|
68
|
+
*/
|
|
69
|
+
get gate_count() {
|
|
70
|
+
const ret = wasm.wasmquantumcircuit_gate_count(this.__wbg_ptr);
|
|
71
|
+
return ret >>> 0;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Apply Hadamard gate to the target qubit.
|
|
75
|
+
* @param {number} qubit
|
|
76
|
+
*/
|
|
77
|
+
h(qubit) {
|
|
78
|
+
wasm.wasmquantumcircuit_h(this.__wbg_ptr, qubit);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add a measurement operation on a single qubit.
|
|
82
|
+
* @param {number} qubit
|
|
83
|
+
*/
|
|
84
|
+
measure(qubit) {
|
|
85
|
+
wasm.wasmquantumcircuit_measure(this.__wbg_ptr, qubit);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Add measurement operations on all qubits.
|
|
89
|
+
*/
|
|
90
|
+
measure_all() {
|
|
91
|
+
wasm.wasmquantumcircuit_measure_all(this.__wbg_ptr);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a new quantum circuit with the given number of qubits.
|
|
95
|
+
*
|
|
96
|
+
* Returns an error if `num_qubits` exceeds the WASM limit (25).
|
|
97
|
+
* @param {number} num_qubits
|
|
98
|
+
*/
|
|
99
|
+
constructor(num_qubits) {
|
|
100
|
+
const ret = wasm.wasmquantumcircuit_new(num_qubits);
|
|
101
|
+
if (ret[2]) {
|
|
102
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
103
|
+
}
|
|
104
|
+
this.__wbg_ptr = ret[0];
|
|
105
|
+
WasmQuantumCircuitFinalization.register(this, this.__wbg_ptr, this);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The number of qubits in this circuit.
|
|
110
|
+
* @returns {number}
|
|
111
|
+
*/
|
|
112
|
+
get num_qubits() {
|
|
113
|
+
const ret = wasm.wasmquantumcircuit_num_qubits(this.__wbg_ptr);
|
|
114
|
+
return ret >>> 0;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Reset a qubit to the |0> state.
|
|
118
|
+
* @param {number} qubit
|
|
119
|
+
*/
|
|
120
|
+
reset(qubit) {
|
|
121
|
+
wasm.wasmquantumcircuit_reset(this.__wbg_ptr, qubit);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Apply Rx rotation gate with the given angle (radians).
|
|
125
|
+
* @param {number} qubit
|
|
126
|
+
* @param {number} angle
|
|
127
|
+
*/
|
|
128
|
+
rx(qubit, angle) {
|
|
129
|
+
wasm.wasmquantumcircuit_rx(this.__wbg_ptr, qubit, angle);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Apply Ry rotation gate with the given angle (radians).
|
|
133
|
+
* @param {number} qubit
|
|
134
|
+
* @param {number} angle
|
|
135
|
+
*/
|
|
136
|
+
ry(qubit, angle) {
|
|
137
|
+
wasm.wasmquantumcircuit_ry(this.__wbg_ptr, qubit, angle);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Apply Rz rotation gate with the given angle (radians).
|
|
141
|
+
* @param {number} qubit
|
|
142
|
+
* @param {number} angle
|
|
143
|
+
*/
|
|
144
|
+
rz(qubit, angle) {
|
|
145
|
+
wasm.wasmquantumcircuit_rz(this.__wbg_ptr, qubit, angle);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Apply Rzz (ZZ-rotation) gate with the given angle (radians).
|
|
149
|
+
* @param {number} q1
|
|
150
|
+
* @param {number} q2
|
|
151
|
+
* @param {number} angle
|
|
152
|
+
*/
|
|
153
|
+
rzz(q1, q2, angle) {
|
|
154
|
+
wasm.wasmquantumcircuit_rzz(this.__wbg_ptr, q1, q2, angle);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Apply S (phase) gate to the target qubit.
|
|
158
|
+
* @param {number} qubit
|
|
159
|
+
*/
|
|
160
|
+
s(qubit) {
|
|
161
|
+
wasm.wasmquantumcircuit_s(this.__wbg_ptr, qubit);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Apply SWAP gate.
|
|
165
|
+
* @param {number} q1
|
|
166
|
+
* @param {number} q2
|
|
167
|
+
*/
|
|
168
|
+
swap(q1, q2) {
|
|
169
|
+
wasm.wasmquantumcircuit_swap(this.__wbg_ptr, q1, q2);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Apply T gate to the target qubit.
|
|
173
|
+
* @param {number} qubit
|
|
174
|
+
*/
|
|
175
|
+
t(qubit) {
|
|
176
|
+
wasm.wasmquantumcircuit_t(this.__wbg_ptr, qubit);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Apply Pauli-X (NOT) gate to the target qubit.
|
|
180
|
+
* @param {number} qubit
|
|
181
|
+
*/
|
|
182
|
+
x(qubit) {
|
|
183
|
+
wasm.wasmquantumcircuit_x(this.__wbg_ptr, qubit);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Apply Pauli-Y gate to the target qubit.
|
|
187
|
+
* @param {number} qubit
|
|
188
|
+
*/
|
|
189
|
+
y(qubit) {
|
|
190
|
+
wasm.wasmquantumcircuit_y(this.__wbg_ptr, qubit);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Apply Pauli-Z gate to the target qubit.
|
|
194
|
+
* @param {number} qubit
|
|
195
|
+
*/
|
|
196
|
+
z(qubit) {
|
|
197
|
+
wasm.wasmquantumcircuit_z(this.__wbg_ptr, qubit);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (Symbol.dispose) WasmQuantumCircuit.prototype[Symbol.dispose] = WasmQuantumCircuit.prototype.free;
|
|
201
|
+
exports.WasmQuantumCircuit = WasmQuantumCircuit;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Estimate memory usage (in bytes) for a state vector of `num_qubits` qubits.
|
|
205
|
+
*
|
|
206
|
+
* Each qubit doubles the state vector size. The formula is `2^n * 16` bytes
|
|
207
|
+
* (two f64 values per complex amplitude).
|
|
208
|
+
* @param {number} num_qubits
|
|
209
|
+
* @returns {number}
|
|
210
|
+
*/
|
|
211
|
+
function estimate_memory(num_qubits) {
|
|
212
|
+
const ret = wasm.estimate_memory(num_qubits);
|
|
213
|
+
return ret >>> 0;
|
|
214
|
+
}
|
|
215
|
+
exports.estimate_memory = estimate_memory;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Run Grover's quantum search algorithm.
|
|
219
|
+
*
|
|
220
|
+
* Searches for one or more target states in a space of `2^num_qubits` items.
|
|
221
|
+
* The optimal number of iterations is computed automatically when not specified.
|
|
222
|
+
*
|
|
223
|
+
* ## Parameters
|
|
224
|
+
*
|
|
225
|
+
* - `num_qubits` - Number of qubits (search space = 2^num_qubits).
|
|
226
|
+
* - `target_states` - Array of target state indices to search for (as u32 values).
|
|
227
|
+
* - `seed` - Optional RNG seed for reproducibility. Pass `null` or `undefined`
|
|
228
|
+
* for non-deterministic execution. If provided, interpreted as a
|
|
229
|
+
* floating-point number and truncated to a 64-bit unsigned integer.
|
|
230
|
+
*
|
|
231
|
+
* ## Returns
|
|
232
|
+
*
|
|
233
|
+
* A JS object:
|
|
234
|
+
* ```typescript
|
|
235
|
+
* {
|
|
236
|
+
* measured_state: number,
|
|
237
|
+
* target_found: boolean,
|
|
238
|
+
* success_probability: number,
|
|
239
|
+
* num_iterations: number,
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
* @param {number} num_qubits
|
|
243
|
+
* @param {Uint32Array} target_states
|
|
244
|
+
* @param {any} seed
|
|
245
|
+
* @returns {any}
|
|
246
|
+
*/
|
|
247
|
+
function grover_search(num_qubits, target_states, seed) {
|
|
248
|
+
const ptr0 = passArray32ToWasm0(target_states, wasm.__wbindgen_malloc);
|
|
249
|
+
const len0 = WASM_VECTOR_LEN;
|
|
250
|
+
const ret = wasm.grover_search(num_qubits, ptr0, len0, seed);
|
|
251
|
+
if (ret[2]) {
|
|
252
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
253
|
+
}
|
|
254
|
+
return takeFromExternrefTable0(ret[0]);
|
|
255
|
+
}
|
|
256
|
+
exports.grover_search = grover_search;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Called automatically when the WASM module is instantiated.
|
|
260
|
+
*
|
|
261
|
+
* Sets up `console_error_panic_hook` (when the feature is enabled) so that
|
|
262
|
+
* Rust panics produce readable stack traces in the browser console instead
|
|
263
|
+
* of opaque "unreachable" errors.
|
|
264
|
+
*/
|
|
265
|
+
function init() {
|
|
266
|
+
wasm.init();
|
|
267
|
+
}
|
|
268
|
+
exports.init = init;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Get the maximum number of qubits supported in the WASM environment.
|
|
272
|
+
* @returns {number}
|
|
273
|
+
*/
|
|
274
|
+
function max_qubits() {
|
|
275
|
+
const ret = wasm.max_qubits();
|
|
276
|
+
return ret >>> 0;
|
|
277
|
+
}
|
|
278
|
+
exports.max_qubits = max_qubits;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Build and simulate a QAOA (Quantum Approximate Optimization Algorithm)
|
|
282
|
+
* circuit for the MaxCut problem on an undirected graph.
|
|
283
|
+
*
|
|
284
|
+
* ## Parameters
|
|
285
|
+
*
|
|
286
|
+
* - `num_nodes` - Number of graph nodes (one qubit per node).
|
|
287
|
+
* - `edges_flat` - Flattened edge list as consecutive pairs: `[i1, j1, i2, j2, ...]`.
|
|
288
|
+
* Each `(i, j)` pair defines an undirected edge with unit weight.
|
|
289
|
+
* - `p` - Number of QAOA rounds (circuit depth parameter).
|
|
290
|
+
* - `gammas` - Problem-unitary angles, length must equal `p`.
|
|
291
|
+
* - `betas` - Mixer-unitary angles, length must equal `p`.
|
|
292
|
+
* - `seed` - Optional RNG seed. Pass `null` or `undefined` for non-deterministic
|
|
293
|
+
* execution.
|
|
294
|
+
*
|
|
295
|
+
* ## Returns
|
|
296
|
+
*
|
|
297
|
+
* A JS object:
|
|
298
|
+
* ```typescript
|
|
299
|
+
* {
|
|
300
|
+
* probabilities: number[], // length = 2^num_nodes
|
|
301
|
+
* expected_cut: number, // expected cut value from the output state
|
|
302
|
+
* }
|
|
303
|
+
* ```
|
|
304
|
+
* @param {number} num_nodes
|
|
305
|
+
* @param {Uint32Array} edges_flat
|
|
306
|
+
* @param {number} p
|
|
307
|
+
* @param {Float64Array} gammas
|
|
308
|
+
* @param {Float64Array} betas
|
|
309
|
+
* @param {any} seed
|
|
310
|
+
* @returns {any}
|
|
311
|
+
*/
|
|
312
|
+
function qaoa_maxcut(num_nodes, edges_flat, p, gammas, betas, seed) {
|
|
313
|
+
const ptr0 = passArray32ToWasm0(edges_flat, wasm.__wbindgen_malloc);
|
|
314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
315
|
+
const ptr1 = passArrayF64ToWasm0(gammas, wasm.__wbindgen_malloc);
|
|
316
|
+
const len1 = WASM_VECTOR_LEN;
|
|
317
|
+
const ptr2 = passArrayF64ToWasm0(betas, wasm.__wbindgen_malloc);
|
|
318
|
+
const len2 = WASM_VECTOR_LEN;
|
|
319
|
+
const ret = wasm.qaoa_maxcut(num_nodes, ptr0, len0, p, ptr1, len1, ptr2, len2, seed);
|
|
320
|
+
if (ret[2]) {
|
|
321
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
322
|
+
}
|
|
323
|
+
return takeFromExternrefTable0(ret[0]);
|
|
324
|
+
}
|
|
325
|
+
exports.qaoa_maxcut = qaoa_maxcut;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Run a quantum circuit simulation and return the results as a JS object.
|
|
329
|
+
*
|
|
330
|
+
* The returned object has the shape:
|
|
331
|
+
* ```typescript
|
|
332
|
+
* {
|
|
333
|
+
* probabilities: number[], // length = 2^num_qubits
|
|
334
|
+
* measurements: Array<{ qubit: number, result: boolean, probability: number }>,
|
|
335
|
+
* num_qubits: number,
|
|
336
|
+
* gate_count: number,
|
|
337
|
+
* execution_time_ms: number,
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
* @param {WasmQuantumCircuit} circuit
|
|
341
|
+
* @returns {any}
|
|
342
|
+
*/
|
|
343
|
+
function simulate(circuit) {
|
|
344
|
+
_assertClass(circuit, WasmQuantumCircuit);
|
|
345
|
+
const ret = wasm.simulate(circuit.__wbg_ptr);
|
|
346
|
+
if (ret[2]) {
|
|
347
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
348
|
+
}
|
|
349
|
+
return takeFromExternrefTable0(ret[0]);
|
|
350
|
+
}
|
|
351
|
+
exports.simulate = simulate;
|
|
352
|
+
function __wbg_get_imports() {
|
|
353
|
+
const import0 = {
|
|
354
|
+
__proto__: null,
|
|
355
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
356
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
357
|
+
return ret;
|
|
358
|
+
},
|
|
359
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
360
|
+
const ret = String(arg1);
|
|
361
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
362
|
+
const len1 = WASM_VECTOR_LEN;
|
|
363
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
364
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
365
|
+
},
|
|
366
|
+
__wbg___wbindgen_is_function_acc5528be2b923f2: function(arg0) {
|
|
367
|
+
const ret = typeof(arg0) === 'function';
|
|
368
|
+
return ret;
|
|
369
|
+
},
|
|
370
|
+
__wbg___wbindgen_is_null_6d937fbfb6478470: function(arg0) {
|
|
371
|
+
const ret = arg0 === null;
|
|
372
|
+
return ret;
|
|
373
|
+
},
|
|
374
|
+
__wbg___wbindgen_is_object_0beba4a1980d3eea: function(arg0) {
|
|
375
|
+
const val = arg0;
|
|
376
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
377
|
+
return ret;
|
|
378
|
+
},
|
|
379
|
+
__wbg___wbindgen_is_string_1fca8072260dd261: function(arg0) {
|
|
380
|
+
const ret = typeof(arg0) === 'string';
|
|
381
|
+
return ret;
|
|
382
|
+
},
|
|
383
|
+
__wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
|
|
384
|
+
const ret = arg0 === undefined;
|
|
385
|
+
return ret;
|
|
386
|
+
},
|
|
387
|
+
__wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
|
|
388
|
+
const obj = arg1;
|
|
389
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
390
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
391
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
392
|
+
},
|
|
393
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
394
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
395
|
+
},
|
|
396
|
+
__wbg_call_5575218572ead796: function() { return handleError(function (arg0, arg1, arg2) {
|
|
397
|
+
const ret = arg0.call(arg1, arg2);
|
|
398
|
+
return ret;
|
|
399
|
+
}, arguments); },
|
|
400
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
401
|
+
const ret = arg0.crypto;
|
|
402
|
+
return ret;
|
|
403
|
+
},
|
|
404
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
405
|
+
arg0.getRandomValues(arg1);
|
|
406
|
+
}, arguments); },
|
|
407
|
+
__wbg_length_589238bdcf171f0e: function(arg0) {
|
|
408
|
+
const ret = arg0.length;
|
|
409
|
+
return ret;
|
|
410
|
+
},
|
|
411
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
412
|
+
const ret = arg0.msCrypto;
|
|
413
|
+
return ret;
|
|
414
|
+
},
|
|
415
|
+
__wbg_new_2e117a478906f062: function() {
|
|
416
|
+
const ret = new Object();
|
|
417
|
+
return ret;
|
|
418
|
+
},
|
|
419
|
+
__wbg_new_36e147a8ced3c6e0: function() {
|
|
420
|
+
const ret = new Array();
|
|
421
|
+
return ret;
|
|
422
|
+
},
|
|
423
|
+
__wbg_new_with_length_9b650f44b5c44a4e: function(arg0) {
|
|
424
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
425
|
+
return ret;
|
|
426
|
+
},
|
|
427
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
428
|
+
const ret = arg0.node;
|
|
429
|
+
return ret;
|
|
430
|
+
},
|
|
431
|
+
__wbg_now_e7c6795a7f81e10f: function(arg0) {
|
|
432
|
+
const ret = arg0.now();
|
|
433
|
+
return ret;
|
|
434
|
+
},
|
|
435
|
+
__wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
|
|
436
|
+
const ret = arg0.performance;
|
|
437
|
+
return ret;
|
|
438
|
+
},
|
|
439
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
440
|
+
const ret = arg0.process;
|
|
441
|
+
return ret;
|
|
442
|
+
},
|
|
443
|
+
__wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
|
|
444
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
445
|
+
},
|
|
446
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
447
|
+
arg0.randomFillSync(arg1);
|
|
448
|
+
}, arguments); },
|
|
449
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
450
|
+
const ret = module.require;
|
|
451
|
+
return ret;
|
|
452
|
+
}, arguments); },
|
|
453
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
454
|
+
arg0[arg1] = arg2;
|
|
455
|
+
},
|
|
456
|
+
__wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
|
|
457
|
+
arg0[arg1 >>> 0] = arg2;
|
|
458
|
+
},
|
|
459
|
+
__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938: function() {
|
|
460
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
461
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
462
|
+
},
|
|
463
|
+
__wbg_static_accessor_GLOBAL_ce44e66a4935da8c: function() {
|
|
464
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
465
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
466
|
+
},
|
|
467
|
+
__wbg_static_accessor_SELF_44f6e0cb5e67cdad: function() {
|
|
468
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
469
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
470
|
+
},
|
|
471
|
+
__wbg_static_accessor_WINDOW_168f178805d978fe: function() {
|
|
472
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
473
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
474
|
+
},
|
|
475
|
+
__wbg_subarray_b0e8ac4ed313fea8: function(arg0, arg1, arg2) {
|
|
476
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
477
|
+
return ret;
|
|
478
|
+
},
|
|
479
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
480
|
+
const ret = arg0.versions;
|
|
481
|
+
return ret;
|
|
482
|
+
},
|
|
483
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
484
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
485
|
+
const ret = arg0;
|
|
486
|
+
return ret;
|
|
487
|
+
},
|
|
488
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
489
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
490
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
491
|
+
return ret;
|
|
492
|
+
},
|
|
493
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
494
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
495
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
496
|
+
return ret;
|
|
497
|
+
},
|
|
498
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
499
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
500
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
501
|
+
return ret;
|
|
502
|
+
},
|
|
503
|
+
__wbindgen_init_externref_table: function() {
|
|
504
|
+
const table = wasm.__wbindgen_externrefs;
|
|
505
|
+
const offset = table.grow(4);
|
|
506
|
+
table.set(0, undefined);
|
|
507
|
+
table.set(offset + 0, undefined);
|
|
508
|
+
table.set(offset + 1, null);
|
|
509
|
+
table.set(offset + 2, true);
|
|
510
|
+
table.set(offset + 3, false);
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
return {
|
|
514
|
+
__proto__: null,
|
|
515
|
+
"./ruqu_wasm_bg.js": import0,
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const WasmQuantumCircuitFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
520
|
+
? { register: () => {}, unregister: () => {} }
|
|
521
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmquantumcircuit_free(ptr, 1));
|
|
522
|
+
|
|
523
|
+
function addToExternrefTable0(obj) {
|
|
524
|
+
const idx = wasm.__externref_table_alloc();
|
|
525
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
526
|
+
return idx;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function _assertClass(instance, klass) {
|
|
530
|
+
if (!(instance instanceof klass)) {
|
|
531
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
536
|
+
ptr = ptr >>> 0;
|
|
537
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
let cachedDataViewMemory0 = null;
|
|
541
|
+
function getDataViewMemory0() {
|
|
542
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
543
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
544
|
+
}
|
|
545
|
+
return cachedDataViewMemory0;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
549
|
+
function getFloat64ArrayMemory0() {
|
|
550
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
551
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
552
|
+
}
|
|
553
|
+
return cachedFloat64ArrayMemory0;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function getStringFromWasm0(ptr, len) {
|
|
557
|
+
return decodeText(ptr >>> 0, len);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
let cachedUint32ArrayMemory0 = null;
|
|
561
|
+
function getUint32ArrayMemory0() {
|
|
562
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
563
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
564
|
+
}
|
|
565
|
+
return cachedUint32ArrayMemory0;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
let cachedUint8ArrayMemory0 = null;
|
|
569
|
+
function getUint8ArrayMemory0() {
|
|
570
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
571
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
572
|
+
}
|
|
573
|
+
return cachedUint8ArrayMemory0;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
function handleError(f, args) {
|
|
577
|
+
try {
|
|
578
|
+
return f.apply(this, args);
|
|
579
|
+
} catch (e) {
|
|
580
|
+
const idx = addToExternrefTable0(e);
|
|
581
|
+
wasm.__wbindgen_exn_store(idx);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function isLikeNone(x) {
|
|
586
|
+
return x === undefined || x === null;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
590
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
591
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
592
|
+
WASM_VECTOR_LEN = arg.length;
|
|
593
|
+
return ptr;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
597
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
598
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
599
|
+
WASM_VECTOR_LEN = arg.length;
|
|
600
|
+
return ptr;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
604
|
+
if (realloc === undefined) {
|
|
605
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
606
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
607
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
608
|
+
WASM_VECTOR_LEN = buf.length;
|
|
609
|
+
return ptr;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
let len = arg.length;
|
|
613
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
614
|
+
|
|
615
|
+
const mem = getUint8ArrayMemory0();
|
|
616
|
+
|
|
617
|
+
let offset = 0;
|
|
618
|
+
|
|
619
|
+
for (; offset < len; offset++) {
|
|
620
|
+
const code = arg.charCodeAt(offset);
|
|
621
|
+
if (code > 0x7F) break;
|
|
622
|
+
mem[ptr + offset] = code;
|
|
623
|
+
}
|
|
624
|
+
if (offset !== len) {
|
|
625
|
+
if (offset !== 0) {
|
|
626
|
+
arg = arg.slice(offset);
|
|
627
|
+
}
|
|
628
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
629
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
630
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
631
|
+
|
|
632
|
+
offset += ret.written;
|
|
633
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
WASM_VECTOR_LEN = offset;
|
|
637
|
+
return ptr;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function takeFromExternrefTable0(idx) {
|
|
641
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
642
|
+
wasm.__externref_table_dealloc(idx);
|
|
643
|
+
return value;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
647
|
+
cachedTextDecoder.decode();
|
|
648
|
+
function decodeText(ptr, len) {
|
|
649
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
const cachedTextEncoder = new TextEncoder();
|
|
653
|
+
|
|
654
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
655
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
656
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
657
|
+
view.set(buf);
|
|
658
|
+
return {
|
|
659
|
+
read: arg.length,
|
|
660
|
+
written: buf.length
|
|
661
|
+
};
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
let WASM_VECTOR_LEN = 0;
|
|
666
|
+
|
|
667
|
+
const wasmPath = `${__dirname}/ruqu_wasm_bg.wasm`;
|
|
668
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
669
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
670
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
671
|
+
let wasm = wasmInstance.exports;
|
|
672
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_wasmquantumcircuit_free: (a: number, b: number) => void;
|
|
5
|
+
export const estimate_memory: (a: number) => number;
|
|
6
|
+
export const grover_search: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
7
|
+
export const init: () => void;
|
|
8
|
+
export const max_qubits: () => number;
|
|
9
|
+
export const qaoa_maxcut: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: any) => [number, number, number];
|
|
10
|
+
export const simulate: (a: number) => [number, number, number];
|
|
11
|
+
export const wasmquantumcircuit_barrier: (a: number) => void;
|
|
12
|
+
export const wasmquantumcircuit_cnot: (a: number, b: number, c: number) => void;
|
|
13
|
+
export const wasmquantumcircuit_cz: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const wasmquantumcircuit_depth: (a: number) => number;
|
|
15
|
+
export const wasmquantumcircuit_gate_count: (a: number) => number;
|
|
16
|
+
export const wasmquantumcircuit_h: (a: number, b: number) => void;
|
|
17
|
+
export const wasmquantumcircuit_measure: (a: number, b: number) => void;
|
|
18
|
+
export const wasmquantumcircuit_measure_all: (a: number) => void;
|
|
19
|
+
export const wasmquantumcircuit_new: (a: number) => [number, number, number];
|
|
20
|
+
export const wasmquantumcircuit_num_qubits: (a: number) => number;
|
|
21
|
+
export const wasmquantumcircuit_reset: (a: number, b: number) => void;
|
|
22
|
+
export const wasmquantumcircuit_rx: (a: number, b: number, c: number) => void;
|
|
23
|
+
export const wasmquantumcircuit_ry: (a: number, b: number, c: number) => void;
|
|
24
|
+
export const wasmquantumcircuit_rz: (a: number, b: number, c: number) => void;
|
|
25
|
+
export const wasmquantumcircuit_rzz: (a: number, b: number, c: number, d: number) => void;
|
|
26
|
+
export const wasmquantumcircuit_s: (a: number, b: number) => void;
|
|
27
|
+
export const wasmquantumcircuit_swap: (a: number, b: number, c: number) => void;
|
|
28
|
+
export const wasmquantumcircuit_t: (a: number, b: number) => void;
|
|
29
|
+
export const wasmquantumcircuit_x: (a: number, b: number) => void;
|
|
30
|
+
export const wasmquantumcircuit_y: (a: number, b: number) => void;
|
|
31
|
+
export const wasmquantumcircuit_z: (a: number, b: number) => void;
|
|
32
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
35
|
+
export const __externref_table_alloc: () => number;
|
|
36
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
37
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
38
|
+
export const __wbindgen_start: () => void;
|