@@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
49
50
50
#include " core/solver/minres_kernels.hpp"
51
51
#include " core/test/utils.hpp"
52
- #include " core/test/ utils/matrix_utils.hpp"
52
+ #include " core/utils/matrix_utils.hpp"
53
53
#include " test/utils/executor.hpp"
54
54
55
55
namespace {
@@ -80,14 +80,19 @@ class Minres : public ::testing::Test {
80
80
}
81
81
82
82
std::unique_ptr<Mtx> gen_mtx (gko::size_type num_rows,
83
- gko::size_type num_cols, gko::size_type stride)
83
+ gko::size_type num_cols, gko::size_type stride,
84
+ bool make_hermitian)
84
85
{
85
- auto tmp_mtx = gko::test::generate_random_matrix<Mtx >(
86
+ auto tmp_mtx = gko::test::generate_random_matrix_data<value_type , gko::int32 >(
86
87
num_rows, num_cols,
87
88
std::uniform_int_distribution<>(num_cols, num_cols),
88
- std::normal_distribution<value_type>(-1.0 , 1.0 ), rand_engine, ref);
89
+ std::normal_distribution<value_type>(-1.0 , 1.0 ), rand_engine);
90
+ if (make_hermitian) {
91
+ gko::utils::make_unit_diagonal (tmp_mtx);
92
+ gko::utils::make_hermitian (tmp_mtx);
93
+ }
89
94
auto result = Mtx::create (ref, gko::dim<2 >{num_rows, num_cols}, stride);
90
- result->copy_from (tmp_mtx. get () );
95
+ result->read (tmp_mtx);
91
96
return result;
92
97
}
93
98
@@ -96,31 +101,31 @@ class Minres : public ::testing::Test {
96
101
gko::size_type m = 597 ;
97
102
gko::size_type n = 43 ;
98
103
// all vectors need the same stride as b, except x
99
- b = gen_mtx (m, n, n + 2 );
100
- r = gen_mtx (m, n, n + 2 );
101
- z = gen_mtx (m, n, n + 2 );
102
- z_tilde = gen_mtx (m, n, n + 2 );
103
- p = gen_mtx (m, n, n + 2 );
104
- p_prev = gen_mtx (m, n, n + 2 );
105
- q = gen_mtx (m, n, n + 2 );
106
- q_prev = gen_mtx (m, n, n + 2 );
107
- v = gen_mtx (m, n, n + 2 );
108
- x = gen_mtx (m, n, n + 3 );
109
- alpha = gen_mtx (1 , n, n);
110
- beta = gen_mtx (1 , n, n)->compute_absolute ();
111
- gamma = gen_mtx (1 , n, n);
112
- delta = gen_mtx (1 , n, n);
113
- cos_prev = gen_mtx (1 , n, n);
114
- cos = gen_mtx (1 , n, n);
115
- sin_prev = gen_mtx (1 , n, n);
116
- sin = gen_mtx (1 , n, n);
117
- eta_next = gen_mtx (1 , n, n);
118
- eta = gen_mtx (1 , n, n);
119
- tau = gen_mtx (1 , n, n)->compute_absolute ();
104
+ b = gen_mtx (m, n, n + 2 , false );
105
+ r = gen_mtx (m, n, n + 2 , false );
106
+ z = gen_mtx (m, n, n + 2 , false );
107
+ z_tilde = gen_mtx (m, n, n + 2 , false );
108
+ p = gen_mtx (m, n, n + 2 , false );
109
+ p_prev = gen_mtx (m, n, n + 2 , false );
110
+ q = gen_mtx (m, n, n + 2 , false );
111
+ q_prev = gen_mtx (m, n, n + 2 , false );
112
+ v = gen_mtx (m, n, n + 2 , false );
113
+ x = gen_mtx (m, n, n + 3 , false );
114
+ alpha = gen_mtx (1 , n, n, false );
115
+ beta = gen_mtx (1 , n, n, false )->compute_absolute ();
116
+ gamma = gen_mtx (1 , n, n, false );
117
+ delta = gen_mtx (1 , n, n, false );
118
+ cos_prev = gen_mtx (1 , n, n, false );
119
+ cos = gen_mtx (1 , n, n, false );
120
+ sin_prev = gen_mtx (1 , n, n, false );
121
+ sin = gen_mtx (1 , n, n, false );
122
+ eta_next = gen_mtx (1 , n, n, false );
123
+ eta = gen_mtx (1 , n, n, false );
124
+ tau = gen_mtx (1 , n, n, false )->compute_absolute ();
120
125
// check correct handling for zero values
121
126
beta->at (2 ) = gko::zero<value_type>();
122
127
stop_status =
123
- std::make_unique<gko::Array <gko::stopping_status>>(ref, n);
128
+ std::make_unique<gko::array <gko::stopping_status>>(ref, n);
124
129
for (size_t i = 0 ; i < stop_status->get_num_elems (); ++i) {
125
130
stop_status->get_data ()[i].reset ();
126
131
}
@@ -148,7 +153,7 @@ class Minres : public ::testing::Test {
148
153
d_cos = gko::clone (exec, cos );
149
154
d_sin_prev = gko::clone (exec, sin_prev);
150
155
d_sin = gko::clone (exec, sin );
151
- d_stop_status = std::make_unique<gko::Array <gko::stopping_status>>(
156
+ d_stop_status = std::make_unique<gko::array <gko::stopping_status>>(
152
157
exec, *stop_status);
153
158
}
154
159
@@ -203,8 +208,8 @@ class Minres : public ::testing::Test {
203
208
std::unique_ptr<Mtx> d_sin_prev;
204
209
std::unique_ptr<Mtx> d_sin;
205
210
206
- std::unique_ptr<gko::Array <gko::stopping_status>> stop_status;
207
- std::unique_ptr<gko::Array <gko::stopping_status>> d_stop_status;
211
+ std::unique_ptr<gko::array <gko::stopping_status>> stop_status;
212
+ std::unique_ptr<gko::array <gko::stopping_status>> d_stop_status;
208
213
};
209
214
210
215
@@ -296,10 +301,9 @@ TEST_F(Minres, MinresStep2IsEquivalentToStep2)
296
301
297
302
TEST_F (Minres, ApplyIsEquivalentToRef)
298
303
{
299
- auto mtx = gen_mtx (50 , 50 , 53 );
300
- gko::test::make_hermitian (mtx.get ());
301
- auto x = gen_mtx (50 , 1 , 5 );
302
- auto b = gen_mtx (50 , 1 , 4 );
304
+ auto mtx = gen_mtx (50 , 50 , 53 , true );
305
+ auto x = gen_mtx (50 , 1 , 5 , false );
306
+ auto b = gen_mtx (50 , 1 , 4 , false );
303
307
auto d_mtx = gko::clone (exec, mtx);
304
308
auto d_x = gko::clone (exec, x);
305
309
auto d_b = gko::clone (exec, b);
@@ -331,11 +335,9 @@ TEST_F(Minres, ApplyIsEquivalentToRef)
331
335
332
336
TEST_F (Minres, PreconditionedApplyIsEquivalentToRef)
333
337
{
334
-
335
- auto mtx = gen_mtx (50 , 50 , 53 );
336
- gko::test::make_hpd (mtx.get ());
337
- auto x = gen_mtx (50 , 1 , 5 );
338
- auto b = gen_mtx (50 , 1 , 4 );
338
+ auto mtx = gen_mtx (50 , 50 , 53 , true );
339
+ auto x = gen_mtx (50 , 1 , 5 , false );
340
+ auto b = gen_mtx (50 , 1 , 4 , false );
339
341
auto d_mtx = gko::clone (exec, mtx);
340
342
auto d_x = gko::clone (exec, x);
341
343
auto d_b = gko::clone (exec, b);
0 commit comments