BlockEncoding.__neg__#
- BlockEncoding.__neg__() BlockEncoding[source]#
Returns a BlockEncoding of the negated operator.
This method implements the transformation \(A \to -A\) by scaling the encoded operator by \(-1\).
- Returns:
- BlockEncoding
A new BlockEncoding instance representing the operator \(-A\).
Examples
Define a block-encoding and negate it.
from qrisp import * from qrisp.block_encodings import BlockEncoding from qrisp.operators import X, Y, Z H1 = X(0)*X(1) - 0.2*Y(0)*Y(1) H2 = 0.2*Y(0)*Y(1) - X(0)*X(1) BE1 = BlockEncoding.from_operator(H1) BE2 = BlockEncoding.from_operator(H2) BE3 = -BE1 def operand_prep(): qv = QuantumFloat(3) return qv @terminal_sampling def main(BE): qv = BE.apply_rus(operand_prep)() return qv res_be2 = main(BE2) res_be_neg = main(BE3) print("Result from BE of H2 = - H1: ", res_be2) print("Result from - BE1: ", res_be_neg) # Result from BE of H2 = - H1: {3.0: 1.0} # Result from - BE1: {3.0: 1.0}