Arcelyth/mqc/simulator/states does not have a README file

    DensityMatrix

    type DensityMatrix

    A quantum state represented by a complex density matrix. For a Bell pair, the wire dimensions are [2, 2]. The basis order is 00, 01, 10, 11.

    The real and imaginary arrays store entries in row-major order. The imaginary entries are all zero in this example. For a matrix of dimension d, the flat index is

    DensityMatrix::basis

    fn DensityMatrix::basis(dimensions : Array[UInt], index : Int) -> DensityMatrix raise
    QError

    DensityMatrix::copy

    DensityMatrix::dim

    fn DensityMatrix::dim(self : DensityMatrix) -> Array[UInt]

    DensityMatrix::entries

    Copy all entries in row-major order.

    DensityMatrix::entry

    DensityMatrix::from_mixture

    fn DensityMatrix::from_mixture(states : Array[StateVector], weights : Array[Double]) -> DensityMatrix raise
    QError

    Mix pure states with finite, nonnegative weights that sum to one. All states must have the same ordered wire dimensions. Inputs are copied.

    DensityMatrix::from_state

    Construct a density matrix from a normalized pure state.

    DensityMatrix::marginal_probabilities

    fn DensityMatrix::marginal_probabilities(self : DensityMatrix, targets : Array[Int]) -> Array[Double] raise
    QError

    DensityMatrix::probabilities

    fn DensityMatrix::probabilities(self : DensityMatrix) -> Array[Double]

    Read computational-basis probabilities from the diagonal, clipping negative roundoff.

    DensityMatrix::purity

    fn DensityMatrix::purity(self : DensityMatrix) -> Double

    Return the purity of the quantum state.

    DensityMatrix::size

    fn DensityMatrix::size(self : DensityMatrix) -> Int

    DensityMatrix::trace

    fn DensityMatrix::trace(self : DensityMatrix) -> Double

    Return the trace of the density matrix.

    DensityMatrix::zero

    DensityMatrixState

    type DensityMatrixState

    Mutable density-matrix execution data.

    DensityMatrixState::apply

    Apply a quantum instruction to the density-matrix state.

    Measurement instructions are handled separately by validating the current state and measuring the requested target wires.

    A channel sums the contributions of its Kraus operators on the target wires. Only explicit measurements append digits to the shot record.

    DensityMatrixState::copy

    DensityMatrixState::density_matrix

    Export a density matrix that later execution cannot mutate.

    DensityMatrixState::dim

    DensityMatrixState::from_density

    fn DensityMatrixState::from_density(matrix : DensityMatrix, seed? : UInt64) -> DensityMatrixState raise
    QError

    DensityMatrixState::new

    fn DensityMatrixState::new(dimensions : Array[UInt], seed? : UInt64) -> DensityMatrixState raise
    QError

    DensityMatrixState::probabilities

    fn DensityMatrixState::probabilities(self : DensityMatrixState) -> Array[Double]

    DensityMatrixState::records

    DensityMatrixState::validate

    SimulationStateBase

    type SimulationStateBase

    Common data for backends that need randomness and measurement records.

    SimulationStateBase::copy

    Copy the records and RNG position into independent storage.

    SimulationStateBase::draw

    fn SimulationStateBase::draw(self : SimulationStateBase) -> Double

    Draw a uniform value in [0, 1).

    SimulationStateBase::latest

    SimulationStateBase::new

    fn SimulationStateBase::new(seed? : UInt64) -> SimulationStateBase

    SimulationStateBase::record

    fn SimulationStateBase::record(self : SimulationStateBase, digits : ArrayView[Int], key? : String) -> Unit

    Append measured digits in target order.

    SimulationStateBase::records

    Return an independent Array3 with axes (shot, occurrence, measured digit). A single execution has shape (1, 1, digit count), including (1, 1, 0).

    StateVector

    pub struct StateVector {
    shape :
    Shape

    re : Array[Double]
    im : Array[Double]
    }

    A quantum state represented by a complex state vector. For a Bell pair, the wire dimensions are [2, 2]. The basis order is 00, 01, 10, 11.

    The real array stores the four amplitudes shown above. The imaginary array contains zeros.

    StateVector::amplitude

    Read one complex amplitude by basis index.

    StateVector::amplitudes

    Copy all amplitudes into a new array in mixed-radix basis order.

    StateVector::basis

    fn StateVector::basis(dimensions : Array[UInt], index : Int) -> StateVector raise
    QError

    StateVector::dim

    fn StateVector::dim(self : StateVector) -> Array[UInt]

    StateVector::from_amplitudes

    fn StateVector::from_amplitudes(dimensions : Array[UInt], amplitudes : Array[
    Complex
    ], tolerance? : Double) -> StateVector raise
    QError

    Accept only a finite, normalized state. Input amplitudes are copied. Require exactly one amplitude per basis state and a finite tolerance in (0, 1e-6].

    StateVector::inner_product

    Return the inner product, conjugating the amplitudes of the first vector.

    StateVector::marginal_probabilities

    fn StateVector::marginal_probabilities(self : StateVector, targets : Array[Int]) -> Array[Double] raise
    QError

    Return the probabilities for the selected wires in target order. For each outcome, sum over basis states with matching digits on those wires.

    StateVector::norm_squared

    fn StateVector::norm_squared(self : StateVector) -> Double

    Return the squared norm using compensated summation.

    StateVector::probabilities

    fn StateVector::probabilities(self : StateVector) -> Array[Double]

    Return the measurement probability of each basis state, in basis order.

    StateVector::size

    fn StateVector::size(self : StateVector) -> Int

    Return the number of basis states for the ordered wire dimensions.

    StateVector::zero

    fn StateVector::zero(dimensions : Array[UInt]) -> StateVector

    StateVectorState

    type StateVectorState

    Mutable state-vector execution data.

    StateVectorState::apply

    Execute one instruction and change this state in place.

    StateVectorState::apply_channel

    fn StateVectorState::apply_channel(self : StateVectorState, channel :
    Channel
    , targets : Array[Int]) -> Unit raise
    QError

    Apply a channel to the target wires for one state-vector trajectory. Draw a Kraus operator with probability equal to the squared norm of the state it produces.

    A unitary mixture supplies these probabilities directly. Sample a gate from the mixture and apply it to the current state.

    For a general Kraus channel, continue the shot with the normalized state

    StateVectorState::copy

    StateVectorState::dim

    fn StateVectorState::dim(self : StateVectorState) -> Array[UInt]

    StateVectorState::from_state

    fn StateVectorState::from_state(state : StateVector, seed? : UInt64) -> StateVectorState raise
    QError

    StateVectorState::new

    fn StateVectorState::new(dimensions : Array[UInt], seed? : UInt64) -> StateVectorState

    StateVectorState::records

    StateVectorState::statevector

    fn StateVectorState::statevector(self : StateVectorState) -> StateVector

    Export a state vector that later execution cannot mutate.

    StateVectorState::validate

    evolve

    Execute unitary kernels. Terminal measurements leave the returned state unchanged. The first wire is the most significant basis digit.