Skip to main content

sites

Method of Operator.

sites() -> List

Returns the sites of an individual operator in definition order. Unlike support(), this preserves the order of sites as they appear in the operator definition. Note: This function only works with individual operators (X, Y, Z, XX, YY, etc.). For OperatorProduct or OperatorSum, use support() instead. Important: The order returned is the constructor order, not necessarily the order of mathematical application.

Returns

A list of indices representing the qubits the operator acts on, in the order they were specified in the constructor.

Example

var op1 = X(0)
var sites1 = sites(op1) // Returns [0]
var op2 = XX(0, 1)
var sites2 = sites(op2) // Returns [0, 1]
var op3 = CNOT(2, 0)
var sites3 = sites(op3) // Returns [2, 0]
var op4 = CNOT(0, 2)
var sites4 = sites(op4) // Returns [0, 2]