measure: measure

Description Usage Arguments Value Examples

View source: R/measure.R

Description

Probabilistically measures the input ket. By default measures all qubits, but if a list of integers is supplied it will measure only those qubits. Returns a list containing the state of the ket after measurement along with integer value of the state that was measured. Additionally, returns a vector of the measured binary values, if a list of qubits to measure was specified.

Usage

1

Arguments

...

The input ket to measure. Optionally followed by integers specifying which qubits of the ket to measure. Qubits indexed from 0 from right to left

l2r

Boolean which specifices if indexing should be performed from left to right. Is FALSE by default to maintain backwards compatibility, however all other functions index from left to right.

Value

A list with the first item a column vector containing normalized amplitudes of the measured ket and the second item the integer value of the state which was measured. If a list of qubits to measure was specified as an argument, there is a 3rd item in the list which is a vector of the binary measured values.

Examples

1
2
3
4
5
 measure(ket(1,0),l2r=TRUE)
 measure(ket(1,2,2,1),0,l2r=TRUE)
 measure(ket(1,2,3,4,5,6,7,8),0,l2r=TRUE)
 measure(ket(1,2,3,4,5,6,7,8),0,1,l2r=TRUE)
 measure(ket(1,2,3,4,5,6,7,8),0,1,2,l2r=TRUE)

Example output

Attaching package:QuantumOpsThe following object is masked frompackage:stats:

    dist

The following objects are masked frompackage:base:

    I, norm, single

[[1]]
     [,1]
[1,] 1+0i
[2,] 0+0i

[[2]]
[1] 0

[[1]]
             [,1]
[1,] 0.4472136+0i
[2,] 0.8944272+0i
[3,] 0.0000000+0i
[4,] 0.0000000+0i

[[2]]
[1] 1

[[3]]
[1] 0

[[1]]
             [,1]
[1,] 0.0000000+0i
[2,] 0.0000000+0i
[3,] 0.0000000+0i
[4,] 0.0000000+0i
[5,] 0.3790490+0i
[6,] 0.4548588+0i
[7,] 0.5306686+0i
[8,] 0.6064784+0i

[[2]]
[1] 7

[[3]]
[1] 1

[[1]]
             [,1]
[1,] 0.0000000+0i
[2,] 0.0000000+0i
[3,] 0.0000000+0i
[4,] 0.0000000+0i
[5,] 0.6401844+0i
[6,] 0.7682213+0i
[7,] 0.0000000+0i
[8,] 0.0000000+0i

[[2]]
[1] 5

[[3]]
[1] 1 0

[[1]]
     [,1]
[1,] 0+0i
[2,] 0+0i
[3,] 0+0i
[4,] 0+0i
[5,] 0+0i
[6,] 1+0i
[7,] 0+0i
[8,] 0+0i

[[2]]
[1] 5

[[3]]
[1] 1 0 1

QuantumOps documentation built on Feb. 3, 2020, 5:07 p.m.