PySparQ.pysparq.algorithms.qram_utils

QRAM 电路构建的经典辅助函数。

Attributes

PI

与 C++ constexpr double pi 匹配的 Pi 常量。

Functions

column_flatten(→ list[float])

将行优先方阵转置为列优先表示。

create_qram_utils_demo(→ str)

返回展示本模块典型用法的演示脚本字符串。

get_complement(→ int)

反向二进制补码:将无符号值符号扩展为有符号整数。

make_complement(→ int)

将有符号整数转换为其二进制补码表示。

make_func(→ list[complex])

从有理寄存器值计算 2x2 旋转矩阵。

make_func_inv(→ list[complex])

从有理寄存器值计算逆 2x2 旋转矩阵。

make_vector_tree(→ list[int])

从叶分布数据构建用于 QRAM 电路的二叉树。

pow2(→ int)

通过左移返回 2**n,匹配 basic.h 语义。

scale_and_convert_vector(→ list[int])

缩放浮点值并转换为二进制补码整数。

Module Contents

PySparQ.pysparq.algorithms.qram_utils.column_flatten(row_vec: list[float]) list[float][源代码]

将行优先方阵转置为列优先表示。

PySparQ.pysparq.algorithms.qram_utils.create_qram_utils_demo() str[源代码]

返回展示本模块典型用法的演示脚本字符串。

PySparQ.pysparq.algorithms.qram_utils.get_complement(data: int, data_sz: int) int[源代码]

反向二进制补码:将无符号值符号扩展为有符号整数。

PySparQ.pysparq.algorithms.qram_utils.make_complement(data: int, data_sz: int) int[源代码]

将有符号整数转换为其二进制补码表示。

PySparQ.pysparq.algorithms.qram_utils.make_func(value: int, n_digit: int) list[complex][源代码]

从有理寄存器值计算 2x2 旋转矩阵。

PySparQ.pysparq.algorithms.qram_utils.make_func_inv(value: int, n_digit: int) list[complex][源代码]

从有理寄存器值计算逆 2x2 旋转矩阵。

PySparQ.pysparq.algorithms.qram_utils.make_vector_tree(dist: list[int], data_size: int) list[int][源代码]

从叶分布数据构建用于 QRAM 电路的二叉树。

PySparQ.pysparq.algorithms.qram_utils.pow2(n: int) int[源代码]

通过左移返回 2**n,匹配 basic.h 语义。

PySparQ.pysparq.algorithms.qram_utils.scale_and_convert_vector(input_vec: list[float] | numpy.ndarray, exponent: int, data_size: int, from_matrix: bool = ...) list[int][源代码]

缩放浮点值并转换为二进制补码整数。

PySparQ.pysparq.algorithms.qram_utils.PI: float[源代码]

与 C++ constexpr double pi 匹配的 Pi 常量。