Skip to main content

ComplexOperatorSum

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

Factories

operator_sum() -> ComplexOperatorSum

Creates an empty ComplexOperatorSum with complex coefficients (default behavior).

Returns

A new empty ComplexOperatorSum.

Example

var my_sum = operator_sum()  # Creates empty ComplexOperatorSum (default)

operator_sum(const Operator op) -> ComplexOperatorSum

Creates a ComplexOperatorSum from a generic Operator (default behavior).

Parameters

  • op: The operator to include in the sum.

Returns

A new ComplexOperatorSum containing the operator with coefficient (1.0, 0.0).

Example

var my_sum = operator_sum(X(0))  # Creates ComplexOperatorSum from single operator

operator_sum(as_complex type_tag) -> ComplexOperatorSum

Creates an empty ComplexOperatorSum with complex coefficients.

Parameters

  • type_tag: A global constant tagging the object type.

Returns

A new empty ComplexOperatorSum.

Example

var my_sum = operator_sum(as_complex)  # Creates empty ComplexOperatorSum

operator_sum(const Model model) -> ComplexOperatorSum

Converts a Model into a ComplexOperatorSum.

Parameters

operator_sum(const Operator op, as_complex type_tag) -> ComplexOperatorSum

Creates a ComplexOperatorSum from an operator with complex coefficients.

Parameters

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

Returns

A new ComplexOperatorSum containing the operator with coefficient (1.0, 0.0).

Example

var my_sum = operator_sum(X(0), as_complex)  # Creates ComplexOperatorSum

operator_sum(const Model model, as_complex type) -> ComplexOperatorSum

Converts a Model into a ComplexOperatorSum.

Parameters

Symbols

NameDescription
+=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.
=Assigns an Operator expression to this ComplexOperatorSum, replacing any existing content.
[]Returns the coefficient and term of the sum at the index position.

Members

NameDescription
get_coefficientsReturns the coefficients of the ComplexOperatorSum.