Skip to content

Commit e4f6df9

Browse files
fritzgoebelpratikvn
andcommitted
Update examples/iterative-refinement/iterative-refinement.cpp
Co-Authored-By: Pratik Nayak <pratikvn@protonmail.com>
1 parent e71ca6e commit e4f6df9

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

examples/iterative-refinement/iterative-refinement.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ int main(int argc, char *argv[])
7979
for (auto i = 0; i < size; i++) {
8080
host_x->at(i, 0) = 1.;
8181
}
82-
auto x = gko::matrix::Dense<>::create(exec);
83-
auto b = gko::matrix::Dense<>::create(exec);
82+
auto x = gko::matrix::Dense<ValueType>::create(exec);
83+
auto b = gko::matrix::Dense<ValueType>::create(exec);
8484
x->copy_from(host_x.get());
8585
b->copy_from(host_x.get());
8686

@@ -93,11 +93,12 @@ int main(int argc, char *argv[])
9393

9494
// copy b again
9595
b->copy_from(host_x.get());
96-
96+
gko::size_type max_iters= 10000u;
97+
gko::remove_complex<ValueType> outer_reduction_factor = 1e-12;
9798
auto iter_stop =
98-
gko::stop::Iteration::build().with_max_iters(10000u).on(exec);
99+
gko::stop::Iteration::build().with_max_iters(max_iters).on(exec);
99100
auto tol_stop = gko::stop::ResidualNormReduction<ValueType>::build()
100-
.with_reduction_factor(static_cast<ValueType>(1e-12))
101+
.with_reduction_factor(outer_reduction_factor)
101102
.on(exec);
102103

103104
std::shared_ptr<const gko::log::Convergence<ValueType>> logger =
@@ -106,13 +107,14 @@ int main(int argc, char *argv[])
106107
tol_stop->add_logger(logger);
107108

108109
// Create solver factory
110+
gko::remove_complex<ValueType> inner_reduction_factor = 1e-2;
109111
auto solver_gen =
110112
ir::build()
111113
.with_solver(
112114
cg::build()
113115
.with_criteria(
114116
gko::stop::ResidualNormReduction<ValueType>::build()
115-
.with_reduction_factor(static_cast<ValueType>(1e-2))
117+
.with_reduction_factor(inner_reduction_factor)
116118
.on(exec))
117119
.on(exec))
118120
.with_criteria(gko::share(iter_stop), gko::share(tol_stop))

0 commit comments

Comments
 (0)