基本量子门¶
基本量子门实现单量子比特和多量子比特的标准量子门操作。它们作用于 Boolean 寄存器;存储细节见 寄存器类型,产生叠加态的 Hadamard 家族见 Hadamard 操作。
概述¶
算子 |
操作 |
幺正类 |
|---|---|---|
|
Pauli-X(比特翻转) |
SelfAdjoint |
|
Pauli-Y |
SelfAdjoint |
|
Pauli-Z(相位翻转) |
SelfAdjoint |
|
S 门(π/2 相位) |
SelfAdjoint |
|
T 门(π/4 相位) |
SelfAdjoint |
|
任意相位 e^{iλ} |
BaseOperator |
|
X 轴旋转 |
SelfAdjoint |
|
Y 轴旋转 |
SelfAdjoint |
|
Z 轴旋转 |
SelfAdjoint |
|
√X 门 |
SelfAdjoint |
|
通用单量子比特门(2 参数) |
BaseOperator |
|
通用单量子比特门(3 参数) |
BaseOperator |
类型约束¶
所有量子门要求:
寄存器类型::doc:`Boolean </guide/core_concepts/register_types>`(单量子比特门)
位索引:必须在寄存器大小范围内 [0, size)
# 正确:Boolean 类型用于单量子比特门
ps.System.add_register("qubit", ps.Boolean, 1)
ps.X_Bool("qubit", 0)(state)
# 错误:位索引超出范围
# ps.X_Bool("qubit", 1)(state) # 抛出异常!
---
Pauli 门¶
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
Self, for method chaining.
操作: 比特翻转 |0⟩ ↔ |1⟩
矩阵:
import pysparq as ps
ps.System.clear()
ps.System.add_register("q", ps.Boolean, 1)
state = ps.SparseState()
# 初始 |q=0⟩
ps.X_Bool("q", 0)(state)
# |q=1⟩
# 再次应用恢复原状态(自伴)
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
Self, for method chaining.
矩阵:
ps.Y_Bool("q", 0)(state)
Z_Bool(Pauli-Z)¶
- class pysparq.Z_Bool¶
操作: 相位翻转 |1⟩ → -|1⟩
矩阵:
ps.Z_Bool("q", 0)(state)
---
相位门¶
S_Bool(S 门)¶
- class pysparq.S_Bool¶
操作: 相位旋转 π/2
矩阵:
ps.S_Bool("q", 0)(state)
T_Bool(T 门)¶
- class pysparq.T_Bool¶
操作: 相位旋转 π/4
矩阵:
ps.T_Bool("q", 0)(state)
Phase_Bool(任意相位)¶
- 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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
Self, for method chaining.
操作: 相位旋转 e^{iλ}
Dagger: 相位旋转 e^{-iλ}
# 相位旋转 π/3
op = ps.Phase_Bool("q", 0, np.pi / 3)
op(state)
# 撤销
op.dag(state)
---
旋转门¶
RX_Bool(X 轴旋转)¶
- class pysparq.RX_Bool¶
矩阵:
import numpy as np
# X 轴旋转 π/2
ps.RX_Bool("q", np.pi / 2)(state)
RY_Bool(Y 轴旋转)¶
- class pysparq.RY_Bool¶
矩阵:
ps.RY_Bool("q", np.pi / 2)(state)
RZ_Bool(Z 轴旋转)¶
- 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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
Self, for method chaining.
矩阵:
ps.RZ_Bool("q", np.pi / 2)(state)
SX_Bool(√X 门)¶
- class pysparq.SX_Bool¶
操作: X^{1/2}
ps.SX_Bool("q", 0)(state)
---
通用门¶
U2_Bool(2 参数通用门)¶
- class pysparq.U2_Bool¶
矩阵:
U3_Bool(3 参数通用门)¶
- class pysparq.U3_Bool¶
矩阵:
import numpy as np
op = ps.U3_Bool("q", np.pi/4, np.pi/2, 0)
op(state)
# 撤销
op.dag(state)
---
其他门¶
Rot_Bool(通用旋转)¶
- 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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Bit position to check (0-indexed).
conds -- List of (register, position) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int) to condition on.
conds -- List of register names or IDs for multi-condition.
- 返回:
Self, for method chaining.
示例
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
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.
- 参数:
cond -- Register name (str) or ID (int).
pos -- Value to match.
conds -- List of (register, value) pairs.
- 返回:
Self, for method chaining.
操作: 应用任意 2×2 幺正矩阵
import numpy as np
# 定义 2x2 矩阵
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)