PySparQ.pysparq.algorithms.state_preparation 源代码

"""Quantum state preparation based on QRAM binary-tree decomposition."""

from __future__ import annotations

from typing import Union


[文档] class StatePrepViaQRAM: """Quantum state-preparation operator based on QRAM binary-tree decomposition."""
[文档] qram: object
[文档] work_qubit: str
[文档] addr_size: int
[文档] data_size: int
[文档] rational_size: int
def __init__( self, qram: object, work_qubit: str, data_size: int, rational_size: int, ) -> None: ...
[文档] def conditioned_by_nonzeros( self, cond: Union[str, int, list[Union[str, int]]] ) -> "StatePrepViaQRAM": ...
[文档] def conditioned_by_all_ones( self, cond: Union[str, int, list[Union[str, int]]] ) -> "StatePrepViaQRAM": ...
[文档] def conditioned_by_bit( self, reg: Union[str, int], bit: int ) -> "StatePrepViaQRAM": ...
[文档] def clear_conditions(self) -> "StatePrepViaQRAM": ...
def __call__(self, state: "SparseState") -> None: ...
[文档] def dag(self, state: "SparseState") -> None: ...
[文档] class StatePreparation: """High-level wrapper managing the full state-preparation pipeline."""
[文档] qubit_number: int
[文档] data_size: int
[文档] data_range: int
[文档] rational_size: int
[文档] dist: list[int]
[文档] tree: list[int]
[文档] qram: Union[object, None]
def __init__(self, qubit_number: int, data_size: int, data_range: int) -> None: ...
[文档] def random_distribution(self) -> None: """Generate a random amplitude distribution.""" ...
[文档] def show_distribution(self) -> None: """Print the raw values and normalized amplitudes of the distribution.""" ...
[文档] def get_real_dist(self) -> list[float]: """Return the normalized amplitude distribution as a list of floats.""" ...
[文档] def make_tree(self) -> None: """Build the binary tree from the current distribution.""" ...
[文档] def show_tree(self) -> None: """Print the binary tree level by level.""" ...
[文档] def make_qram(self) -> None: """Create a QRAM circuit sized for the tree data.""" ...
[文档] def set_qram(self) -> None: """Load the binary-tree data into the QRAM circuit.""" ...
[文档] def get_fidelity(self) -> float: """Compute the fidelity between the prepared state and the target state.""" ...
[文档] def run(self) -> None: """Run the full state-preparation pipeline.""" ...
[文档] def create_state_preparation_demo() -> str: """Return a demo script string for state preparation.""" ...