Skip to main content

merged

Overloads

NameDescription
merged(const ComplexOperatorSum input) -> ComplexOperatorSumSimplifies an OperatorSum by combining like terms (out-of-place).
merged(const RealOperatorSum input) -> RealOperatorSumSimplifies an OperatorSum by combining like terms (out-of-place).

merged(const ComplexOperatorSum input) -> ComplexOperatorSum

Simplifies an OperatorSum by combining like terms (out-of-place).

This function merges coefficients of identical operators in the sum. For example, terms like 2.0*X(0) and 3.0*X(0) are combined into 5.0*X(0). Near-zero coefficient terms are also removed, returning an empty operator (), during the process.

Parameters

  • input: The input OperatorSum to be simplified.

Returns

A new OperatorSum with like terms combined or an empty Operator when near-zero coefficient terms removed.

Example

var my_sum = 2.0*X(0) + Y(1) + 3.0*X(0);
var simplified = merged(my_sum); // Returns (5 * X(0) + 1 * Y(1))

merged(const RealOperatorSum input) -> RealOperatorSum

Simplifies an OperatorSum by combining like terms (out-of-place).

This function merges coefficients of identical operators in the sum. For example, terms like 2.0*X(0) and 3.0*X(0) are combined into 5.0*X(0). Near-zero coefficient terms are also removed, returning an empty operator (), during the process.

Parameters

  • input: The input OperatorSum to be simplified.

Returns

A new OperatorSum with like terms combined or an empty Operator when near-zero coefficient terms removed.

Example

var my_sum = 2.0*X(0) + Y(1) + 3.0*X(0);
var simplified = merged(my_sum); // Returns (5 * X(0) + 1 * Y(1))