gko::Combination#

Linear combination of LinOps. Given \(k\) operators \(\mathit{op}_1, \ldots, \mathit{op}_k\) and \(k\) scalar coefficients \(c_1, \ldots, c_k\) (each a \(1 \times 1\) Dense), Combination represents

\[ \mathit{Combination}(x) = c_1\, \mathit{op}_1\, x + c_2\, \mathit{op}_2\, x + \cdots + c_k\, \mathit{op}_k\, x, \]

and is itself a LinOp. apply runs each constituent and accumulates the scaled results into the output. The constructor moves all operators onto the executor of the first one if their executors differ, so the combined operator runs on a single executor.

Common use cases: assembling \(A - \lambda I\) as Combination{1.0, A, -lambda, I} for shifted-system solves, building residual operators of the form b - A x as a single LinOp that a logger or downstream tool can consume, and stacking multiple corrections in iterative refinement pipelines.

template<typename ValueType = default_precision>
class Combination #

Inherits from

The Combination class can be used to construct a linear combination of multiple linear operators c1 * op1 + c2 * op2 + ... + ck * opk.

Combination ensures that all LinOps passed to its constructor use the same executor, and if not, copies the operators to the executor of the first operator.

Template Parameters:

ValueType – precision of input and result vectors

Public Functions

inline const std::vector<std::shared_ptr<const LinOp>> &get_coefficients(
) const noexcept#

Returns a list of coefficients of the combination.

Returns:

a list of coefficients

inline const std::vector<std::shared_ptr<const LinOp>> &get_operators(
) const noexcept#

Returns a list of operators of the combination.

Returns:

a list of operators

virtual std::unique_ptr<LinOp> transpose() const override#

Returns a LinOp representing the transpose of the Transposable object.

Returns:

a pointer to the new transposed object

virtual std::unique_ptr<LinOp> conj_transpose() const override#

Returns a LinOp representing the conjugate transpose of the Transposable object.

Returns:

a pointer to the new conjugate transposed object

Combination &operator=(const Combination&)#

Copy-assigns a Combination. The executor is not modified, and the wrapped LinOps are only being cloned if they are on a different executor.

Combination &operator=(Combination&&)#

Move-assigns a Combination. The executor is not modified, and the wrapped LinOps are only being cloned if they are on a different executor, otherwise they share ownership. The moved-from object is empty (0x0 LinOp without operators) afterwards.

Combination(const Combination&)#

Copy-constructs a Combination. This inherits the executor of the input Combination and all of its operators with shared ownership.

Combination(Combination&&)#

Move-constructs a Combination. This inherits the executor of the input Combination and all of its operators. The moved-from object is empty (0x0 LinOp without operators) afterwards.