+=
Symbol of ComplexOperatorSum.
(ComplexOperatorSum lhs += const Operator rhs) -> void
Adds an Operator to the sum. Operators without explicit coefficients default to 1.0+0.0i.Important: Coefficients are NOT automatically combined - each term is kept separate. Use the merged() function if you want to combine like terms.
Parameters
- lhs: Left-hand side value.
- rhs: The Operator to add to the sum.
Example
var sum = ComplexOperatorSum()
sum += X(0) // sum = (1+0i)*X(0)
sum += Y(1) // sum = (1+0i)*X(0) + (1+0i)*Y(1)
sum += (0.0 + 1.0i) * X(0) // sum = (1+0i)*X(0) + (1+0i)*Y(1) + (0+1i)*X(0) (NOT combined!)
sum += (2.0 + 0.5i) * Z(2) // sum = (1+0i)*X(0) + (1+0i)*Y(1) + (0+1i)*X(0) + (2+0.5i)*Z(2)
var combined = merged(sum) // Use merged() to get (1+1i)*X(0) + (1+0i)*Y(1) + (2+0.5i)*Z(2)