diff --git a/core/test/solver/batch_bicgstab.cpp b/core/test/solver/batch_bicgstab.cpp index 386bfac3e67..07b94fd2617 100644 --- a/core/test/solver/batch_bicgstab.cpp +++ b/core/test/solver/batch_bicgstab.cpp @@ -74,11 +74,11 @@ class BatchBicgstab : public ::testing::Test { const gko::size_type num_batch_items = 3; const int num_rows = 5; std::shared_ptr<const Mtx> mtx; - std::unique_ptr<typename Solver::Factory> solver_factory; const int def_max_iters = 100; const real_type def_abs_res_tol = 1e-11; const gko::batch::stop::tolerance_type def_tol_type = gko::batch::stop::tolerance_type::absolute; + std::unique_ptr<typename Solver::Factory> solver_factory; std::unique_ptr<gko::batch::BatchLinOp> solver; }; diff --git a/include/ginkgo/core/log/batch_logger.hpp b/include/ginkgo/core/log/batch_logger.hpp index c28f5489390..d6d76d81ccf 100644 --- a/include/ginkgo/core/log/batch_logger.hpp +++ b/include/ginkgo/core/log/batch_logger.hpp @@ -116,6 +116,10 @@ struct log_data final { * The purpose of this logger is to give simple access to standard data * generated by the solver once it has converged. * + * @note The final logged residuals are the implicit residuals that have been + * computed within the solver process. Depending on the solver algorithm, this + * may be significantly different from the true residual (||b - Ax||). + * * @ingroup log */ template <typename ValueType = default_precision> diff --git a/include/ginkgo/core/solver/batch_bicgstab.hpp b/include/ginkgo/core/solver/batch_bicgstab.hpp index e93f3e7a260..4ce8ad7c1bd 100644 --- a/include/ginkgo/core/solver/batch_bicgstab.hpp +++ b/include/ginkgo/core/solver/batch_bicgstab.hpp @@ -64,6 +64,12 @@ namespace solver { * tolerance (absolute or relative) and the maximum number of iterations to be * used in the stopping criterion can be set via the factory parameters. * + * @note The tolerance check is against the internal residual computed within + * the solver process. This implicit (internal) residual, can diverge from the + * true residual (||b - Ax||). A posterori checks (by computing the true + * residual, ||b - Ax||) are recommended to ensure that the solution has + * converged to the desired tolerance. + * * @tparam ValueType precision of matrix elements * * @ingroup solvers diff --git a/include/ginkgo/core/solver/batch_solver_base.hpp b/include/ginkgo/core/solver/batch_solver_base.hpp index 7ff8d1c61c1..06aa5c0122e 100644 --- a/include/ginkgo/core/solver/batch_solver_base.hpp +++ b/include/ginkgo/core/solver/batch_solver_base.hpp @@ -63,7 +63,7 @@ class BatchSolver { */ std::shared_ptr<const BatchLinOp> get_system_matrix() const { - return system_matrix_; + return this->system_matrix_; } /** @@ -73,7 +73,7 @@ class BatchSolver { */ std::shared_ptr<const BatchLinOp> get_preconditioner() const { - return preconditioner_; + return this->preconditioner_; } /** @@ -81,7 +81,7 @@ class BatchSolver { * * @return The residual tolerance. */ - double get_tolerance() const { return residual_tol_; } + double get_tolerance() const { return this->residual_tol_; } /** * Update the residual tolerance to be used by the solver. @@ -94,7 +94,7 @@ class BatchSolver { if (res_tol < 0) { GKO_INVALID_STATE("Tolerance cannot be negative!"); } - residual_tol_ = res_tol; + this->residual_tol_ = res_tol; } /** @@ -102,7 +102,7 @@ class BatchSolver { * * @return Maximum number of iterations. */ - int get_max_iterations() const { return max_iterations_; } + int get_max_iterations() const { return this->max_iterations_; } /** * Set the maximum number of iterations for the solver to use, @@ -115,7 +115,7 @@ class BatchSolver { if (max_iterations < 0) { GKO_INVALID_STATE("Max iterations cannot be negative!"); } - max_iterations_ = max_iterations; + this->max_iterations_ = max_iterations; } /** @@ -125,7 +125,7 @@ class BatchSolver { */ ::gko::batch::stop::tolerance_type get_tolerance_type() const { - return tol_type_; + return this->tol_type_; } /** @@ -137,7 +137,7 @@ class BatchSolver { { if (tol_type == ::gko::batch::stop::tolerance_type::absolute || tol_type == ::gko::batch::stop::tolerance_type::relative) { - tol_type_ = tol_type; + this->tol_type_ = tol_type; } else { GKO_INVALID_STATE("Invalid tolerance type specified!"); } @@ -160,12 +160,12 @@ class BatchSolver { void set_system_matrix_base(std::shared_ptr<const BatchLinOp> system_matrix) { - system_matrix_ = std::move(system_matrix); + this->system_matrix_ = std::move(system_matrix); } void set_preconditioner_base(std::shared_ptr<const BatchLinOp> precond) { - preconditioner_ = std::move(precond); + this->preconditioner_ = std::move(precond); } std::shared_ptr<const BatchLinOp> system_matrix_{}; @@ -386,11 +386,11 @@ class EnableBatchSolver { if (&other != this) { this->set_size(other.get_size()); - set_system_matrix(other.get_system_matrix()); - set_preconditioner(other.get_preconditioner()); - reset_tolerance(other.get_tolerance()); - reset_max_iterations(other.get_max_iterations()); - reset_tolerance_type(other.get_tolerance_type()); + this->set_system_matrix(other.get_system_matrix()); + this->set_preconditioner(other.get_preconditioner()); + this->reset_tolerance(other.get_tolerance()); + this->reset_max_iterations(other.get_max_iterations()); + this->reset_tolerance_type(other.get_tolerance_type()); } return *this; } @@ -399,11 +399,11 @@ class EnableBatchSolver { if (&other != this) { this->set_size(other.get_size()); - set_system_matrix(other.get_system_matrix()); - set_preconditioner(other.get_preconditioner()); - reset_tolerance(other.get_tolerance()); - reset_max_iterations(other.get_max_iterations()); - reset_tolerance_type(other.get_tolerance_type()); + this->set_system_matrix(other.get_system_matrix()); + this->set_preconditioner(other.get_preconditioner()); + this->reset_tolerance(other.get_tolerance()); + this->reset_max_iterations(other.get_max_iterations()); + this->reset_tolerance_type(other.get_tolerance_type()); other.set_system_matrix(nullptr); other.set_preconditioner(nullptr); }