tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
blas2_matrix_vector_product.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_LINALG_BLAS2_MATRIX_VECTOR_PRODUCT_HPP
4#define TETL_LINALG_BLAS2_MATRIX_VECTOR_PRODUCT_HPP
5
9
10namespace etl::linalg {
11
13template <in_matrix InMat, in_vector InVec, out_vector OutVec>
14constexpr auto matrix_vector_product(InMat a, InVec x, OutVec y) noexcept -> void
15{
16 TETL_PRECONDITION(a.extent(1) == x.extent(0));
17 TETL_PRECONDITION(a.extent(0) == y.extent(0));
18
19 using size_type = detail::common_size_type_t<InMat, InVec, OutVec>;
20
21 for (size_type i(0); etl::cmp_less(i, a.extent(0)); ++i) {
22 y(i) = typename OutVec::element_type{};
23 for (size_type j(0); etl::cmp_less(j, a.extent(1)); ++j) {
24 y(i) += a(i, j) * x(j);
25 }
26 }
27}
28
29} // namespace etl::linalg
30
31#endif // TETL_LINALG_BLAS2_MATRIX_VECTOR_PRODUCT_HPP
#define TETL_PRECONDITION(...)
Definition check.hpp:16
constexpr auto matrix_vector_product(InMat a, InVec x, OutVec y) noexcept -> void
Definition blas2_matrix_vector_product.hpp:14
constexpr auto cmp_less(T t, U u) noexcept -> bool
Compare the values of two integers t and u. Unlike builtin comparison operators, negative signed inte...
Definition cmp_less.hpp:21
Definition accessor_conjugate.hpp:12