Add formula-matrix custom gates and fix Variables modal in view.

Parse $$ pmatrix/[[…]] into executable matrices for quantum.gate matrix=, and make the vars panel open a rich modal without breaking the page script.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-12 14:40:55 +08:00
1 parent 505d478724
commit d269ccb7e7
15 files changed
+1622 -162

No files matched your search

+15 -3
View File
@@ -118,6 +118,14 @@ Append another circuit's ops or a `{gate,qubits}` op map.
**> quantum_append circuit=`self` op=`op`**
## apply
+ `gate`
+ `qubits`=0
Apply a gate handle (named or custom `matrix=`) on `qubits` (int or list).
**> quantum_apply circuit=`self` gate=`gate` qubits=`qubits`**
## noise
+ `kind`
+ `p`
@@ -162,13 +170,17 @@ Circuit rail / probability bars / Bloch sphere SVG (`kind=circuit|probs|bloch`).
**> quantum_draw_circuit circuit=`self` path=`path` kind=`kind` qubit=`qubit`**
# gate
+ `name`
+ `name`=None
+ `theta`=None
+ `matrix`=None
Named gate handle (built-in unitary). Use `matches_matrix` to check an author-supplied matrix.
Named built-in gate (`name=H`) or custom unitary from `matrix=` (nested list / `$$` matrix fence). Optional `name=` label for custom gates (default `U`).
> ensure_plugin
**> quantum_gate_new name=`name` theta=`theta`**
1. `matrix`
**> quantum_gate_from_matrix matrix=`matrix` name=`name`**
2. *
**> quantum_gate_new name=`name` theta=`theta`**
## matrix
+15 -3
View File
@@ -118,6 +118,14 @@ description: 官方量子电路模拟(中文)。门 + 电路;ABI 插件。
**> quantum_append circuit=`self` op=`操作`**
## 施加
+ `门`
+ `比特`=0
将门句柄(具名或 `矩阵=` 自定义)施加到 `比特`(整数或列表)。
**> quantum_apply circuit=`self` gate=`门` qubits=`比特`**
## 噪声
+ `种类`
+ `概率`
@@ -162,13 +170,17 @@ description: 官方量子电路模拟(中文)。门 + 电路;ABI 插件。
**> quantum_draw_circuit circuit=`self` path=`路径` kind=`种类` qubit=`比特`**
# 门
+ `名`
+ `名`=None
+ `参数`=None
+ `矩阵`=None
具名门句柄。用「匹配矩阵」核对作者给出的矩阵。
具名内置门(`名=H`)或由 `矩阵=`(嵌套 list / `$$` 矩阵围栏)定义的自定义酉门。自定义门可选 `名=`(默认 `U`)。
> 确保插件
**> quantum_gate_new name=`名` theta=`参数`**
1. `矩阵`
**> quantum_gate_from_matrix matrix=`矩阵` name=`名`**
2. *
**> quantum_gate_new name=`名` theta=`参数`**
## 矩阵