Learn R Programming

qsimulatR (version 1.0)

qstate: The qstate class

Description

This class represents a quantum state

Arguments

Slots

nbits

The number of qubits

coefs

The 2^nbits complex valued vector of coefficients

basis

String or vector of strings. A single string will be interpreted as the collapse-parameter in genComputationalBasis. A vector of length 2^nbits yields the basis directly.

circuit

List containing the number of non-quantum bits ncbits and a list of gates gatelist applied to the original state. Filled automatically as gates are applied, required for plotting.

Details

The qubits are counted from 1 to nbits starting with the least significant bit.

Examples

Run this code
x <- qstate(nbits=2)
x

x <- qstate(nbits=2, coefs=as.complex(sqrt(rep(0.25, 4))), basis=",")
x

x <- qstate(nbits=1, coefs=as.complex(sqrt(rep(0.5, 2))), basis=c("|dead>", "|alive>"))
x

Run the code above in your browser using DataLab