Utilities

These helpers support the symbolic linear-combination representation used by Point and Expression. Most users interact with them indirectly through overloaded arithmetic.

PEPit.merge_dictsFunction
merge_dicts(dict1::OrderedDict, dict2::OrderedDict)

Merge two coefficient dictionaries by adding coefficients with matching keys.

This helper is used when symbolic points, functions, and expressions are added together. The keys encode symbolic atoms and the values encode their scalar coefficients.

Arguments

  • dict1: first coefficient dictionary.
  • dict2: second coefficient dictionary.

Returns

An OrderedDict containing the union of both key sets, with coefficients added for keys that appear in both inputs.

PEPit.multiply_dictsFunction
multiply_dicts(dict1::OrderedDict, dict2::OrderedDict)

Develop the product of two symbolic linear combinations.

If dict1 represents \sum_i a_i p_i and dict2 represents \sum_j b_j q_j, then the returned dictionary represents the bilinear expansion with keys (p_i, q_j) and coefficients a_i b_j. This is the dictionary-level operation behind inner products of symbolic Point objects.

Arguments

  • dict1: first coefficient dictionary.
  • dict2: second coefficient dictionary.

Returns

An OrderedDict{Any,Float64} whose keys are ordered pairs of input keys and whose values are products of the corresponding coefficients, added when the same pair appears more than once.

PEPit.prune_dictFunction
prune_dict(d::OrderedDict)

Remove all zero coefficients from a symbolic decomposition dictionary.

The symbolic algebra stores many affine and linear combinations as dictionaries. After additions or scalar multiplications, exact zero coefficients can appear and should be removed so that equality checks on decompositions remain stable.

Arguments

  • d: coefficient dictionary to prune.

Returns

A new OrderedDict with all entries whose value is exactly zero removed.

PEPit.get_blockFunction
get_block(bp::BlockPartition, point::Point, block_number::Int)

Return the block_number-th symbolic block of point, creating the block decomposition and its orthogonality constraints if needed.

The first d - 1 blocks are new leaf points; the final block is defined as the residual required to make the block sum equal to point. Orthogonality constraints are registered by add_partition_constraints! during model construction.

PEPit.get_nb_blocksFunction
get_nb_blocks(bp::BlockPartition)

Return the number of blocks in a block partition.

PEPit.get_is_leafFunction
get_is_leaf(obj)

Return whether obj is a leaf symbolic object with its own SDP variable index.

For points, leaf objects are the independent vectors that generate the Gram matrix. For expressions, leaf objects are independent scalar function values. Non-leaf objects are affine or linear combinations of existing leaves.