LinOpFactory Class Reference#
|
Reference API
|
#include <ginkgo/core/base/lin_op.hpp>
Public Member Functions | |
| std::unique_ptr< LinOp > | generate (std::shared_ptr< const LinOp > input) const |
Public Member Functions inherited from gko::EnableAbstractPolymorphicObject< AbstractObject, PolymorphicBase > | |
| std::unique_ptr< AbstractObject > | create_default (std::shared_ptr< const Executor > exec) const |
| std::unique_ptr< AbstractObject > | create_default () const |
| std::unique_ptr< AbstractObject > | clone (std::shared_ptr< const Executor > exec) const |
| std::unique_ptr< AbstractObject > | clone () const |
| AbstractObject * | copy_from (const PolymorphicObject *other) |
| template<typename Derived > | |
| std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * | copy_from (std::unique_ptr< Derived > &&other) |
| template<typename Derived > | |
| std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, AbstractObject > * | copy_from (const std::unique_ptr< Derived > &other) |
| AbstractObject * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
| AbstractObject * | move_from (ptr_param< PolymorphicObject > other) |
| AbstractObject * | clear () |
Public Member Functions inherited from gko::PolymorphicObject | |
| PolymorphicObject & | operator= (const PolymorphicObject &) |
| std::unique_ptr< PolymorphicObject > | create_default (std::shared_ptr< const Executor > exec) const |
| std::unique_ptr< PolymorphicObject > | create_default () const |
| std::unique_ptr< PolymorphicObject > | clone (std::shared_ptr< const Executor > exec) const |
| std::unique_ptr< PolymorphicObject > | clone () const |
| PolymorphicObject * | copy_from (const PolymorphicObject *other) |
| template<typename Derived , typename Deleter > | |
| std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * | copy_from (std::unique_ptr< Derived, Deleter > &&other) |
| template<typename Derived , typename Deleter > | |
| std::enable_if_t< std::is_base_of< PolymorphicObject, std::decay_t< Derived > >::value, PolymorphicObject > * | copy_from (const std::unique_ptr< Derived, Deleter > &other) |
| PolymorphicObject * | copy_from (const std::shared_ptr< const PolymorphicObject > &other) |
| PolymorphicObject * | move_from (ptr_param< PolymorphicObject > other) |
| PolymorphicObject * | clear () |
| std::shared_ptr< const Executor > | get_executor () const noexcept |
Public Member Functions inherited from gko::log::EnableLogging< PolymorphicObject > | |
| void | add_logger (std::shared_ptr< const Logger > logger) override |
| void | remove_logger (const Logger *logger) override |
| void | remove_logger (ptr_param< const Logger > logger) |
| const std::vector< std::shared_ptr< const Logger > > & | get_loggers () const override |
| void | clear_loggers () override |
Public Member Functions inherited from gko::log::Loggable | |
| void | remove_logger (ptr_param< const Logger > logger) |
Additional Inherited Members | |
Protected Member Functions inherited from gko::PolymorphicObject | |
| PolymorphicObject (std::shared_ptr< const Executor > exec) | |
| PolymorphicObject (const PolymorphicObject &other) | |
| virtual std::unique_ptr< PolymorphicObject > | create_default_impl (std::shared_ptr< const Executor > exec) const =0 |
| virtual PolymorphicObject * | copy_from_impl (const PolymorphicObject *other)=0 |
| virtual PolymorphicObject * | copy_from_impl (std::unique_ptr< PolymorphicObject > other)=0 |
| virtual PolymorphicObject * | move_from_impl (PolymorphicObject *other)=0 |
| virtual PolymorphicObject * | move_from_impl (std::unique_ptr< PolymorphicObject > other)=0 |
| virtual PolymorphicObject * | clear_impl ()=0 |
Protected Member Functions inherited from gko::log::EnableLogging< PolymorphicObject > | |
| void | log (Params &&... params) const |
Protected Attributes inherited from gko::log::EnableLogging< PolymorphicObject > | |
| std::vector< std::shared_ptr< const Logger > > | loggers_ |
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 \(Ax = b\), the solution \(x = A^{-1}b\) 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 \(A\), returns a new linear operator \(A^{-1}\) stored in "CG format"
- Storing the operator \(A^{-1}\) in "CG format" means that the data structure used to store the operator is just a simple pointer to the original matrix \(A\). The application \(x = A^{-1}b\) of such an operator can then be implemented by solving the linear system \(Ax = b\) 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 \(A\) is a linear operator \(M^{-1}\), which approximates \(A^{-1}\). In addition, it is stored in a way such that both the data of \(M^{-1}\) is cheap to compute from \(A\), and the operation \(x = M^{-1}b\) 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 \(A\) into a preconditioner \(M^{-1}\) 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 \(x = M^{-1}b\) depending on the format the preconditioner is stored in (e.g. as two triangular solves in case of ILU)
Example: using CG in Ginkgo
The documentation for this class was generated from the following file:
- ginkgo/core/base/lin_op.hpp
Generated by
Public Member Functions inherited from