文档中的步骤
结构步骤(非实际执行时序)
marqdo
Optional package (not stdlib). Install: marqdo ext add quantum (or build marqdo_plugin_quantum).
GHZ (3 qubits): H on q0, then CX 0→1 and 0→2. Ideal |000⟩ / |111⟩ each ≈ 1/2.
Q7: Bell density, partial trace, Schmidt, draw kind=hinton / qsphere — examples/quantum-entanglement/.
| step | gate | qubits |
|---|---|---|
| 1 | H | 0 |
| 2 | CX | 0,1 |
| 3 | CX | 0,2 |
| _type | gate |
| name | H |
| key | value |
|---|---|
| _type | gate |
| name | H |
| _type | quantum_svg |
| kind | probs |
| ops | … |
| qubits | 3 |
| svg | <svg xmlns="http://www.w3.org/2000/s… |
| key | value |
|---|---|
| _type | quantum_svg |
| kind | probs |
| ops | 3 |
| qubits | 3 |
| svg | <svg xmlns="http://www.w3.org/2000/svg" width="152" height="180" viewBox="0 0 152.0 180.0" data-theme="dark" role="img" aria-label="measurement probabilities"><defs> <linearGradient id="mq-bg" x1="0" y1="0" x2="1" y2="1"> <stop offset="0%" stop-color="#0a0e14"/> <stop offset="55%" stop-color="#141c28"/> <stop offset="100%" stop-color="#0a0e14"/> </linearGradient> <filter id="mq-glow" x="-40%" y="-40%" width="180%" height="180%"> <feGaussianBlur stdDeviation="2.2" result="b"/> <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge> </filter> <filter id="mq-soft" x="-20%" y="-20%" width="140%" height="140%"> <feDropShadow dx="0" dy="1.5" stdDeviation="1.8" flood-color="#4c6fff" flood-opacity="0.35"/> </filter> </defs><rect width="152.0" height="180.0" rx="14" fill="url(#mq-bg)"/><line x1="36" y1="144" x2="136" y2="144" stroke="#7d8fa3" stroke-width="1.2"/><line x1="36" y1="24" x2="36" y2="144" stroke="#7d8fa3" stroke-width="1.2"/><text x="8" y="28" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#e8eef6">1</text><text x="8" y="148" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#e8eef6">0</text><rect x="40" y="83.99999999999999" width="36" height="60.000000000000014" rx="4" fill="#5b7cfa" stroke="#f0f5ff" stroke-width="1" filter="url(#mq-soft)"/><text x="58" y="162" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="11" fill="#e8eef6">000</text><text x="58" y="78.99999999999999" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#93a4b8">0.50</text><rect x="88" y="83.99999999999999" width="36" height="60.000000000000014" rx="4" fill="#5b7cfa" stroke="#f0f5ff" stroke-width="1" filter="url(#mq-soft)"/><text x="106" y="162" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="11" fill="#e8eef6">111</text><text x="106" y="78.99999999999999" text-anchor="middle" font-family="ui-monospace,Menlo,Consolas,monospace" font-size="10" fill="#93a4b8">0.50</text></svg> |
| _type | quantum_svg |
| kind | matrix |
| svg | <svg xmlns="http://www.w3.org/2000/s… |
| key | value |
|---|---|
| _type | quantum_svg |
| kind | matrix |
| svg | <svg xmlns="http://www.w3.org/2000/svg" width="196" height="192" viewBox="0 0 196.0 192.0" role="img" aria-label="gate matrix heatmap"><text x="8" y="18" font-family="ui-monospace,Menlo,monospace" font-size="12" fill="#1a1a1a">H matrix</text><text x="8" y="67.6" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">0</text><text x="72" y="22" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">0</text><rect x="36" y="28" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="72" y="67.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><rect x="108" y="28" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="144" y="67.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><text x="8" y="139.60000000000002" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">1</text><text x="144" y="22" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="10" fill="#666">1</text><rect x="36" y="100" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="72" y="139.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">0.707</text><rect x="108" y="100" width="72" height="72" fill="rgb(107,116,247)" stroke="#1a1a1a" stroke-width="0.8"/><text x="144" y="139.6" text-anchor="middle" font-family="ui-monospace,Menlo,monospace" font-size="9" fill="#fff">-0.707</text></svg> |
| 000 | 0.5 |
| 111 | 0.5 |
| key | value |
|---|---|
| 000 | 0.5 |
| 111 | 0.5 |
| _type | circuit |
| ops | … |
| qubits | 3 |
| key | value | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| _type | circuit | ||||||||||||||||||||||||||||
| ops |
| ||||||||||||||||||||||||||||
| qubits | 3 |
| step | List(3) |
| gate | List(3) |
| qubits | List(3) |
| key | value | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| step |
| ||||||||
| gate |
| ||||||||
| qubits |
|
结构步骤(非实际执行时序)
--- markup: occlusion title: Quantum circuits (ext/quantum) description: Official quantum simulator — tables, gates, Q7 density, Q8 themed SVG import: quantum: ext/quantum/quantum.mq.md --- # main Optional package (not stdlib). Install: `marqdo ext add quantum` (or build `marqdo_plugin_quantum`). GHZ (3 qubits): H on q0, then CX 0→1 and 0→2. Ideal |000⟩ / |111⟩ each ≈ 1/2. Q7: Bell density, partial trace, Schmidt, `draw kind=hinton` / qsphere — `examples/quantum-entanglement/`. Q8: `draw theme="dark"|"light"|"bw"` (default dark lab look) on circuit / probs / bloch. Rebuild plugin then `ext add` so view loads the new native lib. `steps` = | step | gate | qubits | |------|------|--------| | 1 | H | 0 | | 2 | CX | 0,1 | | 3 | CX | 0,2 | **`qc` = > quantum.circuit qubits=3 steps=`steps`** **`p` = > `qc`.probabilities** **`_` = > `qc`.draw kind="probs" theme="dark"** **`H` = > quantum.gate name="H"** **`__` = > `H`.draw kind="matrix"** > print text=`p` > print text=quantum-feature-ok