Quantum Operations Reference
◐ Design-level API
This page documents qalgora-Q API design, architecture, or adaptation workflows. Code examples illustrate intended usage and are not guaranteed to run in the current reference implementation.The full set of intrinsic gates and measurements available inside a kernel.
Single-qubit gates
| Gate | Action |
|---|---|
x, y, z | Pauli operators |
h | Hadamard — creates superposition |
s, t | Phase gates (π/2, π/4) |
rx, ry, rz | Parameterized rotations |
r1 | Phase rotation on |1⟩ |
u3 | General single-qubit unitary |
Two-qubit & modifiers
| Form | Meaning |
|---|---|
swap(a, b) | Exchange two qubits |
x.ctrl(c, t) | Controlled gate (CNOT) |
x.ctrl([c1, c2], t) | Multi-controlled (Toffoli); controls as a list… |
x.ctrl(q[0:k], t) | …or as a qview slice — same control set |
t.adj(q) | Adjoint (inverse) of a gate |
Measurements
| Op | Basis |
|---|---|
mz(q) | Computational (Z) basis |
mx(q) | X basis |
my(q) | Y basis |
Custom operations
import qalgora
import numpy as np
# register a custom unitary by its matrix
qalgora.register_operation("iswap", np.array([
[1, 0, 0, 0],
[0, 0, 1j, 0],
[0, 1j, 0, 0],
[0, 0, 0, 1],
]))Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.量子操作参考手册
◐ 设计接口
本页描述的是 qalgora-Q 的接口设计、架构设计或适配工作流。相关代码用于说明预期用法,当前参考实现不保证可以直接运行。内核中可用的全部内置门和测量操作。
单量子比特门
| 门 | 动作 |
|---|---|
x, y, z | Pauli 算符 |
h | Hadamard 门 — 产生叠加态 |
s, t | 相位门(π/2、π/4) |
rx, ry, rz | 参数化旋转 |
r1 | |1⟩ 上的相位旋转 |
u3 | 通用单量子比特幺正算符 |
双量子比特门与修饰符
| 形式 | 含义 |
|---|---|
swap(a, b) | 交换两个量子比特 |
x.ctrl(c, t) | 受控门(CNOT) |
x.ctrl([c1, c2], t) | 多受控门(Toffoli);控制位用列表…… |
x.ctrl(q[0:k], t) | ……或用 qview 切片——表示同一组控制位 |
t.adj(q) | 门的伴随(逆)操作 |
测量
| 操作 | 基 |
|---|---|
mz(q) | 计算基(Z 基) |
mx(q) | X 基 |
my(q) | Y 基 |
自定义操作
import qalgora
import numpy as np
# register a custom unitary by its matrix
qalgora.register_operation("iswap", np.array([
[1, 0, 0, 0],
[0, 0, 1j, 0],
[0, 1j, 0, 0],
[0, 0, 0, 1],
]))规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。