Skip to main content

RealOperatorSum

Represents a sum of operators with real scalar coefficients. Each term consists of a real coefficient and an operator. Create instances using the operator_sum() factory function.

Factories

SX(integer site) -> RealOperatorSum

Returns \fSx=12X\fS_x = \frac{1}{2}X\f as a scaled operator sum.

Parameters

  • site: The site index where the operator acts (exactly 1 site required).

Example

var sx0 = SX(0)

SY(integer site) -> RealOperatorSum

Returns \fSy=12Y\fS_y = \frac{1}{2}Y\f as a scaled operator sum.

Parameters

  • site: The site index where the operator acts (exactly 1 site required).

Example

var sy1 = SY(1)

SZ(integer site) -> RealOperatorSum

Returns \fSz=12Z\fS_z = \frac{1}{2}Z\f as a scaled operator sum.

Parameters

  • site: The site index where the operator acts (exactly 1 site required).

Example

var sz2 = SZ(2)

operator_sum(as_real type_tag) -> RealOperatorSum

Creates an empty RealOperatorSum with real coefficients.

Parameters

  • type_tag: A global constant tagging the object type.

Returns

A new empty RealOperatorSum.

Example

var my_sum = operator_sum(as_real)  # Creates empty RealOperatorSum

operator_sum(const Model model, as_real type) -> RealOperatorSum

Converts a Model into a RealOperatorSum.

Parameters

operator_sum(const Operator op, as_real type_tag) -> RealOperatorSum

Creates a RealOperatorSum from an operator with real coefficients.

Parameters

  • op: The operator to include in the sum.
  • type_tag: A global constant tagging the object type.

Returns

A new RealOperatorSum containing the operator with coefficient 1.0.

Example

var my_sum = operator_sum(X(0), as_real)  # Creates RealOperatorSum

Symbols

NameDescription
+=Adds an Operator to the sum. Operators without explicit coefficients default to 1.0. Important: Coefficients are NOT automatically combined - each term is kept separate. Use the merged() function if you want to combine like terms.
[]Returns the coefficient and term of the sum at the index position.

Members

NameDescription
get_coefficientsReturns the coefficients of the RealOperatorSum.