6 template <
typename T,
typename VEC1,
typename VEC2>
7 void matvec_core(
const matrix::LinearOperator<T> &A,
const VEC1 &x, VEC2 &y) {
12 assert(A.get_row() == y.size());
13 assert(A.get_col() == x.size());
15 assert(A.get_matvec_init_flag());
17 const size_t xoffset = x.get_offset();
18 const size_t yoffset = y.get_offset();
20 vector<T> x_tmp(x.size(), 0);
21 if (x.get_device_mem_stat())
23 vector<T> y_tmp(y.size(), 0);
24 if (y.get_device_mem_stat())
27 internal::vcopy(x.size(), x.data() + xoffset, x_tmp.data(),
28 x.get_device_mem_stat());
30 y_tmp = A.get_matvec()(x_tmp);
32 internal::vcopy(y.size(), y_tmp.data(), y.data() + yoffset,
33 y.get_device_mem_stat());
38 template <
typename T,
typename VEC1,
typename VEC2>
39 void rmatvec_core(
const matrix::LinearOperator<T> &A,
const VEC1 &x, VEC2 &y) {
44 assert(A.get_row() == x.size());
45 assert(A.get_col() == y.size());
47 assert(A.get_rmatvec_init_flag());
49 const size_t xoffset = x.get_offset();
50 const size_t yoffset = y.get_offset();
52 vector<T> x_tmp(x.size(), 0);
53 if (x.get_device_mem_stat())
55 vector<T> y_tmp(y.size(), 0);
56 if (y.get_device_mem_stat())
59 internal::vcopy(x.size(), x.data() + xoffset, x_tmp.data(),
60 x.get_device_mem_stat());
62 y_tmp = A.get_rmatvec()(x_tmp);
64 internal::vcopy(y.size(), y_tmp.data(), y.data() + yoffset,
65 y.get_device_mem_stat());