Ginkgo  Generated from pipelines/1868155508 branch based on main. Ginkgo version 1.10.0
A numerical linear algebra library targeting many-core architectures
solver_base.hpp
1 // SPDX-FileCopyrightText: 2017 - 2025 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_SOLVER_SOLVER_BASE_HPP_
6 #define GKO_PUBLIC_CORE_SOLVER_SOLVER_BASE_HPP_
7 
8 
9 #include <memory>
10 #include <type_traits>
11 #include <utility>
12 
13 #include <ginkgo/core/base/lin_op.hpp>
14 #include <ginkgo/core/base/math.hpp>
15 #include <ginkgo/core/log/logger.hpp>
16 #include <ginkgo/core/matrix/dense.hpp>
17 #include <ginkgo/core/matrix/identity.hpp>
18 #include <ginkgo/core/solver/workspace.hpp>
19 #include <ginkgo/core/stop/combined.hpp>
20 #include <ginkgo/core/stop/criterion.hpp>
21 
22 
23 GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS
24 
25 
26 namespace gko {
27 namespace solver {
28 
29 
33 enum class initial_guess_mode {
37  zero,
41  rhs,
45  provided
46 };
47 
48 
49 namespace multigrid {
50 namespace detail {
51 
52 
53 class MultigridState;
54 
55 
56 } // namespace detail
57 } // namespace multigrid
58 
59 
66 protected:
67  friend class multigrid::detail::MultigridState;
68 
82  virtual void apply_with_initial_guess(const LinOp* b, LinOp* x,
83  initial_guess_mode guess) const = 0;
84 
85  void apply_with_initial_guess(ptr_param<const LinOp> b, ptr_param<LinOp> x,
86  initial_guess_mode guess) const
87  {
88  apply_with_initial_guess(b.get(), x.get(), guess);
89  }
90 
103  virtual void apply_with_initial_guess(const LinOp* alpha, const LinOp* b,
104  const LinOp* beta, LinOp* x,
105  initial_guess_mode guess) const = 0;
106 
107 
108  void apply_with_initial_guess(ptr_param<const LinOp> alpha,
112  initial_guess_mode guess) const
113  {
114  apply_with_initial_guess(alpha.get(), b.get(), beta.get(), x.get(),
115  guess);
116  }
117 
123  initial_guess_mode get_default_initial_guess() const { return guess_; }
124 
131  explicit ApplyWithInitialGuess(
133  : guess_(guess)
134  {}
135 
141  void set_default_initial_guess(initial_guess_mode guess) { guess_ = guess; }
142 
143 private:
144  initial_guess_mode guess_;
145 };
146 
147 
160 template <typename DerivedType>
162 protected:
163  friend class multigrid::detail::MultigridState;
164 
167  : ApplyWithInitialGuess(guess)
168  {}
169 
174  void apply_with_initial_guess(const LinOp* b, LinOp* x,
175  initial_guess_mode guess) const override
176  {
177  self()->template log<log::Logger::linop_apply_started>(self(), b, x);
178  auto exec = self()->get_executor();
179  GKO_ASSERT_CONFORMANT(self(), b);
180  GKO_ASSERT_EQUAL_ROWS(self(), x);
181  GKO_ASSERT_EQUAL_COLS(b, x);
182  this->apply_with_initial_guess_impl(make_temporary_clone(exec, b).get(),
183  make_temporary_clone(exec, x).get(),
184  guess);
185  self()->template log<log::Logger::linop_apply_completed>(self(), b, x);
186  }
187 
192  void apply_with_initial_guess(const LinOp* alpha, const LinOp* b,
193  const LinOp* beta, LinOp* x,
194  initial_guess_mode guess) const override
195  {
196  self()->template log<log::Logger::linop_advanced_apply_started>(
197  self(), alpha, b, beta, x);
198  auto exec = self()->get_executor();
199  GKO_ASSERT_CONFORMANT(self(), b);
200  GKO_ASSERT_EQUAL_ROWS(self(), x);
201  GKO_ASSERT_EQUAL_COLS(b, x);
202  GKO_ASSERT_EQUAL_DIMENSIONS(alpha, dim<2>(1, 1));
203  GKO_ASSERT_EQUAL_DIMENSIONS(beta, dim<2>(1, 1));
204  this->apply_with_initial_guess_impl(
205  make_temporary_clone(exec, alpha).get(),
206  make_temporary_clone(exec, b).get(),
207  make_temporary_clone(exec, beta).get(),
208  make_temporary_clone(exec, x).get(), guess);
209  self()->template log<log::Logger::linop_advanced_apply_completed>(
210  self(), alpha, b, beta, x);
211  }
212 
213  // TODO: should we provide the default implementation?
218  virtual void apply_with_initial_guess_impl(
219  const LinOp* b, LinOp* x, initial_guess_mode guess) const = 0;
220 
225  virtual void apply_with_initial_guess_impl(
226  const LinOp* alpha, const LinOp* b, const LinOp* beta, LinOp* x,
227  initial_guess_mode guess) const = 0;
228 
229  GKO_ENABLE_SELF(DerivedType);
230 };
231 
232 
237 template <typename Solver>
239  // number of vectors used by this workspace
240  static int num_vectors(const Solver&) { return 0; }
241  // number of arrays used by this workspace
242  static int num_arrays(const Solver&) { return 0; }
243  // array containing the num_vectors names for the workspace vectors
244  static std::vector<std::string> op_names(const Solver&) { return {}; }
245  // array containing the num_arrays names for the workspace vectors
246  static std::vector<std::string> array_names(const Solver&) { return {}; }
247  // array containing all scalar vectors (independent of problem size)
248  static std::vector<int> scalars(const Solver&) { return {}; }
249  // array containing all vectors (dependent on problem size)
250  static std::vector<int> vectors(const Solver&) { return {}; }
251 };
252 
253 
269 template <typename DerivedType>
271 public:
278  void set_preconditioner(std::shared_ptr<const LinOp> new_precond) override
279  {
280  auto exec = self()->get_executor();
281  if (new_precond) {
282  GKO_ASSERT_EQUAL_DIMENSIONS(self(), new_precond);
283  GKO_ASSERT_IS_SQUARE_MATRIX(new_precond);
284  if (new_precond->get_executor() != exec) {
285  new_precond = gko::clone(exec, new_precond);
286  }
287  }
289  }
290 
296  {
297  if (&other != this) {
299  }
300  return *this;
301  }
302 
309  {
310  if (&other != this) {
311  set_preconditioner(other.get_preconditioner());
312  other.set_preconditioner(nullptr);
313  }
314  return *this;
315  }
316 
317  EnablePreconditionable() = default;
318 
319  EnablePreconditionable(std::shared_ptr<const LinOp> preconditioner)
320  {
321  set_preconditioner(std::move(preconditioner));
322  }
323 
328  {
329  *this = other;
330  }
331 
337  {
338  *this = std::move(other);
339  }
340 
341 private:
342  DerivedType* self() { return static_cast<DerivedType*>(this); }
343 
344  const DerivedType* self() const
345  {
346  return static_cast<const DerivedType*>(this);
347  }
348 };
349 
350 
351 namespace detail {
352 
353 
362 class SolverBaseLinOp {
363 public:
364  SolverBaseLinOp(std::shared_ptr<const Executor> exec)
365  : workspace_{std::move(exec)}
366  {}
367 
368  virtual ~SolverBaseLinOp() = default;
369 
375  std::shared_ptr<const LinOp> get_system_matrix() const
376  {
377  return system_matrix_;
378  }
379 
380  const LinOp* get_workspace_op(int vector_id) const
381  {
382  return workspace_.get_op(vector_id);
383  }
384 
385  virtual int get_num_workspace_ops() const { return 0; }
386 
387  virtual std::vector<std::string> get_workspace_op_names() const
388  {
389  return {};
390  }
391 
396  virtual std::vector<int> get_workspace_scalars() const { return {}; }
397 
402  virtual std::vector<int> get_workspace_vectors() const { return {}; }
403 
404 protected:
405  void set_system_matrix_base(std::shared_ptr<const LinOp> system_matrix)
406  {
407  system_matrix_ = std::move(system_matrix);
408  }
409 
410  void set_workspace_size(int num_operators, int num_arrays) const
411  {
412  workspace_.set_size(num_operators, num_arrays);
413  }
414 
415  template <typename LinOpType>
416  LinOpType* create_workspace_op(int vector_id, gko::dim<2> size) const
417  {
418  return workspace_.template create_or_get_op<LinOpType>(
419  vector_id,
420  [&] {
421  return LinOpType::create(this->workspace_.get_executor(), size);
422  },
423  typeid(LinOpType), size, size[1]);
424  }
425 
426  template <typename LinOpType>
427  LinOpType* create_workspace_op_with_config_of(int vector_id,
428  const LinOpType* vec) const
429  {
430  return workspace_.template create_or_get_op<LinOpType>(
431  vector_id, [&] { return LinOpType::create_with_config_of(vec); },
432  typeid(*vec), vec->get_size(), vec->get_stride());
433  }
434 
435  template <typename LinOpType>
436  LinOpType* create_workspace_op_with_type_of(int vector_id,
437  const LinOpType* vec,
438  dim<2> size) const
439  {
440  return workspace_.template create_or_get_op<LinOpType>(
441  vector_id,
442  [&] {
443  return LinOpType::create_with_type_of(
444  vec, workspace_.get_executor(), size, size[1]);
445  },
446  typeid(*vec), size, size[1]);
447  }
448 
449  template <typename LinOpType>
450  LinOpType* create_workspace_op_with_type_of(int vector_id,
451  const LinOpType* vec,
452  dim<2> global_size,
453  dim<2> local_size) const
454  {
455  return workspace_.template create_or_get_op<LinOpType>(
456  vector_id,
457  [&] {
458  return LinOpType::create_with_type_of(
459  vec, workspace_.get_executor(), global_size, local_size,
460  local_size[1]);
461  },
462  typeid(*vec), global_size, local_size[1]);
463  }
464 
465  template <typename ValueType>
466  matrix::Dense<ValueType>* create_workspace_scalar(int vector_id,
467  size_type size) const
468  {
469  return workspace_.template create_or_get_op<matrix::Dense<ValueType>>(
470  vector_id,
471  [&] {
473  workspace_.get_executor(), dim<2>{1, size});
474  },
475  typeid(matrix::Dense<ValueType>), gko::dim<2>{1, size}, size);
476  }
477 
478  template <typename ValueType>
479  const matrix::Dense<ValueType>* create_workspace_fixed_scalar(
480  int vector_id, size_type size, ValueType val) const
481  {
482  return workspace_.template create_or_get_op<matrix::Dense<ValueType>>(
483  vector_id,
484  [&] {
486  workspace_.get_executor(), dim<2>{1, size});
487  mat->fill(val);
488  return mat;
489  },
490  typeid(matrix::Dense<ValueType>), gko::dim<2>{1, size}, size);
491  }
492 
493  template <typename ValueType>
494  array<ValueType>& create_workspace_array(int array_id, size_type size) const
495  {
496  return workspace_.template create_or_get_array<ValueType>(array_id,
497  size);
498  }
499 
500  template <typename ValueType>
501  array<ValueType>& create_workspace_array(int array_id) const
502  {
503  return workspace_.template init_or_get_array<ValueType>(array_id);
504  }
505 
506 private:
507  mutable detail::workspace workspace_;
508 
509  std::shared_ptr<const LinOp> system_matrix_;
510 };
511 
512 
513 } // namespace detail
514 
515 
516 template <typename MatrixType>
517 class
518  // clang-format off
519  GKO_DEPRECATED("This class will be replaced by the template-less detail::SolverBaseLinOp in a future release") SolverBase
520  // clang-format on
521  : public detail::SolverBaseLinOp {
522 public:
523  using detail::SolverBaseLinOp::SolverBaseLinOp;
524 
532  std::shared_ptr<const MatrixType> get_system_matrix() const
533  {
534  return std::dynamic_pointer_cast<const MatrixType>(
535  SolverBaseLinOp::get_system_matrix());
536  }
537 
538 protected:
539  void set_system_matrix_base(std::shared_ptr<const MatrixType> system_matrix)
540  {
541  SolverBaseLinOp::set_system_matrix_base(std::move(system_matrix));
542  }
543 };
544 
545 
555 template <typename DerivedType, typename MatrixType = LinOp>
556 class EnableSolverBase : public SolverBase<MatrixType> {
557 public:
563  {
564  if (&other != this) {
565  set_system_matrix(other.get_system_matrix());
566  }
567  return *this;
568  }
569 
575  {
576  if (&other != this) {
577  set_system_matrix(other.get_system_matrix());
578  other.set_system_matrix(nullptr);
579  }
580  return *this;
581  }
582 
583  EnableSolverBase() : SolverBase<MatrixType>{self()->get_executor()} {}
584 
585  EnableSolverBase(std::shared_ptr<const MatrixType> system_matrix)
586  : SolverBase<MatrixType>{self()->get_executor()}
587  {
588  set_system_matrix(std::move(system_matrix));
589  }
590 
595  : SolverBase<MatrixType>{other.self()->get_executor()}
596  {
597  *this = other;
598  }
599 
605  : SolverBase<MatrixType>{other.self()->get_executor()}
606  {
607  *this = std::move(other);
608  }
609 
610  int get_num_workspace_ops() const override
611  {
612  using traits = workspace_traits<DerivedType>;
613  return traits::num_vectors(*self());
614  }
615 
616  std::vector<std::string> get_workspace_op_names() const override
617  {
618  using traits = workspace_traits<DerivedType>;
619  return traits::op_names(*self());
620  }
621 
626  std::vector<int> get_workspace_scalars() const override
627  {
628  using traits = workspace_traits<DerivedType>;
629  return traits::scalars(*self());
630  }
631 
636  std::vector<int> get_workspace_vectors() const override
637  {
638  using traits = workspace_traits<DerivedType>;
639  return traits::vectors(*self());
640  }
641 
642 protected:
643  void set_system_matrix(std::shared_ptr<const MatrixType> new_system_matrix)
644  {
645  auto exec = self()->get_executor();
646  if (new_system_matrix) {
647  GKO_ASSERT_EQUAL_DIMENSIONS(self(), new_system_matrix);
648  GKO_ASSERT_IS_SQUARE_MATRIX(new_system_matrix);
649  if (new_system_matrix->get_executor() != exec) {
650  new_system_matrix = gko::clone(exec, new_system_matrix);
651  }
652  }
653  this->set_system_matrix_base(new_system_matrix);
654  }
655 
656  void setup_workspace() const
657  {
658  using traits = workspace_traits<DerivedType>;
659  this->set_workspace_size(traits::num_vectors(*self()),
660  traits::num_arrays(*self()));
661  }
662 
663 private:
664  DerivedType* self() { return static_cast<DerivedType*>(this); }
665 
666  const DerivedType* self() const
667  {
668  return static_cast<const DerivedType*>(this);
669  }
670 };
671 
672 
680 public:
686  std::shared_ptr<const stop::CriterionFactory> get_stop_criterion_factory()
687  const
688  {
689  return stop_factory_;
690  }
691 
698  std::shared_ptr<const stop::CriterionFactory> new_stop_factory)
699  {
700  stop_factory_ = new_stop_factory;
701  }
702 
703 private:
704  std::shared_ptr<const stop::CriterionFactory> stop_factory_;
705 };
706 
707 
717 template <typename DerivedType>
719 public:
725  {
726  if (&other != this) {
728  }
729  return *this;
730  }
731 
738  {
739  if (&other != this) {
740  set_stop_criterion_factory(other.get_stop_criterion_factory());
741  other.set_stop_criterion_factory(nullptr);
742  }
743  return *this;
744  }
745 
746  EnableIterativeBase() = default;
747 
749  std::shared_ptr<const stop::CriterionFactory> stop_factory)
750  {
751  set_stop_criterion_factory(std::move(stop_factory));
752  }
753 
757  EnableIterativeBase(const EnableIterativeBase& other) { *this = other; }
758 
764  {
765  *this = std::move(other);
766  }
767 
769  std::shared_ptr<const stop::CriterionFactory> new_stop_factory) override
770  {
771  auto exec = self()->get_executor();
772  if (new_stop_factory && new_stop_factory->get_executor() != exec) {
773  new_stop_factory = gko::clone(exec, new_stop_factory);
774  }
776  }
777 
778 private:
779  DerivedType* self() { return static_cast<DerivedType*>(this); }
780 
781  const DerivedType* self() const
782  {
783  return static_cast<const DerivedType*>(this);
784  }
785 };
786 
787 
798 template <typename ValueType, typename DerivedType>
800  : public EnableSolverBase<DerivedType>,
801  public EnableIterativeBase<DerivedType>,
802  public EnablePreconditionable<DerivedType> {
803 public:
805 
807  std::shared_ptr<const LinOp> system_matrix,
808  std::shared_ptr<const stop::CriterionFactory> stop_factory,
809  std::shared_ptr<const LinOp> preconditioner)
810  : EnableSolverBase<DerivedType>(std::move(system_matrix)),
811  EnableIterativeBase<DerivedType>{std::move(stop_factory)},
812  EnablePreconditionable<DerivedType>{std::move(preconditioner)}
813  {}
814 
815  template <typename FactoryParameters>
817  std::shared_ptr<const LinOp> system_matrix,
818  const FactoryParameters& params)
820  system_matrix, stop::combine(params.criteria),
821  generate_preconditioner(system_matrix, params)}
822  {}
823 
824 private:
825  template <typename FactoryParameters>
826  static std::shared_ptr<const LinOp> generate_preconditioner(
827  std::shared_ptr<const LinOp> system_matrix,
828  const FactoryParameters& params)
829  {
830  if (params.generated_preconditioner) {
831  return params.generated_preconditioner;
832  } else if (params.preconditioner) {
833  return params.preconditioner->generate(system_matrix);
834  } else {
836  system_matrix->get_executor(), system_matrix->get_size());
837  }
838  }
839 };
840 
841 
842 template <typename Parameters, typename Factory>
844  : enable_parameters_type<Parameters, Factory> {
848  std::vector<std::shared_ptr<const stop::CriterionFactory>>
849  GKO_DEFERRED_FACTORY_VECTOR_PARAMETER(criteria);
850 };
851 
852 
853 template <typename Parameters, typename Factory>
855  : enable_iterative_solver_factory_parameters<Parameters, Factory> {
860  std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
862 
867  std::shared_ptr<const LinOp> GKO_FACTORY_PARAMETER_SCALAR(
869 };
870 
871 
872 } // namespace solver
873 } // namespace gko
874 
875 
876 GKO_END_DISABLE_DEPRECATION_WARNINGS
877 
878 
879 #endif // GKO_PUBLIC_CORE_SOLVER_SOLVER_BASE_HPP_
gko::solver::EnableIterativeBase::EnableIterativeBase
EnableIterativeBase(const EnableIterativeBase &other)
Creates a shallow copy of the provided stopping criterion.
Definition: solver_base.hpp:757
gko::solver::EnableSolverBase::EnableSolverBase
EnableSolverBase(const EnableSolverBase &other)
Creates a shallow copy of the provided system matrix.
Definition: solver_base.hpp:594
gko::solver::EnableApplyWithInitialGuess
EnableApplyWithInitialGuess providing default operation for ApplyWithInitialGuess with correct valida...
Definition: solver_base.hpp:161
gko::log::profile_event_category::solver
Solver events.
gko::solver::EnableIterativeBase
A LinOp deriving from this CRTP class stores a stopping criterion factory and allows applying with a ...
Definition: solver_base.hpp:718
gko::solver::EnableSolverBase::operator=
EnableSolverBase & operator=(EnableSolverBase &&other)
Moves the provided system matrix, clones it onto this executor if executors don't match.
Definition: solver_base.hpp:574
gko::LinOp
Definition: lin_op.hpp:117
gko::solver::EnableSolverBase::get_workspace_vectors
std::vector< int > get_workspace_vectors() const override
Returns the IDs of all vectors (workspace vectors with system dimension-dependent size,...
Definition: solver_base.hpp:636
gko::Preconditionable
A LinOp implementing this interface can be preconditioned.
Definition: lin_op.hpp:682
gko::solver::enable_iterative_solver_factory_parameters
Definition: solver_base.hpp:843
gko::matrix::Dense::create
static std::unique_ptr< Dense > create(std::shared_ptr< const Executor > exec, const dim< 2 > &size={}, size_type stride=0)
Creates an uninitialized Dense matrix of the specified size.
gko::solver::EnablePreconditionable::operator=
EnablePreconditionable & operator=(const EnablePreconditionable &other)
Creates a shallow copy of the provided preconditioner, clones it onto this executor if executors don'...
Definition: solver_base.hpp:295
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:90
gko::ptr_param::get
T * get() const
Definition: utils_helper.hpp:75
gko::solver::enable_preconditioned_iterative_solver_factory_parameters
Definition: solver_base.hpp:854
gko::solver::initial_guess_mode::zero
the input is zero
gko::solver::EnablePreconditionable::EnablePreconditionable
EnablePreconditionable(const EnablePreconditionable &other)
Creates a shallow copy of the provided preconditioner.
Definition: solver_base.hpp:327
GKO_FACTORY_PARAMETER_SCALAR
#define GKO_FACTORY_PARAMETER_SCALAR(_name, _default)
Creates a scalar factory parameter in the factory parameters structure.
Definition: abstract_factory.hpp:445
gko::solver::enable_iterative_solver_factory_parameters::criteria
std::vector< std::shared_ptr< const stop::CriterionFactory > > criteria
Stopping criteria to be used by the solver.
Definition: solver_base.hpp:849
gko::solver::EnableSolverBase::get_workspace_scalars
std::vector< int > get_workspace_scalars() const override
Returns the IDs of all scalars (workspace vectors with system dimension-independent size,...
Definition: solver_base.hpp:626
gko::clone
detail::cloned_type< Pointer > clone(const Pointer &p)
Creates a unique clone of the object pointed to by p.
Definition: utils_helper.hpp:173
gko::Preconditionable::get_preconditioner
virtual std::shared_ptr< const LinOp > get_preconditioner() const
Returns the preconditioner operator used by the Preconditionable.
Definition: lin_op.hpp:691
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::solver::EnableIterativeBase::set_stop_criterion_factory
void set_stop_criterion_factory(std::shared_ptr< const stop::CriterionFactory > new_stop_factory) override
Sets the stopping criterion of the solver.
Definition: solver_base.hpp:768
gko::solver::EnablePreconditionable
Mixin providing default operation for Preconditionable with correct value semantics.
Definition: solver_base.hpp:270
gko::solver::EnableSolverBase::operator=
EnableSolverBase & operator=(const EnableSolverBase &other)
Creates a shallow copy of the provided system matrix, clones it onto this executor if executors don't...
Definition: solver_base.hpp:562
gko::dim< 2 >
gko::solver::EnableIterativeBase::operator=
EnableIterativeBase & operator=(EnableIterativeBase &&other)
Moves the provided stopping criterion, clones it onto this executor if executors don't match.
Definition: solver_base.hpp:737
gko::solver::EnablePreconditionable::operator=
EnablePreconditionable & operator=(EnablePreconditionable &&other)
Moves the provided preconditioner, clones it onto this executor if executors don't match.
Definition: solver_base.hpp:308
gko::Preconditionable::set_preconditioner
virtual void set_preconditioner(std::shared_ptr< const LinOp > new_precond)
Sets the preconditioner operator used by the Preconditionable.
Definition: lin_op.hpp:702
gko::ptr_param
This class is used for function parameters in the place of raw pointers.
Definition: utils_helper.hpp:41
gko::stop::combine
std::shared_ptr< const CriterionFactory > combine(FactoryContainer &&factories)
Combines multiple criterion factories into a single combined criterion factory.
Definition: combined.hpp:109
gko::solver::enable_preconditioned_iterative_solver_factory_parameters::generated_preconditioner
std::shared_ptr< const LinOp > generated_preconditioner
Already generated preconditioner.
Definition: solver_base.hpp:868
gko::solver::SolverBase
Definition: solver_base.hpp:517
gko::solver::EnablePreconditionable::set_preconditioner
void set_preconditioner(std::shared_ptr< const LinOp > new_precond) override
Sets the preconditioner operator used by the Preconditionable.
Definition: solver_base.hpp:278
gko::solver::initial_guess_mode::rhs
the input is right hand side
gko::matrix::Identity::create
static std::unique_ptr< Identity > create(std::shared_ptr< const Executor > exec, dim< 2 > size)
Creates an Identity matrix of the specified size.
gko::solver::EnableSolverBase
A LinOp deriving from this CRTP class stores a system matrix.
Definition: solver_base.hpp:556
gko::solver::IterativeBase::set_stop_criterion_factory
virtual void set_stop_criterion_factory(std::shared_ptr< const stop::CriterionFactory > new_stop_factory)
Sets the stopping criterion of the solver.
Definition: solver_base.hpp:697
gko::solver::IterativeBase
A LinOp implementing this interface stores a stopping criterion factory.
Definition: solver_base.hpp:679
gko::solver::EnableSolverBase::EnableSolverBase
EnableSolverBase(EnableSolverBase &&other)
Moves the provided system matrix.
Definition: solver_base.hpp:604
gko::solver::SolverBase::get_system_matrix
std::shared_ptr< const MatrixType > get_system_matrix() const
Returns the system matrix, with its concrete type, used by the solver.
Definition: solver_base.hpp:532
gko::solver::IterativeBase::get_stop_criterion_factory
std::shared_ptr< const stop::CriterionFactory > get_stop_criterion_factory() const
Gets the stopping criterion factory of the solver.
Definition: solver_base.hpp:686
gko::make_temporary_clone
detail::temporary_clone< detail::pointee< Ptr > > make_temporary_clone(std::shared_ptr< const Executor > exec, Ptr &&ptr)
Creates a temporary_clone.
Definition: temporary_clone.hpp:208
gko::solver::initial_guess_mode
initial_guess_mode
Give a initial guess mode about the input of the apply method.
Definition: solver_base.hpp:33
gko::solver::EnablePreconditionable::EnablePreconditionable
EnablePreconditionable(EnablePreconditionable &&other)
Moves the provided preconditioner.
Definition: solver_base.hpp:336
gko::solver::initial_guess_mode::provided
the input is provided
gko::solver::EnableIterativeBase::EnableIterativeBase
EnableIterativeBase(EnableIterativeBase &&other)
Moves the provided stopping criterion.
Definition: solver_base.hpp:763
gko::solver::workspace_traits
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition: solver_base.hpp:238
gko::enable_parameters_type
The enable_parameters_type mixin is used to create a base implementation of the factory parameters st...
Definition: abstract_factory.hpp:211
gko::solver::EnableIterativeBase::operator=
EnableIterativeBase & operator=(const EnableIterativeBase &other)
Creates a shallow copy of the provided stopping criterion, clones it onto this executor if executors ...
Definition: solver_base.hpp:724
gko::solver::ApplyWithInitialGuess
ApplyWithInitialGuess provides a way to give the input guess for apply function.
Definition: solver_base.hpp:65
gko::solver::enable_preconditioned_iterative_solver_factory_parameters::preconditioner
std::shared_ptr< const LinOpFactory > preconditioner
The preconditioner to be used by the iterative solver.
Definition: solver_base.hpp:861
gko::solver::EnablePreconditionedIterativeSolver
A LinOp implementing this interface stores a system matrix and stopping criterion factory.
Definition: solver_base.hpp:799