Return a copy of this state with qubit labels permuted
327261
def permute(self, qubits: Qubits) -> 'State':
        """"""
        vec = self.vec.permute(qubits)
        return State(vec.tensor, vec.qubits, self._memory)
826759
def without_operations_touching(self, qubits: Iterable[raw_types.Qid]):
        
        qubits = frozenset(qubits)
        if not self.operates_on(qubits):
            return self
        return Moment(
            operation for operation in self.operations
            if qubits.isdisjoint(frozenset(operation.qubits)))
817536
def sX(qubit: Qubit, coefficient: complex = 1.0) -> Pauli:
    """"""
    return Pauli.sigma(qubit, 'X', coefficient)
942187
def copy(self):
        """"""
        ms = MouseState()
        ms.left_pressed = self.left_pressed
        ms.middle_pressed = self.middle_pressed
        ms.right_pressed = self.right_pressed
        ms.mouse_pos = self.mouse_pos
        return ms
88185
def map_qubits(self: TSelf_PauliStringGateOperation,
                   qubit_map: Dict[raw_types.Qid, raw_types.Qid]
                  ) -> TSelf_PauliStringGateOperation:
        
1347339
def on(self,
           *qubits: raw_types.Qid) -> 'SingleQubitPauliStringGateOperation':
        
        if len(qubits) != 1:
            raise ValueError(
                'Expected a single qubit, got <{!r}>.'.format(qubits))
        from cirq.ops.pauli_string import SingleQubitPauliStringGateOperation
        return SingleQubitPauliStringGateOperation(self, qubits[0])
812508
def copy(self):
        
        np = Particle()
        memmove(byref(np), byref(self), sizeof(self))
        return np
122749
def run(self, ket: State = None) -> State:
        
        if ket is None:
            qubits = self.qubits
            ket = zero_state(qubits=qubits)

        for elem in self.elements:
            ket = elem.run(ket)
        return ket
910297
def relabel(self, qubits: Qubits) -> 'Gate':
        """"""
        gate = copy(self)
        gate.vec = gate.vec.relabel(qubits)
        return gate
1154937
function( state ) {
			var key,
				clonedState = {};

			for( key in state ) {
				if( key !== LOCAL ) {
					clonedState[ key ] = state[ key ];
				}
			}

			return clonedState;
		}
1074106
def permute(self, qubits: Qubits) -> 'Density':
        """"""
        vec = self.vec.permute(qubits)
        return Density(vec.tensor, vec.qubits, self._memory)
505944
def qubits(self) -> Qubits:
        
        qbs = [q for elem in self.elements for q in elem.qubits]    # gather
        qbs = list(set(qbs))                                        # unique
        qbs = sorted(qbs)                                           # sort
        return tuple(qbs)
360033
def random_state(qubits: Union[int, Qubits]) -> State:
    """"""
    N, qubits = qubits_count_tuple(qubits)
    ket = np.random.normal(size=([2] * N)) \
        + 1j * np.random.normal(size=([2] * N))
    return State(ket, qubits).normalize()
185898
public Bits dup() {
        Assert.check(currentState != BitsState.UNKNOWN);
        Bits tmp = new Bits();
        tmp.bits = dupBits();
        currentState = BitsState.NORMAL;
        return tmp;
    }
661758
def to_matrix(self, n_qubits=-1):
        """"""
        if n_qubits == -1:
            n_qubits = self.max_n() + 1
        mat = I.to_matrix(n_qubits)
        for op in self.ops:
            if op.is_identity:
                continue
            mat = mat @ op.to_matrix(n_qubits)
        return mat * self.coeff
1290013
def as_qubit_order(val: 'qubit_order_or_list.QubitOrderOrList'
                       ) -> 'QubitOrder':
        
        if isinstance(val, collections.Iterable):
            return QubitOrder.explicit(val)
        if isinstance(val, QubitOrder):
            return val
        raise ValueError(
            "Don't know how to interpret <{}> as a Basis.".format(val))
537278
def generate(self, state):
        """"""
        if self.count >= random.randint(DharmaConst.VARIABLE_MIN, DharmaConst.VARIABLE_MAX):
            return "%s%d" % (self.var, random.randint(1, self.count))
        var = random.choice(self)
        prefix = self.eval(var[0], state)
        suffix = self.eval(var[1], state)
        self.count += 1
        element_name = "%s%d" % (self.var, self.count)
        self.default += "%s%s%s\n" % (prefix, element_name, suffix)
        return element_name