Useful functions
Currently, there are two useful methods for querying and manipulating expressions, namely collect_operators
and replace
. In following are examples for each.
from qadence2_expressions import *
collected_ops = collect_operators(Z(1) + 2 * Z(1) * Z (2) - X(3))
{QuantumOperator(Symbol('Z'), [1], is_hermitian=True, is_unitary=True): Value(1.0), KroneckerProduct(QuantumOperator(Symbol('Z'), [1], is_hermitian=True, is_unitary=True), QuantumOperator(Symbol('Z'), [2], is_hermitian=True, is_unitary=True)): Value(2.0), QuantumOperator(Symbol('X'), [3], is_hermitian=True, is_unitary=True): Value(-1.0)}