Ginkgo: ginkgo/core/solver/solver_base.hpp Source File

| 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
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
23GKO_BEGIN_DISABLE_DEPRECATION_WARNINGS
24
25
26namespace gko {
27namespace solver {
28
29
33 enum class initial_guess_mode {
37 zero,
41 rhs,
45 provided
46};
47
48
49namespace multigrid {
50namespace detail {
51
52
53class MultigridState;
54
55
56} // namespace detail
57} // namespace multigrid
58
59
65 class ApplyWithInitialGuess {
66protected:
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,
109 ptr_param<const LinOp> b,
110 ptr_param<const LinOp> beta,
111 ptr_param<LinOp> x,
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(
132 initial_guess_mode guess = initial_guess_mode::provided)
133 : guess_(guess)
134 {}
135
141 void set_default_initial_guess(initial_guess_mode guess) { guess_ = guess; }
142
143private:
144 initial_guess_mode guess_;
145};
146
147
160template <typename DerivedType>
161 class EnableApplyWithInitialGuess : public ApplyWithInitialGuess {
162protected:
163 friend class multigrid::detail::MultigridState;
164
165 explicit EnableApplyWithInitialGuess(
166 initial_guess_mode guess = initial_guess_mode::provided)
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
237template <typename Solver>
238 struct workspace_traits {
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
269template <typename DerivedType>
270 class EnablePreconditionable : public Preconditionable {
271public:
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 }
288 Preconditionable::set_preconditioner(new_precond);
289 }
290
295 EnablePreconditionable& operator=(const EnablePreconditionable& other)
296 {
297 if (&other != this) {
298 set_preconditioner(other.get_preconditioner());
299 }
300 return *this;
301 }
302
308 EnablePreconditionable& operator=(EnablePreconditionable&& other)
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
327 EnablePreconditionable(const EnablePreconditionable& other)
328 {
329 *this = other;
330 }
331
336 EnablePreconditionable(EnablePreconditionable&& other)
337 {
338 *this = std::move(other);
339 }
340
341private:
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
351namespace detail {
352
353
362class SolverBaseLinOp {
363public:
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
404protected:
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 [&] {
472 return matrix::Dense<ValueType>::create(
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 [&] {
485 auto mat = matrix::Dense<ValueType>::create(
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
506private:
507 mutable detail::workspace workspace_;
508
509 std::shared_ptr<const LinOp> system_matrix_;
510};
511
512
513} // namespace detail
514
515
516template <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 {
522public:
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
538protected:
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
555template <typename DerivedType, typename MatrixType = LinOp>
556 class EnableSolverBase : public SolverBase<MatrixType> {
557public:
562 EnableSolverBase& operator=(const EnableSolverBase& other)
563 {
564 if (&other != this) {
565 set_system_matrix(other.get_system_matrix());
566 }
567 return *this;
568 }
569
574 EnableSolverBase& operator=(EnableSolverBase&& other)
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
594 EnableSolverBase(const EnableSolverBase& other)
595 : SolverBase<MatrixType>{other.self()->get_executor()}
596 {
597 *this = other;
598 }
599
604 EnableSolverBase(EnableSolverBase&& other)
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
642protected:
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
663private:
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
679 class IterativeBase {
680public:
686 std::shared_ptr<const stop::CriterionFactory> get_stop_criterion_factory()
687 const
688 {
689 return stop_factory_;
690 }
691
697 virtual void set_stop_criterion_factory(
698 std::shared_ptr<const stop::CriterionFactory> new_stop_factory)
699 {
700 stop_factory_ = new_stop_factory;
701 }
702
703private:
704 std::shared_ptr<const stop::CriterionFactory> stop_factory_;
705};
706
707
717template <typename DerivedType>
718 class EnableIterativeBase : public IterativeBase {
719public:
724 EnableIterativeBase& operator=(const EnableIterativeBase& other)
725 {
726 if (&other != this) {
727 set_stop_criterion_factory(other.get_stop_criterion_factory());
728 }
729 return *this;
730 }
731
737 EnableIterativeBase& operator=(EnableIterativeBase&& other)
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
748 EnableIterativeBase(
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
763 EnableIterativeBase(EnableIterativeBase&& other)
764 {
765 *this = std::move(other);
766 }
767
768 void set_stop_criterion_factory(
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 }
775 IterativeBase::set_stop_criterion_factory(new_stop_factory);
776 }
777
778private:
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
798template <typename ValueType, typename DerivedType>
799 class EnablePreconditionedIterativeSolver
800 : public EnableSolverBase<DerivedType>,
801 public EnableIterativeBase<DerivedType>,
802 public EnablePreconditionable<DerivedType> {
803public:
804 EnablePreconditionedIterativeSolver() = default;
805
806 EnablePreconditionedIterativeSolver(
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>
816 EnablePreconditionedIterativeSolver(
817 std::shared_ptr<const LinOp> system_matrix,
818 const FactoryParameters& params)
819 : EnablePreconditionedIterativeSolver{
820 system_matrix, stop::combine(params.criteria),
821 generate_preconditioner(system_matrix, params)}
822 {}
823
824private:
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 {
835 return matrix::Identity<ValueType>::create(
836 system_matrix->get_executor(), system_matrix->get_size());
837 }
838 }
839};
840
841
842template <typename Parameters, typename Factory>
843 struct enable_iterative_solver_factory_parameters
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
853template <typename Parameters, typename Factory>
854 struct enable_preconditioned_iterative_solver_factory_parameters
855 : enable_iterative_solver_factory_parameters<Parameters, Factory> {
860 std::shared_ptr<const LinOpFactory> GKO_DEFERRED_FACTORY_PARAMETER(
861 preconditioner);
862
867 std::shared_ptr<const LinOp> GKO_FACTORY_PARAMETER_SCALAR(
868 generated_preconditioner, nullptr);
869};
870
871
872} // namespace solver
873} // namespace gko
874
875
876GKO_END_DISABLE_DEPRECATION_WARNINGS
877
878
879#endif // GKO_PUBLIC_CORE_SOLVER_SOLVER_BASE_HPP_
gko::LinOp
Definition lin_op.hpp:117
gko::Preconditionable
A LinOp implementing this interface can be preconditioned.
Definition lin_op.hpp:682
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::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::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::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::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::ptr_param
This class is used for function parameters in the place of raw pointers.
Definition utils_helper.hpp:41
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::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::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::EnableIterativeBase::EnableIterativeBase
EnableIterativeBase(EnableIterativeBase &&other)
Moves the provided stopping criterion.
Definition solver_base.hpp:763
gko::solver::EnableIterativeBase::EnableIterativeBase
EnableIterativeBase(const EnableIterativeBase &other)
Creates a shallow copy of the provided stopping criterion.
Definition solver_base.hpp:757
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::EnablePreconditionable
Mixin providing default operation for Preconditionable with correct value semantics.
Definition solver_base.hpp:270
gko::solver::EnablePreconditionable::EnablePreconditionable
EnablePreconditionable(const EnablePreconditionable &other)
Creates a shallow copy of the provided preconditioner.
Definition solver_base.hpp:327
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::solver::EnablePreconditionable::EnablePreconditionable
EnablePreconditionable(EnablePreconditionable &&other)
Moves the provided preconditioner.
Definition solver_base.hpp:336
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::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::EnableSolverBase
A LinOp deriving from this CRTP class stores a system matrix.
Definition solver_base.hpp:556
gko::solver::EnableSolverBase::EnableSolverBase
EnableSolverBase(EnableSolverBase &&other)
Moves the provided system matrix.
Definition solver_base.hpp:604
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::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::solver::EnableSolverBase::EnableSolverBase
EnableSolverBase(const EnableSolverBase &other)
Creates a shallow copy of the provided system matrix.
Definition solver_base.hpp:594
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::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::solver::IterativeBase
A LinOp implementing this interface stores a stopping criterion factory.
Definition solver_base.hpp:679
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::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::SolverBase
Definition solver_base.hpp:521
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_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::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::log
The logger namespace .
Definition convergence.hpp:22
gko::multigrid
The multigrid components namespace.
Definition matrix.hpp:36
gko::preconditioner
The Preconditioner namespace.
Definition gauss_seidel.hpp:19
gko::solver
The ginkgo Solve namespace.
Definition bicg.hpp:28
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::initial_guess_mode::provided
@ provided
the input is provided
Definition solver_base.hpp:45
gko::solver::initial_guess_mode::rhs
@ rhs
the input is right hand side
Definition solver_base.hpp:41
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::zero
constexpr T zero()
Returns the additive identity for T.
Definition math.hpp:626
gko::size_type
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90
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::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::layout_type::array
@ array
The matrix should be written as dense matrix in column-major order.
Definition mtx_io.hpp:97
gko::dim
A type representing the dimensions of a multidimensional object.
Definition dim.hpp:26
gko::solver::enable_iterative_solver_factory_parameters
Definition solver_base.hpp:844
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::enable_preconditioned_iterative_solver_factory_parameters
Definition solver_base.hpp:855
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::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::workspace_traits
Traits class providing information on the type and location of workspace vectors inside a solver.
Definition solver_base.hpp:238