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

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 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

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

Converts a Model into a RealOperatorSum.

Parameters

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.
=Assigns an Operator to this RealOperatorSum, replacing any existing content. This clears the current sum and assigns the new operator(s).
[]Returns the coefficient and term of the sum at the index position.

Members

NameDescription
get_coefficientsReturns the coefficients of the RealOperatorSum.