Measurement Methods
Methods related to Measurement like Projection or Expectation Value.
Documents
GroverAlgorithm.measure — Method
measure(mps::MPS, m::AbstractMeasurement) -> AnyExecute 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: ReturnsFloat64orComplexF64- the expectation value.Sampling: ReturnsDict{String, Int}- counts for each basis state.ProjectiveMeasurement: ReturnsTuple{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]))