XOR

class XOR(num_qubits, amount=None, seed=None)[source]

An n_qubit circuit for bitwise xor-ing the input with some integer amount.

The amount is xor-ed in bitstring form with the input.

This circuit can also represent addition by amount over the finite field GF(2).

Return a circuit implementing bitwise xor.

Parameters
  • num_qubits (int) – the width of circuit.

  • amount (Optional[int]) – the xor amount in decimal form.

  • seed (Optional[int]) – random seed in case a random xor is requested.

Raises

CircuitError – if the xor bitstring exceeds available qubits.

Reference Circuit:
../_images/qiskit.circuit.library.XOR_0_0.png

Attributes

XOR.clbits

Returns a list of classical bits in the order that the registers were added.

XOR.data

Return the circuit data (instructions and context).

XOR.extension_lib

XOR.header

XOR.instances

XOR.n_qubits

Deprecated, use num_qubits instead.

XOR.num_clbits

Return number of classical bits.

XOR.num_parameters

Convenience function to get the number of parameter objects in the circuit.

XOR.num_qubits

Return number of qubits.

XOR.parameters

Convenience function to get the parameters defined in the parameter table.

XOR.prefix

XOR.qubits

Returns a list of quantum bits in the order that the registers were added.

Methods

XOR.AND(qr_variables, qb_target, qr_ancillae)

Build a collective conjunction (AND) circuit in place using mct.

XOR.OR(qr_variables, qb_target, qr_ancillae)

Build a collective disjunction (OR) circuit in place using mct.

XOR.__getitem__(item)

Return indexed operation.

XOR.__len__()

Return number of operations in circuit.

XOR.add_register(*regs)

Add registers.

XOR.append(instruction[, qargs, cargs])

Append one or more instructions to the end of the circuit, modifying the circuit in place.

XOR.assign_parameters(param_dict[, inplace])

Assign parameters to new parameters or values.

XOR.barrier(*qargs)

Apply Barrier.

XOR.bind_parameters(value_dict)

Assign numeric parameters to values yielding a new circuit.

XOR.cast(value, _type)

Best effort to cast value to type.

XOR.cbit_argument_conversion(…)

Converts several classical bit representations (such as indexes, range, etc.) into a list of classical bits.

XOR.ccx(control_qubit1, control_qubit2, …)

Apply CCXGate.

XOR.ch(control_qubit, target_qubit, *[, …])

Apply CHGate.

XOR.cls_instances()

Return the current number of instances of this class, useful for auto naming.

XOR.cls_prefix()

Return the prefix to use for auto naming.

XOR.cnot(control_qubit, target_qubit, *[, …])

Apply CXGate.

XOR.combine(rhs)

Append rhs to self if self contains compatible registers.

XOR.compose(other[, qubits, clbits, front, …])

Compose circuit with other circuit or instruction, optionally permuting wires.

XOR.copy([name])

Copy the circuit.

XOR.count_ops()

Count each operation kind in the circuit.

XOR.crx(theta, control_qubit, target_qubit, *)

Apply CRXGate.

XOR.cry(theta, control_qubit, target_qubit, *)

Apply CRYGate.

XOR.crz(theta, control_qubit, target_qubit, *)

Apply CRZGate.

XOR.cswap(control_qubit, target_qubit1, …)

Apply CSwapGate.

XOR.cu1(theta, control_qubit, target_qubit, *)

Apply CU1Gate.

XOR.cu3(theta, phi, lam, control_qubit, …)

Apply CU3Gate.

XOR.cx(control_qubit, target_qubit, *[, …])

Apply CXGate.

XOR.cy(control_qubit, target_qubit, *[, …])

Apply CYGate.

XOR.cz(control_qubit, target_qubit, *[, …])

Apply CZGate.

XOR.dcx(qubit1, qubit2)

Apply DCXGate.

XOR.decompose()

Call a decomposition pass on this circuit, to decompose one level (shallow decompose).

XOR.depth()

Return circuit depth (i.e., length of critical path).

XOR.diag_gate(diag, qubit)

Deprecated version of QuantumCircuit.diagonal.

XOR.diagonal(diag, qubit)

Attach a diagonal gate to a circuit.

XOR.draw([output, scale, filename, style, …])

Draw the quantum circuit.

XOR.extend(rhs)

Append QuantumCircuit to the right hand side if it contains compatible registers.

XOR.fredkin(control_qubit, target_qubit1, …)

Apply CSwapGate.

XOR.from_qasm_file(path)

Take in a QASM file and generate a QuantumCircuit object.

XOR.from_qasm_str(qasm_str)

Take in a QASM string and generate a QuantumCircuit object.

XOR.h(qubit, *[, q])

Apply HGate.

XOR.hamiltonian(operator, time, qubits[, label])

Apply hamiltonian evolution to to qubits.

XOR.has_register(register)

Test if this circuit has the register r.

XOR.i(qubit, *[, q])

Apply IGate.

XOR.id(qubit, *[, q])

Apply IGate.

XOR.iden(qubit, *[, q])

Deprecated identity gate.

XOR.initialize(params, qubits)

Apply initialize to circuit.

XOR.inverse()

Invert this circuit.

XOR.iso(isometry, q_input, q_ancillas_for_output)

Attach an arbitrary isometry from m to n qubits to a circuit.

XOR.isometry(isometry, q_input, …[, …])

Attach an arbitrary isometry from m to n qubits to a circuit.

XOR.iswap(qubit1, qubit2)

Apply iSwapGate.

XOR.mcmt(gate, control_qubits, target_qubits)

Apply a multi-control, multi-target using a generic gate.

XOR.mcrx(theta, q_controls, q_target[, …])

Apply Multiple-Controlled X rotation gate

XOR.mcry(theta, q_controls, q_target, q_ancillae)

Apply Multiple-Controlled Y rotation gate

XOR.mcrz(lam, q_controls, q_target[, …])

Apply Multiple-Controlled Z rotation gate

XOR.mct(control_qubits, target_qubit[, …])

Apply MCXGate.

XOR.mcu1(lam, control_qubits, target_qubit)

Apply MCU1Gate.

XOR.mcx(control_qubits, target_qubit[, …])

Apply MCXGate.

XOR.measure(qubit, cbit)

Measure quantum bit into classical bit (tuples).

XOR.measure_active([inplace])

Adds measurement to all non-idle qubits.

XOR.measure_all([inplace])

Adds measurement to all qubits.

XOR.mirror()

Mirror the circuit by reversing the instructions.

XOR.ms(theta, qubits)

Apply MSGate.

XOR.num_connected_components([unitary_only])

How many non-entangled subcircuits can the circuit be factored to.

XOR.num_nonlocal_gates()

Return number of non-local gates (i.e.

XOR.num_tensor_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

XOR.num_unitary_factors()

Computes the number of tensor factors in the unitary (quantum) part of the circuit only.

XOR.qasm([formatted, filename])

Return OpenQASM string.

XOR.qbit_argument_conversion(…)

Converts several qubit representations (such as indexes, range, etc.) into a list of qubits.

XOR.r(theta, phi, qubit, *[, q])

Apply RGate.

XOR.rcccx(control_qubit1, control_qubit2, …)

Apply RC3XGate.

XOR.rccx(control_qubit1, control_qubit2, …)

Apply RCCXGate.

XOR.remove_final_measurements([inplace])

Removes final measurement on all qubits if they are present.

XOR.reset(qubit)

Reset q.

XOR.rx(theta, qubit, *[, label, q])

Apply RXGate.

XOR.rxx(theta, qubit1, qubit2)

Apply RXXGate.

XOR.ry(theta, qubit, *[, label, q])

Apply RYGate.

XOR.ryy(theta, qubit1, qubit2)

Apply RYYGate.

XOR.rz(phi, qubit, *[, q])

Apply RZGate.

XOR.rzx(theta, qubit1, qubit2)

Apply RZXGate.

XOR.rzz(theta, qubit1, qubit2)

Apply RZZGate.

XOR.s(qubit, *[, q])

Apply SGate.

XOR.sdg(qubit, *[, q])

Apply SdgGate.

XOR.size()

Returns total number of gate operations in circuit.

XOR.snapshot(label[, snapshot_type, qubits, …])

Take a statevector snapshot of the internal simulator representation.

XOR.snapshot_density_matrix(label[, qubits])

Take a density matrix snapshot of simulator state.

XOR.snapshot_expectation_value(label, op, qubits)

Take a snapshot of expectation value <O> of an Operator.

XOR.snapshot_probabilities(label, qubits[, …])

Take a probability snapshot of the simulator state.

XOR.snapshot_stabilizer(label)

Take a stabilizer snapshot of the simulator state.

XOR.snapshot_statevector(label)

Take a statevector snapshot of the simulator state.

XOR.squ(unitary_matrix, qubit[, mode, …])

Decompose an arbitrary 2*2 unitary into three rotation gates.

XOR.swap(qubit1, qubit2)

Apply SwapGate.

XOR.t(qubit, *[, q])

Apply TGate.

XOR.tdg(qubit, *[, q])

Apply TdgGate.

XOR.to_gate([parameter_map])

Create a Gate out of this circuit.

XOR.to_instruction([parameter_map])

Create an Instruction out of this circuit.

XOR.toffoli(control_qubit1, control_qubit2, …)

Apply CCXGate.

XOR.u1(theta, qubit, *[, q])

Apply U1Gate.

XOR.u2(phi, lam, qubit, *[, q])

Apply U2Gate.

XOR.u3(theta, phi, lam, qubit, *[, q])

Apply U3Gate.

XOR.uc(gate_list, q_controls, q_target[, …])

Attach a uniformly controlled gates (also called multiplexed gates) to a circuit.

XOR.ucg(angle_list, q_controls, q_target[, …])

Deprecated version of uc.

XOR.ucrx(angle_list, q_controls, q_target)

Attach a uniformly controlled (also called multiplexed) Rx rotation gate to a circuit.

XOR.ucry(angle_list, q_controls, q_target)

Attach a uniformly controlled (also called multiplexed) Ry rotation gate to a circuit.

XOR.ucrz(angle_list, q_controls, q_target)

Attach a uniformly controlled (also called multiplexed gates) Rz rotation gate to a circuit.

XOR.ucx(angle_list, q_controls, q_target)

Deprecated version of ucrx.

XOR.ucy(angle_list, q_controls, q_target)

Deprecated version of ucry.

XOR.ucz(angle_list, q_controls, q_target)

Deprecated version of ucrz.

XOR.unitary(obj, qubits[, label])

Apply unitary gate to q.

XOR.width()

Return number of qubits plus clbits in circuit.

XOR.x(qubit, *[, label, ctrl_state, q])

Apply XGate.

XOR.y(qubit, *[, q])

Apply YGate.

XOR.z(qubit, *[, q])

Apply ZGate.

XOR.__len__()

Return number of operations in circuit.

XOR.__getitem__(item)

Return indexed operation.