Skip to content

Commit

Permalink
use the baseline directly
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Aug 4, 2021
1 parent 286a163 commit d50d517
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions reference/test/stop/residual_norm_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ TYPED_TEST(ResidualNorm, WaitsTillResidualGoal)
.residual_norm(res_norm.get())
.check(RelativeStoppingId, true, &stop_status, &one_changed));

res_norm->at(0) = r<TypeParam>::value * 1.1 * res_norm->at(0);
res_norm->at(0) = r<TypeParam>::value * 1.1 * rhs_norm->at(0);
ASSERT_FALSE(
rhs_criterion->update()
.residual_norm(res_norm.get())
.check(RelativeStoppingId, true, &stop_status, &one_changed));
ASSERT_EQ(stop_status.get_data()[0].has_converged(), false);
ASSERT_EQ(one_changed, false);

res_norm->at(0) = r<TypeParam>::value * 0.9 * res_norm->at(0);
res_norm->at(0) = r<TypeParam>::value * 0.9 * rhs_norm->at(0);
ASSERT_TRUE(
rhs_criterion->update()
.residual_norm(res_norm.get())
Expand All @@ -180,6 +180,7 @@ TYPED_TEST(ResidualNorm, WaitsTillResidualGoal)
}
{
auto res_norm = gko::initialize<NormVector>({100.0}, this->exec_);
auto init_res_val = res_norm->at(0, 0);
constexpr gko::uint8 RelativeStoppingId{1};
bool one_changed{};
gko::Array<gko::stopping_status> stop_status(this->exec_, 1);
Expand All @@ -190,15 +191,15 @@ TYPED_TEST(ResidualNorm, WaitsTillResidualGoal)
.residual_norm(res_norm.get())
.check(RelativeStoppingId, true, &stop_status, &one_changed));

res_norm->at(0) = r<TypeParam>::value * 1.1 * res_norm->at(0);
res_norm->at(0) = r<TypeParam>::value * 1.1 * init_res_val;
ASSERT_FALSE(
rel_criterion->update()
.residual_norm(res_norm.get())
.check(RelativeStoppingId, true, &stop_status, &one_changed));
ASSERT_EQ(stop_status.get_data()[0].has_converged(), false);
ASSERT_EQ(one_changed, false);

res_norm->at(0) = r<TypeParam>::value * 0.9 * res_norm->at(0);
res_norm->at(0) = r<TypeParam>::value * 0.9 * init_res_val;
ASSERT_TRUE(
rel_criterion->update()
.residual_norm(res_norm.get())
Expand Down Expand Up @@ -590,6 +591,7 @@ TYPED_TEST(ResidualNormReduction, WaitsTillResidualGoal)
auto initial_res = gko::initialize<Mtx>({100.0}, this->exec_);
std::shared_ptr<gko::LinOp> rhs = gko::initialize<Mtx>({10.0}, this->exec_);
auto res_norm = gko::initialize<NormVector>({100.0}, this->exec_);
auto init_res_val = res_norm->at(0, 0);
auto criterion =
this->factory_->generate(nullptr, rhs, nullptr, initial_res.get());
bool one_changed{};
Expand All @@ -602,15 +604,15 @@ TYPED_TEST(ResidualNormReduction, WaitsTillResidualGoal)
.residual_norm(res_norm.get())
.check(RelativeStoppingId, true, &stop_status, &one_changed));

res_norm->at(0) = r<TypeParam>::value * 1.1 * res_norm->at(0);
res_norm->at(0) = r<TypeParam>::value * 1.1 * init_res_val;
ASSERT_FALSE(
criterion->update()
.residual_norm(res_norm.get())
.check(RelativeStoppingId, true, &stop_status, &one_changed));
ASSERT_EQ(stop_status.get_data()[0].has_converged(), false);
ASSERT_EQ(one_changed, false);

res_norm->at(0) = r<TypeParam>::value * 0.9 * res_norm->at(0);
res_norm->at(0) = r<TypeParam>::value * 0.9 * init_res_val;
ASSERT_TRUE(
criterion->update()
.residual_norm(res_norm.get())
Expand Down

0 comments on commit d50d517

Please sign in to comment.