55 template <Matrix A, Matrix B, MemoryMatrix C,
bool conj_A = blas::is_conj_array_expr<A>,
bool conj_B = blas::is_conj_array_expr<B>>
56 requires((MemoryMatrix<A> or conj_A) and (MemoryMatrix<B> or conj_B))
57 static constexpr bool is_valid_gemm_triple = []() {
59 if constexpr (has_F_layout<C>) {
60 return !(conj_A and has_F_layout<A>)and!(conj_B and has_F_layout<B>);
62 return !(conj_B and !has_F_layout<B>)and!(conj_A and !has_F_layout<A>);
68 using get_layout_policy =
typename std::remove_reference_t<decltype(make_regular(std::declval<A>()))>::layout_policy_t;
86 template <Matrix A, Matrix B>
89 EXPECTS_WITH_MESSAGE(a.shape()[1] == b.shape()[0],
"Error in nda::matmul: Dimension mismatch in matrix-matrix product");
103 auto result = matrix_t(a.shape()[0], b.shape()[1]);
107 auto as_container = []<
Matrix M>(M &&m) ->
decltype(
auto) {
109 return std::forward<M>(m);
111 return matrix_t{std::forward<M>(m)};
116#if defined(__has_feature)
117#if __has_feature(memory_sanitizer)
123 if constexpr (detail::is_valid_gemm_triple<
decltype(as_container(a)),
decltype(as_container(b)), matrix_t>) {
124 blas::gemm(1, as_container(a), as_container(b), 0, result);
151 template <Matrix A, Vector X>
154 EXPECTS_WITH_MESSAGE(a.shape()[1] == x.shape()[0],
"Error in nda::matvecmul: Dimension mismatch in matrix-vector product");
159 static_assert(L_adr_spc == R_adr_spc,
"Error in nda::matvecmul: Matrix-vector product requires arguments with same address spaces");
160 static_assert(L_adr_spc != mem::None);
167 auto result = vector_t(a.shape()[0]);
171 auto as_container = []<
Array B>(B &&b) ->
decltype(
auto) {
173 return std::forward<B>(b);
180#if defined(__has_feature)
181#if __has_feature(memory_sanitizer)
191 blas::gemv(1, as_container(a), as_container(x), 0, result);
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides basic functions to create and manipulate arrays and views.
A generic multi-dimensional array.
Check if a given type satisfies the array concept.
Check if a given type is a matrix, i.e. an nda::ArrayOfRank<2>.
Check if a given type is a memory matrix, i.e. an nda::MemoryArrayOfRank<2>.
Provides concepts for the nda library.
Provides various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
Provides a generic interface to the BLAS gemm routine.
Provides a generic interface to the BLAS gemv routine.
decltype(auto) make_regular(A &&a)
Make a given object regular.
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
constexpr layout_info_t get_layout_info
Constexpr variable that specifies the nda::layout_info_t of type A.
void gemm_generic(typename A::value_type alpha, A const &a, B const &b, typename A::value_type beta, C &&c)
Generic nda::blas::gemm implementation for types not supported by BLAS/LAPACK.
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.
static constexpr bool is_conj_array_expr
Constexpr variable that is true if the given type is a conjugate lazy expression.
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 has_F_layout
Constexpr variable that is true if the given nda::Array type has a Fortran memory layout.
void gemm(get_value_t< A > alpha, A const &a, B const &b, get_value_t< A > beta, C &&c)
Interface to the BLAS gemm routine.
static constexpr AddressSpace get_addr_space
Variable template providing the address space for different types.
static constexpr AddressSpace get_addr_space< A >
Specialization of nda::mem::get_addr_space for nda::Memory Array types.
static const auto check_adr_sp_valid
Check validity of a set of nda::mem::AddressSpace values.
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.
Contiguous layout policy with C-order (row-major order).
Memory policy using an nda::mem::handle_heap.
uint64_t stride_order
Stride order of the array/view.
Provides type traits for the nda library.