Ginkgo: gko::LinOpFactory Class Reference

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
gko::LinOpFactory Class Reference
Linear Operators

A LinOpFactory represents a higher order mapping which transforms one linear operator into another. More...

`#include <ginkgo/core/base/lin_op.hpp>`

Inheritance diagram for gko::LinOpFactory:
[legend]
Collaboration diagram for gko::LinOpFactory:
[legend]

## Public Member Functions
std::unique_ptr< LinOp > | generate (std::shared_ptr< const LinOp > input) const

## Detailed Description

A LinOpFactory represents a higher order mapping which transforms one linear operator into another.

In Ginkgo, every linear solver is viewed as a mapping. For example, given an s.p.d linear system , the solution can be computed using the CG method. This algorithm can be represented in terms of linear operators and mappings between them as follows:

- A Cg::Factory is a higher order mapping which, given an input operator , returns a new linear operator stored in "CG format"
- Storing the operator in "CG format" means that the data structure used to store the operator is just a simple pointer to the original matrix . The application of such an operator can then be implemented by solving the linear system using the CG method. This is achieved in code by having a special class for each of those "formats" (e.g. the "Cg" class defines such a format for the CG solver).

Another example of a LinOpFactory is a preconditioner. A preconditioner for a linear operator is a linear operator , which approximates . In addition, it is stored in a way such that both the data of is cheap to compute from , and the operation can be computed quickly. These operators are useful to accelerate the convergence of Krylov solvers. Thus, a preconditioner also fits into the LinOpFactory framework:

- The factory maps a linear operator into a preconditioner which is stored in suitable format (e.g. as a product of two factors in case of ILU preconditioners).
- The resulting linear operator implements the application operation depending on the format the preconditioner is stored in (e.g. as two triangular solves in case of ILU)

## Example: using CG in Ginkgo

// Suppose A is a matrix, b a rhs vector, and x an initial guess
// Create a CG which runs for at most 1000 iterations, and stops after
// reducing the residual norm by 6 orders of magnitude
auto cg_factory = solver::Cg<>::build()
.with_max_iters(1000)
.with_rel_residual_goal(1e-6)
.on(cuda);
// create a linear operator which represents the solver
auto cg = cg_factory->generate(A);
// solve the system
cg->apply(b, x);

The documentation for this class was generated from the following file:

- ginkgo/core/base/lin_op.hpp