量子电路(ext/quantum)ok
文档
怎样读这份可执行文档
正文说明意图,标记指出哪些片段会执行。遮蔽只在正文显示动作说明,实际逻辑放在侧注;阅读、展开与定位都不会运行代码。
| 标记 | 阅读含义 |
|---|---|
无标记文字 | 作者的解释,按普通 Markdown 阅读。 |
空行 | 分隔叙述与结构,不是计算步骤。 |
# / ## | 一级标题声明对象或入口,更深标题声明函数;说明按钮可查看输入、返回与依据。 |
> | 调用函数;实际执行结果另有标注。 |
1. 递增 | 按条件选择分支,不是普通编号说明。 |
- | 重复或遍历结构;迭代选择器只切换已有运行记录。 |
+ `名` | 兼容的显式形参;新库优先在叙述中声明参数,标题下的表格解释契约。 |
GFM 表 | 未绑定的契约表是说明;绑定表按列、行和 @ 形态构成数据。 |
```lang | 代码块;绑定的外语代码与普通示例区分展示,数学公式另有公式卡片。 |
--- / *** | 分隔内容,不能把分隔线当作函数返回。 |
<!-- marqdo-out --> | 程序写回的结果,区别于作者原始正文。 |
`名` | 叙述中的参数或变量;默认值跟在名称之后。 |
**…** | 执行语句:赋值、调用或计算;不是打印,也不是返回。 |
*…* | 返回表达式;句中以返回、Return 等明确引出。 |
*None* / **** | 显式返回空值或结束当前函数。 |
[键](集合) | 正文显示描述,侧注按函数与参数、可跳转链接、结构化内容展示括号内的细节;空括号表示待补充实际逻辑。阅读不会执行调用。classic 模式保留旧链接取元。 |
修饰… [函数] … | 兼容的带修饰调用;不能把任意普通链接当作执行授权。 |
集合[^键] | 兼容的脚注取元;当前库优先用 access 读取集合。 |
*仅* / **说明** | 普通强调仍属于文字;界面按真实解析结果区分强调、语句与返回。 |
量子:ext/quantum/量子/电路/索引.mq.md门:ext/quantum/量子/门/索引.mq.md
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 |
可选扩展(非 stdlib)。安装:marqdo ext add quantum(或编译 marqdo_plugin_quantum)。
中文面在同包 ext/quantum/量子/(根 skill:索引.mq.md),与英文模块树并列、不混排 API。
GHZ(3 比特):q0 哈达玛,再控非 0→1、0→2。理想 |000⟩ / |111⟩ 各约 1/2。
Q7:密度 / 部分迹 / Schmidt / 绘图 种类=hinton 等 — examples/quantum-entanglement/。
Q8:绘图 主题="dark"|"light"|"bw"(默认 dark 科技感)作用于电路 / 概率 / 布洛赫。改插件后须再 ext add,view 才会加载新 .so。
步骤 =
| 步 | 门 | 比特 |
|---|---|---|
| 1 | H | 0 |
| 2 | CX | 0,1 |
| 3 | CX | 0,2 |
我们先qc = ,供下一步使用。
函数调用计算并保存 qc
量子.电路- 比特数
3- 步骤
`步骤`
原始写法
量子.电路(比特数=3, 步骤=`步骤`)我们先p = ,供下一步使用。
函数调用计算并保存 p
qc.概率无需传入参数
原始写法
> `qc`.概率我们先_ = ,供下一步使用。
函数调用计算并保存 _
qc.绘图- 种类
- probs
- 主题
- dark
原始写法
> `qc`.绘图 种类="probs" 主题="dark"我们先H = ,供下一步使用。
函数调用计算并保存 H
门.门- 名
- H
原始写法
门.门(名="H")我们先__ = ,供下一步使用。
函数调用计算并保存 __
H.绘图- 种类
- matrix
原始写法
> `H`.绘图 种类="matrix"随后我们。
函数调用显示当前步骤的结果
打印- 内容
`p`
原始写法
> 打印 内容=`p`随后我们。
函数调用显示当前步骤的结果
打印- 内容
- 量子特性-ok
原始写法
> 打印 内容="量子特性-ok"Functions
Variables
-
H 门
_type 门 _type_module List(1) name H key value _type 门 _type_module # value 1 门 name H -
_ quantum_svg
_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> -
__ quantum_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> -
description text官方量子模拟 — 表、门、Q7 密度与高级图、Q8 主题 SVG官方量子模拟 — 表、门、Q7 密度与高级图、Q8 主题 SVG
-
markup textocclusionocclusion
-
p map · 2
000 0.5 111 0.5 key value 000 0.5 111 0.5 -
qc 电路
_type 电路 _type_module List(1) ops … qubits 3 key value _type 电路 _type_module # value 1 量子 ops # gate qubits 1 H # value 1 0 2 CX # value 1 0 2 1 3 CX # value 1 0 2 2 qubits 3 -
title text量子电路(ext/quantum)量子电路(ext/quantum)
-
步骤 map · 3
步 List(3) 门 List(3) 比特 List(3) key value 步 # value 1 1 2 2 3 3 门 # value 1 H 2 CX 3 CX 比特 # value 1 0 2 0,1 3 0,2
可执行知识 · 输入、返回与依据
这份文档怎样成为可调用的知识
1 个知识单元 · 14 个结构步骤。先读输入、返回与调用边界,再按需查看依赖和依据。
以下来自静态分析,不代表程序已经运行、测试通过或内容已获领域确认。实际运行见正文标注与“运行与结果”。
main程序入口
回到正文 · 第 10 行
这是程序入口或对象声明。成员函数的输入输出在各自说明中列出。
源码中的返回契约
any · 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。
调用边界
输出文本、plugin.call、process.control。权限由实际运行入口授予;静态副作用信息不等于运行许可。
当前有哪些依据
- 语法与引用
- 检查通过;检查通过
- 契约检查
- 尚未检查
- 测试记录
- 没有可用记录
- 内容来源
- 尚无已核验证据
- 领域审阅
- 尚未进行领域审阅
查看本单元的结构步骤
这是源码结构,不是实际执行时序;正文引用不会因阅读而执行。
技术详情:身份、摘要与原始状态
- 目标标识
mq://public/features%2F06-%E9%87%8F%E5%AD%90/type/main- 制品摘要(未检查锁定状态)
sha256:90b955c9d7adb04426d7666dc3b6fd81aa0b8fa25a3f766374f673d0da1da9b3- 依赖标识
- 原始验证状态
parse: passed; resolve: passed; contract: unchecked; execution: not_run; tests: unknown; evidence: unverified; domain: unreviewed
运行与结果
{000: 0.5, 111: 0.5}
量子特性-ok
完整源码
--- markup: occlusion title: 量子电路(ext/quantum) description: 官方量子模拟 — 表、门、Q7 密度与高级图、Q8 主题 SVG 导入: 量子: ext/quantum/量子/电路/索引.mq.md 门: ext/quantum/量子/门/索引.mq.md --- # main | 返回 | 类型 | 说明 | |---|---|---| | result | any | 空值;按顺序执行本页的演示步骤,观察输出或已说明的副作用。 | 可选扩展(非 stdlib)。安装:`marqdo ext add quantum`(或编译 `marqdo_plugin_quantum`)。 中文面在同包 `ext/quantum/量子/`(根 skill:`索引.mq.md`),与英文模块树并列、不混排 API。 GHZ(3 比特):q0 哈达玛,再控非 0→1、0→2。理想 |000⟩ / |111⟩ 各约 1/2。 Q7:密度 / 部分迹 / Schmidt / `绘图 种类=hinton` 等 — `examples/quantum-entanglement/`。 Q8:`绘图 主题="dark"|"light"|"bw"`(默认 dark 科技感)作用于电路 / 概率 / 布洛赫。改插件后须再 `ext add`,view 才会加载新 `.so`。 `步骤` = | 步 | 门 | 比特 | |----|----|------| | 1 | H | 0 | | 2 | CX | 0,1 | | 3 | CX | 0,2 | 我们先**qc = [计算并保存 qc](量子.电路(比特数=3, 步骤=`步骤`))**,供下一步使用。 我们先**p = [计算并保存 p](> `qc`.概率)**,供下一步使用。 我们先**_ = [计算并保存 _](> `qc`.绘图 种类="probs" 主题="dark")**,供下一步使用。 我们先**H = [计算并保存 H](门.门(名="H"))**,供下一步使用。 我们先**__ = [计算并保存 __](> `H`.绘图 种类="matrix")**,供下一步使用。 随后我们**[显示当前步骤的结果](> 打印 内容=`p`)**。 随后我们**[显示当前步骤的结果](> 打印 内容="量子特性-ok")**。