Measurement Methods

Methods related to Measurement like Projection or Expectation Value.

Documents

GroverAlgorithm.measureMethod
measure(mps::MPS, m::AbstractMeasurement) -> Any

Execute a measurement on the given Matrix Product State.

Arguments

  • mps::MPS: The quantum state as an MPS.
  • m::AbstractMeasurement: The measurement specification.

Returns

The return type depends on the measurement:

  • ExpectationValue: Returns Float64 or ComplexF64 - the expectation value.
  • Sampling: Returns Dict{String, Int} - counts for each basis state.
  • ProjectiveMeasurement: Returns Tuple{Int, MPS} - the measurement outcome (0 or 1) and collapsed state.

Throws

  • ArgumentError: If qubit indices are out of range or measurement is invalid.

Notes

  • For multi-qubit ExpectationValue, the operator acts as a tensor product on the specified qubits.

Example

sites = siteinds("Qubit", 2)
psi = MPS(sites, ["0", "0"])
result = measure(psi, ExpectationValue(:Z, [1]))
source