28namespace nda::linalg {
38 template <Matrix A, Vector X, MemoryVector Y>
40 void gemv_generic(
auto alpha, A
const &a, X
const &x,
auto beta, Y &&y) {
42 auto const [m, n] = a.shape();
43 EXPECTS(n == x.size());
44 EXPECTS(m == y.size());
47 for (
int i = 0; i < m; ++i) {
49 for (
int j = 0; j < n; ++j) y(i) += alpha * a(i, j) * x(j);
55 template <
typename T,
typename CP, Vector X>
56 decltype(
auto) get_gemv_vector(X &&x) {
57 if constexpr (std::is_same_v<get_value_t<X>, T> and MemoryVector<X>) {
58 return std::forward<X>(x);
66 template <
typename T,
typename CP, Matrix A>
67 decltype(
auto) get_gemv_matrix(A &&a) {
68 if constexpr (
requires {
blas::get_array(a); } and std::is_same_v<get_value_t<A>, T>) {
70 return std::forward<A>(a);
80 template <Matrix A, Vector X, MemoryVector Y>
81 void make_gemv_call(A
const &a, X
const &x, Y &y) {
117 template <Matrix A, Vector X>
121 using value_t =
decltype(a(0, 0) * x(0));
126 auto res = return_t(a.shape()[0]);
127#if defined(__has_feature)
128#if __has_feature(memory_sanitizer)
135 auto &&a_mat = detail::get_gemv_matrix<value_t, cont_pol>(a);
136 auto &&x_vec = detail::get_gemv_vector<value_t, cont_pol>(x);
139 detail::make_gemv_call(a_mat, x_vec, res);
141 detail::gemv_generic(1, a, x, 0, res);
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides the generic class for arrays.
Provides basic functions to create and manipulate arrays and views.
Provides concepts for the nda library.
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
Provides a custom runtime error class and macros to assert conditions and throw exceptions.
Provides a generic interface to the BLAS gemv routine.
decltype(auto) make_regular(A &&a)
Make a given object regular.
basic_array< ValueType, 1, C_layout, 'V', ContainerPolicy > vector
Alias template of an nda::basic_array with rank 1 and a 'V' algebra.
basic_array< ValueType, 2, Layout, 'M', ContainerPolicy > matrix
Alias template of an nda::basic_array with rank 2 and an 'M' algebra.
static constexpr bool has_C_layout
Constexpr variable that is true if the given nda::Array type has nda::C_layout.
MemoryArray decltype(auto) get_array(A &&a)
Get the underlying array of a conjugate lazy expression or return the array itself in case it is an n...
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.
static constexpr bool have_host_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Host.
static constexpr bool have_compatible_addr_space
Constexpr variable that is true if all given types have compatible address spaces.
heap_basic< mem::mallocator< AdrSp > > heap
Alias template of the nda::heap_basic policy using an nda::mem::mallocator.
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Provides definitions of various layout policies.
Defines various memory handling policies.
Provides type traits for the nda library.