measure-methods: Method measure

Description Usage Arguments Details Value Examples

Description

performs a masurement on a qstate object.

Usage

1
2
3
4
measure(e1, bit = NA, repetitions = NA)

## S4 method for signature 'qstate'
measure(e1, bit = NA, repetitions = 1)

Arguments

e1

object to measure

bit

bit to project on

repetitions

number of measurements

Details

measure(e1, bit, repetitions) performs repetitions many projections/measurements of the qubit bit. If bit is not given explicitly, all qubits are projected.

Value

measure(e1, bit, repetitions) returns a list with the measured bit, the number of repetitions, the probability distribution of all states prob and the results vector value. If all bits are measured, the basis is added to the list as basis. The collapsed state is stored as psi if exactly one measurement is performed. In the case of a single qubit measurement value is of length repetitions and contains all the results of this projection. Otherwise value is of length 2^nbits and it contains the counts how often each state has been obtained.

Examples

1
2
3
4
## measure the separate bits
x <- H(1) * (H(2) * qstate(nbits=2))
summary(measure(x, bit=1))
hist(measure(x, rep=100))

qsimulatR documentation built on Jan. 13, 2021, 3:13 p.m.