Add ext/quantum Q0–Q1: ABI simulator with H/CX and Bell smoke.
Register the quantum catalog package, English/Chinese circuit APIs, and a state-vector plugin that verifies Bell-state probabilities. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
25b6b86c26
commit
4a7a33e29a
12 files changed
+799
-9
No files matched your search
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: ext/quantum/quantum
|
||||
description: Official quantum circuit simulator (English). Gates + circuits; ABI plugin.
|
||||
> lib/plugin.mq.md
|
||||
> lib/sys.mq.md
|
||||
> lib/json.mq.md
|
||||
---
|
||||
|
||||
## ensure_plugin
|
||||
|
||||
Load the ABI v2 `quantum` plugin once.
|
||||
|
||||
*`p` = > plugin.native_path name=quantum *
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/quantum: native quantum plugin not found (build marqdo_plugin_quantum or marqdo ext add quantum)
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# circuit
|
||||
+ `qubits`=1
|
||||
|
||||
State-vector circuit (default |0…0⟩). Methods append gates and return an updated handle.
|
||||
|
||||
> ensure_plugin
|
||||
**> quantum_circuit_new qubits=`qubits`**
|
||||
|
||||
## h
|
||||
+ `qubit`=0
|
||||
|
||||
**> quantum_h circuit=`self` qubit=`qubit`**
|
||||
|
||||
## x
|
||||
+ `qubit`=0
|
||||
|
||||
**> quantum_x circuit=`self` qubit=`qubit`**
|
||||
|
||||
## i
|
||||
+ `qubit`=0
|
||||
|
||||
**> quantum_i circuit=`self` qubit=`qubit`**
|
||||
|
||||
## cx
|
||||
+ `control`=0
|
||||
+ `target`=1
|
||||
|
||||
**> quantum_cx circuit=`self` control=`control` target=`target`**
|
||||
|
||||
## simulate
|
||||
|
||||
Return state vector amplitudes `{re,im}`.
|
||||
|
||||
**> quantum_simulate circuit=`self`**
|
||||
|
||||
## probabilities
|
||||
|
||||
Return map of basis label → probability (qubit 0 = rightmost bit).
|
||||
|
||||
**> quantum_probabilities circuit=`self`**
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
title: ext/quantum/量子
|
||||
description: 官方量子电路模拟(中文)。门 + 电路;ABI 插件。
|
||||
> lib/plugin.mq.md
|
||||
> lib/sys.mq.md
|
||||
> lib/json.mq.md
|
||||
---
|
||||
|
||||
## 确保插件
|
||||
|
||||
加载 ABI v2 `quantum` 插件。
|
||||
|
||||
*`p` = > plugin.native_path name=quantum *
|
||||
1. `p`
|
||||
> plugin.load path=`p`
|
||||
2. *
|
||||
> print text=ext/quantum: 未找到原生 quantum 插件(请 build marqdo_plugin_quantum 或 marqdo ext add quantum)
|
||||
> sys.exit code=1
|
||||
****
|
||||
|
||||
# 电路
|
||||
+ `比特数`=1
|
||||
|
||||
状态向量电路(默认 |0…0⟩)。方法追加门并返回更新后的句柄。
|
||||
|
||||
> 确保插件
|
||||
**> quantum_circuit_new qubits=`比特数`**
|
||||
|
||||
## 哈达玛
|
||||
+ `比特`=0
|
||||
|
||||
**> quantum_h circuit=`self` qubit=`比特`**
|
||||
|
||||
## 泡利X
|
||||
+ `比特`=0
|
||||
|
||||
**> quantum_x circuit=`self` qubit=`比特`**
|
||||
|
||||
## 单位
|
||||
+ `比特`=0
|
||||
|
||||
**> quantum_i circuit=`self` qubit=`比特`**
|
||||
|
||||
## 控非
|
||||
+ `控制`=0
|
||||
+ `目标`=1
|
||||
|
||||
**> quantum_cx circuit=`self` control=`控制` target=`目标`**
|
||||
|
||||
## 模拟
|
||||
|
||||
**> quantum_simulate circuit=`self`**
|
||||
|
||||
## 概率
|
||||
|
||||
基矢标签 → 概率(qubit 0 为最右侧比特)。
|
||||
|
||||
**> quantum_probabilities circuit=`self`**
|
||||
Reference in new issue
Block a user