@@ -21,6 +21,7 @@ class RowScatter : public ::testing::Test {
21
21
using index_type = std::tuple_element_t <2 , InValueOutValueIndexType>;
22
22
using DenseIn = gko::matrix::Dense<in_value_type>;
23
23
using DenseOut = gko::matrix::Dense<out_value_type>;
24
+ using Scatterer = gko::matrix::RowScatterer<index_type>;
24
25
25
26
26
27
std::shared_ptr<gko::ReferenceExecutor> exec =
@@ -32,6 +33,9 @@ class RowScatter : public ::testing::Test {
32
33
I<I<out_value_type>>{{11 , 22 }, {33 , 44 }, {55 , 66 }, {77 , 88 }}, exec);
33
34
34
35
gko::array<index_type> idxs = {exec, {3 , 1 }};
36
+
37
+ std::unique_ptr<Scatterer> scatterer =
38
+ Scatterer::create (exec, idxs, out->get_size ()[0]);
35
39
};
36
40
37
41
#ifdef GINKGO_MIXED_PRECISION
@@ -43,7 +47,7 @@ TYPED_TEST_SUITE(RowScatter, gko::test::MixedPresisionValueIndexTypes,
43
47
#endif
44
48
45
49
46
- TYPED_TEST (RowScatter, CanScatter )
50
+ TYPED_TEST (RowScatter, CanRowScatter )
47
51
{
48
52
bool invalid_access = false ;
49
53
@@ -70,3 +74,31 @@ TYPED_TEST(RowScatter, CanDetectInvalidAccess)
70
74
71
75
ASSERT_TRUE (invalid_access);
72
76
}
77
+
78
+
79
+ TYPED_TEST (RowScatter, CanRowScatterSimpleApply)
80
+ {
81
+ this ->scatterer ->apply (this ->in .get (), this ->out .get ());
82
+
83
+ auto expected = gko::initialize<typename TestFixture::DenseOut>(
84
+ I<I<typename TestFixture::out_value_type>>{
85
+ {11 , 22 }, {3 , 4 }, {55 , 66 }, {1 , 2 }},
86
+ this ->exec );
87
+ GKO_ASSERT_MTX_NEAR (this ->out , expected, 0.0 );
88
+ }
89
+
90
+
91
+ TYPED_TEST (RowScatter, CanRowScatterAdvancedApply)
92
+ {
93
+ auto alpha = gko::initialize<typename TestFixture::DenseIn>(
94
+ {-gko::one<typename TestFixture::in_value_type>()}, this ->exec );
95
+ auto beta = gko::initialize<typename TestFixture::DenseOut>(
96
+ {-2 * gko::one<typename TestFixture::out_value_type>()}, this ->exec );
97
+ this ->scatterer ->apply (this ->in .get (), this ->out .get ());
98
+
99
+ auto expected = gko::initialize<typename TestFixture::DenseOut>(
100
+ I<I<typename TestFixture::out_value_type>>{
101
+ {-11 , -22 }, {3 , 4 }, {-55 , -66 }, {1 , 2 }},
102
+ this ->exec );
103
+ GKO_ASSERT_MTX_NEAR (this ->out , expected, 0.0 );
104
+ }
0 commit comments