Skip to content

Commit

Permalink
clarify implicit/actual res norm docs, MSVC fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikvn committed Oct 31, 2023
1 parent 9f6d466 commit 28560a5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion core/test/solver/batch_bicgstab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
4 changes: 4 additions & 0 deletions include/ginkgo/core/log/batch_logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions include/ginkgo/core/solver/batch_bicgstab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions include/ginkgo/core/solver/batch_solver_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class BatchSolver {
*/
std::shared_ptr<const BatchLinOp> get_system_matrix() const
{
return system_matrix_;
return this->system_matrix_;
}

/**
Expand All @@ -73,15 +73,15 @@ class BatchSolver {
*/
std::shared_ptr<const BatchLinOp> get_preconditioner() const
{
return preconditioner_;
return this->preconditioner_;
}

/**
* Get the residual tolerance used by the solver.
*
* @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.
Expand All @@ -94,15 +94,15 @@ class BatchSolver {
if (res_tol < 0) {
GKO_INVALID_STATE("Tolerance cannot be negative!");
}
residual_tol_ = res_tol;
this->residual_tol_ = res_tol;
}

/**
* Get the maximum number of iterations set on the solver.
*
* @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,
Expand All @@ -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;
}

/**
Expand All @@ -125,7 +125,7 @@ class BatchSolver {
*/
::gko::batch::stop::tolerance_type get_tolerance_type() const
{
return tol_type_;
return this->tol_type_;
}

/**
Expand All @@ -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!");
}
Expand All @@ -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_{};
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 28560a5

Please sign in to comment.