message: test composition initial guess
diff: @@ -48,10 +48,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  namespace {
  +template <typename ValueType>
  +class DummyLinOp : public gko::EnableLinOp<DummyLinOp<ValueType>>,
  + public gko::EnableCreateMethod<DummyLinOp<ValueType>> {
  + friend class gko::EnablePolymorphicObject<DummyLinOp, gko::LinOp>;
  + friend class gko::EnableCreateMethod<DummyLinOp>;
  +
  +public:
  + using value_type = ValueType;
  +
  + bool apply_uses_initial_guess() const override { return true; }
  +
  +protected:
  + void apply_impl(const gko::LinOp *b, gko::LinOp *x) const override {}
  +
  + void apply_impl(const gko::LinOp *alpha, const gko::LinOp *b,
  + const gko::LinOp *beta, gko::LinOp *x) const override
  + {}
  +
  + explicit DummyLinOp(std::shared_ptr<const gko::Executor> exec)
  + : gko::EnableLinOp<DummyLinOp>(exec)
  + {}
  +
  + explicit DummyLinOp(std::shared_ptr<const gko::Executor> exec,
  + gko::dim<2> size)
  + : gko::EnableLinOp<DummyLinOp>(exec, size)
  + {}
  +};
  +
  +
  template <typename T>
  class Composition : public ::testing::Test {
  protected:
  using Mtx = gko::matrix::Dense<T>;
  + using value_type = T;
  Composition()
  : exec{gko::ReferenceExecutor::create()},
  @@ -275,4 +305,45 @@ TYPED_TEST(Composition, AppliesLongestLinearCombinationToVectorMultipleRhs)
  }
  +TYPED_TEST(Composition, AppliesToVectorWithInitialGuess)
  +{
  + /*
  + cmp = I * DummyLinOp * I
  + */
  + using Mtx = typename TestFixture::Mtx;
  + using value_type = typename TestFixture::value_type;
  + auto cmp = gko::Composition<TypeParam>::create(
  + this->identity,
  + DummyLinOp<value_type>::create(this->exec, this->identity->get_size()),
  + this->identity);
  + auto x = gko::initialize<Mtx>({1.0, 2.0}, this->exec);
  + auto res = clone(x);
  +
  + cmp->apply(lend(x), lend(res));
  +
  + GKO_ASSERT_MTX_NEAR(res, l({1.0, 2.0}), 0);
  +}
  +
  +
  +TYPED_TEST(Composition, AppliesToVectorWithInitialGuess2)
  +{
  + /*
  + cmp = I * DummyLinOp(2x3) * DummyLinOp(3x2) * I
  + */
  + using Mtx = typename TestFixture::Mtx;
  + using value_type = typename TestFixture::value_type;
  + auto size1 = gko::dim<2>(3, 2);
  + auto size2 = gko::dim<2>(2, 3);
  + auto cmp = gko::Composition<TypeParam>::create(
  + this->identity, DummyLinOp<value_type>::create(this->exec, size2),
  + DummyLinOp<value_type>::create(this->exec, size1), this->identity);
  + auto x = gko::initialize<Mtx>({1.0, 2.0}, this->exec);
  + auto res = clone(x);
  +
  + cmp->apply(lend(x), lend(res));
  +
  + GKO_ASSERT_MTX_NEAR(res, l({0.0, 0.0}), 0);
  +}
  +
  +
  } // namespace
  