PySparQ.pysparq.algorithms.qram_utils¶
Classical helper functions for building QRAM circuits.
Attributes¶
Pi constant matching the C++ |
Functions¶
|
Transpose a row-major square matrix into its column-major representation. |
|
Return a demo script string showing typical usage of this module. |
|
Inverse two's complement: sign-extend an unsigned value to a signed integer. |
|
Convert a signed integer to its two's-complement representation. |
|
Compute a 2x2 rotation matrix from a rational register value. |
|
Compute the inverse 2x2 rotation matrix from a rational register value. |
|
Build a binary tree for QRAM circuits from leaf-distribution data. |
|
Return |
|
Scale floating-point values and convert to two's-complement integers. |
Module Contents¶
- PySparQ.pysparq.algorithms.qram_utils.column_flatten(row_vec: list[float]) list[float][源代码]¶
Transpose a row-major square matrix into its column-major representation.
- PySparQ.pysparq.algorithms.qram_utils.create_qram_utils_demo() str[源代码]¶
Return a demo script string showing typical usage of this module.
- PySparQ.pysparq.algorithms.qram_utils.get_complement(data: int, data_sz: int) int[源代码]¶
Inverse two's complement: sign-extend an unsigned value to a signed integer.
- PySparQ.pysparq.algorithms.qram_utils.make_complement(data: int, data_sz: int) int[源代码]¶
Convert a signed integer to its two's-complement representation.
- PySparQ.pysparq.algorithms.qram_utils.make_func(value: int, n_digit: int) list[complex][源代码]¶
Compute a 2x2 rotation matrix from a rational register value.
- PySparQ.pysparq.algorithms.qram_utils.make_func_inv(value: int, n_digit: int) list[complex][源代码]¶
Compute the inverse 2x2 rotation matrix from a rational register value.
- PySparQ.pysparq.algorithms.qram_utils.make_vector_tree(dist: list[int], data_size: int) list[int][源代码]¶
Build a binary tree for QRAM circuits from leaf-distribution data.
- PySparQ.pysparq.algorithms.qram_utils.pow2(n: int) int[源代码]¶
Return
2**nvia a left shift, matchingbasic.hsemantics.