gko::EnableLinOp#

CRTP mixin that supplies the boilerplate every concrete LinOp needs: the apply dispatcher (which calls into the derived class’s apply_impl), the default clone / copy_from plumbing, the polymorphic-object machinery, and the logging hooks. Concrete operators (every solver, preconditioner, and matrix in Ginkgo) derive from EnableLinOp<MyOperator> rather than from LinOp directly — the mixin’s CRTP cast lets these defaults work on the derived type without virtual-dispatch overhead.

template<typename ConcreteLinOp, typename PolymorphicBase = LinOp>
class EnableLinOp #

Inherits from

The EnableLinOp mixin can be used to provide sensible default implementations of the majority of the LinOp and PolymorphicObject interface.

The goal of the mixin is to facilitate the development of new LinOp, by enabling the implementers to focus on the important parts of their operator, while the library takes care of generating the trivial utility functions. The mixin will provide default implementations for the entire PolymorphicObject interface, including a default implementation of copy_from between objects of the new LinOp type. It will also hide the default LinOp::apply() methods with versions that preserve the static type of the object.

Implementers of new LinOps are required to specify only the following aspects:

  1. Creation of the LinOp: This can be facilitated via either EnableCreateMethod mixin (used mostly for matrix formats), or GKO_ENABLE_LIN_OP_FACTORY macro (used for operators created from other operators, like preconditioners and solvers).

  2. Application of the LinOp: Implementers have to override the two overloads of the LinOp::apply_impl() virtual methods.

Note

This mixin can’t be used with concrete types that derive from experimental::distributed::DistributedBase. In that case use experimental::EnableDistributedLinOp instead.

Template Parameters:
  • ConcreteLinOp – the concrete LinOp which is being implemented [CRTP parameter]

  • PolymorphicBase – parent of ConcreteLinOp in the polymorphic hierarchy, has to be a subclass of LinOp

Subclassed by