Basic Quantum Gates¶
Basic quantum gates implement the standard single-qubit and multi-qubit quantum gate operations. They act on Boolean registers; see register types for storage details and Hadamard operations for the superposition-creating Hadamard family.
Overview¶
Operator |
Operation |
Unitarity class |
|---|---|---|
|
Pauli-X (bit flip) |
SelfAdjoint |
|
Pauli-Y |
SelfAdjoint |
|
Pauli-Z (phase flip) |
SelfAdjoint |
|
S gate (π/2 phase) |
SelfAdjoint |
|
T gate (π/4 phase) |
SelfAdjoint |
|
Arbitrary phase e^{iλ} |
BaseOperator |
|
Rotation about the X axis |
SelfAdjoint |
|
Rotation about the Y axis |
SelfAdjoint |
|
Rotation about the Z axis |
SelfAdjoint |
|
√X gate |
SelfAdjoint |
|
General single-qubit gate (2 parameters) |
BaseOperator |
|
General single-qubit gate (3 parameters) |
BaseOperator |
Type Constraints¶
All quantum gates require:
Register type: Boolean (single-qubit gates)
Bit index: must be within the register size range [0, size)
# Correct: Boolean type for single-qubit gates
ps.System.add_register("qubit", ps.Boolean, 1)
ps.X_Bool("qubit", 0)(state)
# Wrong: bit index out of range
# ps.X_Bool("qubit", 1)(state) # Raises an exception!
—
Pauli Gates¶
X_Bool (Pauli-X / NOT)¶
- class pysparq.X_Bool¶
- clear_control_all_ones(self: pysparq._core.X_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_bit(self: pysparq._core.X_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_value(self: pysparq._core.X_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_nonzeros(self: pysparq._core.X_Bool) None¶
Clear all control conditions of the specified type.
- property condition_variable_all_ones¶
- property condition_variable_by_bit¶
- property condition_variable_by_value¶
- property condition_variable_nonzeros¶
- conditioned_by_all_ones(*args, **kwargs)¶
Overloaded function.
conditioned_by_all_ones(self: pysparq._core.X_Bool, cond: str) -> pysparq._core.X_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.X_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.X_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.X_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.X_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
- conditioned_by_bit(*args, **kwargs)¶
Overloaded function.
conditioned_by_bit(self: pysparq._core.X_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.X_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.X_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.X_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.X_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.X_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
- conditioned_by_nonzeros(*args, **kwargs)¶
Overloaded function.
conditioned_by_nonzeros(self: pysparq._core.X_Bool, cond: str) -> pysparq._core.X_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.X_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.X_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.X_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.X_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
- conditioned_by_value(*args, **kwargs)¶
Overloaded function.
conditioned_by_value(self: pysparq._core.X_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.X_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.X_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.X_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.X_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.X_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.X_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
Operation: Bit flip |0⟩ ↔ |1⟩
Matrix:
import pysparq as ps
ps.System.clear()
ps.System.add_register("q", ps.Boolean, 1)
state = ps.SparseState()
# Initially |q=0⟩
ps.X_Bool("q", 0)(state)
# |q=1⟩
# Applying again restores the original state (self-adjoint)
ps.X_Bool("q", 0)(state)
# |q=0⟩
Y_Bool (Pauli-Y)¶
- class pysparq.Y_Bool¶
- clear_control_all_ones(self: pysparq._core.Y_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_bit(self: pysparq._core.Y_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_value(self: pysparq._core.Y_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_nonzeros(self: pysparq._core.Y_Bool) None¶
Clear all control conditions of the specified type.
- property condition_variable_all_ones¶
- property condition_variable_by_bit¶
- property condition_variable_by_value¶
- property condition_variable_nonzeros¶
- conditioned_by_all_ones(*args, **kwargs)¶
Overloaded function.
conditioned_by_all_ones(self: pysparq._core.Y_Bool, cond: str) -> pysparq._core.Y_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.Y_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Y_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Y_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.Y_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
- conditioned_by_bit(*args, **kwargs)¶
Overloaded function.
conditioned_by_bit(self: pysparq._core.Y_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Y_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Y_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Y_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Y_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Y_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
- conditioned_by_nonzeros(*args, **kwargs)¶
Overloaded function.
conditioned_by_nonzeros(self: pysparq._core.Y_Bool, cond: str) -> pysparq._core.Y_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.Y_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Y_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Y_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.Y_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
- conditioned_by_value(*args, **kwargs)¶
Overloaded function.
conditioned_by_value(self: pysparq._core.Y_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Y_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Y_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Y_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Y_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Y_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Y_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
Matrix:
ps.Y_Bool("q", 0)(state)
Z_Bool (Pauli-Z)¶
- class pysparq.Z_Bool¶
Operation: Phase flip |1⟩ → -|1⟩
Matrix:
ps.Z_Bool("q", 0)(state)
—
Phase Gates¶
S_Bool (S gate)¶
- class pysparq.S_Bool¶
Operation: Phase rotation by π/2
Matrix:
ps.S_Bool("q", 0)(state)
T_Bool (T gate)¶
- class pysparq.T_Bool¶
Operation: Phase rotation by π/4
Matrix:
ps.T_Bool("q", 0)(state)
Phase_Bool (arbitrary phase)¶
- class pysparq.Phase_Bool¶
- clear_control_all_ones(self: pysparq._core.Phase_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_bit(self: pysparq._core.Phase_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_value(self: pysparq._core.Phase_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_nonzeros(self: pysparq._core.Phase_Bool) None¶
Clear all control conditions of the specified type.
- property condition_variable_all_ones¶
- property condition_variable_by_bit¶
- property condition_variable_by_value¶
- property condition_variable_nonzeros¶
- conditioned_by_all_ones(*args, **kwargs)¶
Overloaded function.
conditioned_by_all_ones(self: pysparq._core.Phase_Bool, cond: str) -> pysparq._core.Phase_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.Phase_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Phase_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Phase_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.Phase_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
- conditioned_by_bit(*args, **kwargs)¶
Overloaded function.
conditioned_by_bit(self: pysparq._core.Phase_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Phase_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Phase_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Phase_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Phase_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Phase_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
- conditioned_by_nonzeros(*args, **kwargs)¶
Overloaded function.
conditioned_by_nonzeros(self: pysparq._core.Phase_Bool, cond: str) -> pysparq._core.Phase_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.Phase_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Phase_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Phase_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.Phase_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
- conditioned_by_value(*args, **kwargs)¶
Overloaded function.
conditioned_by_value(self: pysparq._core.Phase_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Phase_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Phase_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Phase_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Phase_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Phase_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Phase_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
Operation: Phase rotation e^{iλ}
Dagger: Phase rotation e^{-iλ}
# Phase rotation by π/3
op = ps.Phase_Bool("q", 0, np.pi / 3)
op(state)
# Undo
op.dag(state)
—
Rotation Gates¶
RX_Bool (X-axis rotation)¶
- class pysparq.RX_Bool¶
Matrix:
import numpy as np
# X-axis rotation by π/2
ps.RX_Bool("q", np.pi / 2)(state)
RY_Bool (Y-axis rotation)¶
- class pysparq.RY_Bool¶
Matrix:
ps.RY_Bool("q", np.pi / 2)(state)
RZ_Bool (Z-axis rotation)¶
- class pysparq.RZ_Bool¶
- clear_control_all_ones(self: pysparq._core.RZ_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_bit(self: pysparq._core.RZ_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_value(self: pysparq._core.RZ_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_nonzeros(self: pysparq._core.RZ_Bool) None¶
Clear all control conditions of the specified type.
- property condition_variable_all_ones¶
- property condition_variable_by_bit¶
- property condition_variable_by_value¶
- property condition_variable_nonzeros¶
- conditioned_by_all_ones(*args, **kwargs)¶
Overloaded function.
conditioned_by_all_ones(self: pysparq._core.RZ_Bool, cond: str) -> pysparq._core.RZ_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.RZ_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.RZ_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.RZ_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.RZ_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
- conditioned_by_bit(*args, **kwargs)¶
Overloaded function.
conditioned_by_bit(self: pysparq._core.RZ_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.RZ_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.RZ_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.RZ_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.RZ_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.RZ_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
- conditioned_by_nonzeros(*args, **kwargs)¶
Overloaded function.
conditioned_by_nonzeros(self: pysparq._core.RZ_Bool, cond: str) -> pysparq._core.RZ_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.RZ_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.RZ_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.RZ_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.RZ_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
- conditioned_by_value(*args, **kwargs)¶
Overloaded function.
conditioned_by_value(self: pysparq._core.RZ_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.RZ_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.RZ_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.RZ_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.RZ_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.RZ_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.RZ_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
Matrix:
ps.RZ_Bool("q", np.pi / 2)(state)
SX_Bool (√X gate)¶
- class pysparq.SX_Bool¶
Operation: X^{1/2}
ps.SX_Bool("q", 0)(state)
—
Universal Gates¶
U2_Bool (2-parameter universal gate)¶
- class pysparq.U2_Bool¶
Matrix:
U3_Bool (3-parameter universal gate)¶
- class pysparq.U3_Bool¶
Matrix:
import numpy as np
op = ps.U3_Bool("q", np.pi/4, np.pi/2, 0)
op(state)
# Undo
op.dag(state)
—
Other Gates¶
Rot_Bool (general rotation)¶
- class pysparq.Rot_Bool¶
- clear_control_all_ones(self: pysparq._core.Rot_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_bit(self: pysparq._core.Rot_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_by_value(self: pysparq._core.Rot_Bool) None¶
Clear all control conditions of the specified type.
- clear_control_nonzeros(self: pysparq._core.Rot_Bool) None¶
Clear all control conditions of the specified type.
- property condition_variable_all_ones¶
- property condition_variable_by_bit¶
- property condition_variable_by_value¶
- property condition_variable_nonzeros¶
- conditioned_by_all_ones(*args, **kwargs)¶
Overloaded function.
conditioned_by_all_ones(self: pysparq._core.Rot_Bool, cond: str) -> pysparq._core.Rot_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.Rot_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Rot_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Rot_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
conditioned_by_all_ones(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.Rot_Bool
Condition this operation on registers where all bits are 1.
Calling this method replaces prior all-ones conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
- conditioned_by_bit(*args, **kwargs)¶
Overloaded function.
conditioned_by_bit(self: pysparq._core.Rot_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Rot_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Rot_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Rot_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Rot_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
conditioned_by_bit(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Rot_Bool
Condition this operation on a specific bit position.
Calling this method replaces prior bit conditions. Pass the list-of-pairs overload to require several bits simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Bit position to check (0-indexed).
conds – List of (register, position) pairs.
- Returns:
Self, for method chaining.
- conditioned_by_nonzeros(*args, **kwargs)¶
Overloaded function.
conditioned_by_nonzeros(self: pysparq._core.Rot_Bool, cond: str) -> pysparq._core.Rot_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[str]) -> pysparq._core.Rot_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Rot_Bool, cond: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Rot_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
conditioned_by_nonzeros(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> pysparq._core.Rot_Bool
Condition this operation on registers with nonzero values.
Calling this method replaces prior nonzero-register conditions. Pass the list overload to require several registers simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int) to condition on.
conds – List of register names or IDs for multi-condition.
- Returns:
Self, for method chaining.
Example
op.conditioned_by_nonzeros(‘control_reg’)(state)
- conditioned_by_value(*args, **kwargs)¶
Overloaded function.
conditioned_by_value(self: pysparq._core.Rot_Bool, cond: str, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Rot_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[tuple[str, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Rot_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Rot_Bool, cond: typing.SupportsInt | typing.SupportsIndex, pos: typing.SupportsInt | typing.SupportsIndex) -> pysparq._core.Rot_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
conditioned_by_value(self: pysparq._core.Rot_Bool, conds: collections.abc.Sequence[tuple[typing.SupportsInt | typing.SupportsIndex, typing.SupportsInt | typing.SupportsIndex]]) -> pysparq._core.Rot_Bool
Condition this operation on registers holding a specific value.
Calling this method replaces prior value conditions. Pass the list-of-pairs overload to require several values simultaneously; conditions of different kinds are combined with logical AND.
- Parameters:
cond – Register name (str) or ID (int).
pos – Value to match.
conds – List of (register, value) pairs.
- Returns:
Self, for method chaining.
Operation: Apply an arbitrary 2×2 unitary matrix
import numpy as np
# Define a 2x2 matrix
matrix = np.array([
[np.cos(np.pi/4), -np.sin(np.pi/4)],
[np.sin(np.pi/4), np.cos(np.pi/4)]
])
ps.Rot_Bool("q", matrix)(state)
Reflection_Bool (reflection gate)¶
The reflection gate is documented under phase and reflection operators; it implements the diffusion operator used in Grover search.