57 void gemv_generic(get_value_t<A> alpha, A
const &a, X
const &x, get_value_t<A> beta, Y &&y) {
58 EXPECTS(a.extent(1) == x.extent(0));
59 EXPECTS(a.extent(0) == y.extent(0));
60 for (
int i = 0; i < a.extent(0); ++i) {
62 for (
int k = 0; k < a.extent(1); ++k) y(i) += alpha * a(i, k) * x(k);
88 requires((MemoryMatrix<A>
or is_conj_array_expr<A>)
and have_same_value_type_v<A, X, Y>
and is_blas_lapack_v<get_value_t<A>>)
89 void gemv(get_value_t<A> alpha, A
const &a, X
const &x, get_value_t<A> beta, Y &&y) {
91 auto to_mat = []<Matrix Z>(Z
const &z) ->
decltype(
auto) {
92 if constexpr (is_conj_array_expr<Z>)
93 return std::get<0>(z.a);
97 auto &mat = to_mat(a);
100 using mat_type =
decltype(mat);
101 static_assert(mem::have_compatible_addr_space<mat_type, X, Y>);
104 EXPECTS(mat.extent(1) == x.extent(0));
105 EXPECTS(mat.extent(0) == y.extent(0));
106 EXPECTS(mat.indexmap().min_stride() == 1);
107 EXPECTS(x.indexmap().min_stride() == 1);
108 EXPECTS(y.indexmap().min_stride() == 1);
111 static constexpr bool conj_A = is_conj_array_expr<A>;
112 char op_a = get_op<conj_A, !has_F_layout<mat_type>>;
113 auto [m, n] = mat.shape();
114 if constexpr (has_C_layout<mat_type>) std::swap(m, n);
116 if constexpr (mem::have_device_compatible_addr_space<mat_type, X, Y>) {
117#if defined(NDA_HAVE_DEVICE)
118 device::gemv(op_a, m, n, alpha, mat.data(), get_ld(mat), x.data(), x.indexmap().strides()[0], beta, y.data(), y.indexmap().strides()[0]);
123 f77::gemv(op_a, m, n, alpha, mat.data(), get_ld(mat), x.data(), x.indexmap().strides()[0], beta, y.data(), y.indexmap().strides()[0]);
void gemv_generic(get_value_t< A > alpha, A const &a, X const &x, get_value_t< A > beta, Y &&y)
Generic nda::blas::gemv implementation for types not supported by BLAS/LAPACK.
void gemv(get_value_t< A > alpha, A const &a, X const &x, get_value_t< A > beta, Y &&y)
Interface to the BLAS gemv routine.