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:
1 parent
505d478724
commit
d269ccb7e7
15 files changed
+1622
-162
No files matched your search
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: quantum custom gate from formula matrix
|
||||
description: $$ H matrix $$ → gate matrix= → apply → probs match built-in H.
|
||||
> ext/quantum/quantum.mq.md
|
||||
> lib/math.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`H_matrix` =
|
||||
$$
|
||||
\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
|
||||
$$
|
||||
|
||||
*`U` = > quantum.gate matrix=`H_matrix` name=U *
|
||||
*`qc` = > quantum.circuit qubits=1 *
|
||||
*`qc` = > `qc`.apply gate=`U` qubits=0 *
|
||||
*`p` = > `qc`.probabilities *
|
||||
*`p0` = `p`[^0] *
|
||||
*`lo` = > math.div a=4 b=10 *
|
||||
*`hi` = > math.div a=6 b=10 *
|
||||
|
||||
1. `p0` > `lo`
|
||||
1. `p0` < `hi`
|
||||
> print text=custom-ok
|
||||
2. *
|
||||
> print text=custom-fail
|
||||
2. *
|
||||
> print text=custom-fail
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: quantum custom gate zh from formula
|
||||
description: $$ 矩阵 $$ → 门 矩阵= → 施加.
|
||||
> ext/quantum/量子.mq.md
|
||||
> lib/math.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`H矩阵` =
|
||||
$$
|
||||
\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}
|
||||
$$
|
||||
|
||||
*`U` = > 量子.门 矩阵=`H矩阵` 名=U *
|
||||
*`qc` = > 量子.电路 比特数=1 *
|
||||
*`qc` = > `qc`.施加 门=`U` 比特=0 *
|
||||
*`p` = > `qc`.概率 *
|
||||
*`p0` = `p`[^0] *
|
||||
*`lo` = > math.div a=4 b=10 *
|
||||
*`hi` = > math.div a=6 b=10 *
|
||||
|
||||
1. `p0` > `lo`
|
||||
1. `p0` < `hi`
|
||||
> print text=custom-ok
|
||||
2. *
|
||||
> print text=custom-fail
|
||||
2. *
|
||||
> print text=custom-fail
|
||||
@@ -1630,6 +1630,28 @@ fn ext_quantum_amp_damp_zh_smoke() {
|
||||
assert_out("tests/ext/quantum-amp-damp-zh-smoke.mq.md", "amp-ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_quantum_custom_gate_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_quantum"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build quantum plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_quantum");
|
||||
assert_out("tests/ext/quantum-custom-gate-smoke.mq.md", "custom-ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_quantum_custom_gate_zh_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_quantum"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build quantum plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_quantum");
|
||||
assert_out("tests/ext/quantum-custom-gate-zh-smoke.mq.md", "custom-ok");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_agent_framework_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
|
||||
Reference in new issue
Block a user