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// SPDX-FileCopyrightText: Copyright (C) 2023 Tobias Hienzsch
3
4#ifndef TETL_LINALG_BLAS2_MATRIX_VECTOR_PRODUCT_HPP
5#define TETL_LINALG_BLAS2_MATRIX_VECTOR_PRODUCT_HPP
6
7#include <etl/_contracts/check.hpp>
8#include <etl/_linalg/concepts.hpp>
9#include <etl/_utility/cmp_less.hpp>
10
11namespace etl::linalg {
12
13/// \ingroup linalg
14template <in_matrix InMat, in_vector InVec, out_vector OutVec>
15constexpr auto matrix_vector_product(InMat a, InVec x, OutVec y) noexcept -> void
16{
17 TETL_PRECONDITION(a.extent(1) == x.extent(0));
18 TETL_PRECONDITION(a.extent(0) == y.extent(0));
19
20 using size_type = detail::common_size_type_t<InMat, InVec, OutVec>;
21
22 for (size_type i(0); etl::cmp_less(i, a.extent(0)); ++i) {
23 y(i) = typename OutVec::element_type{};
24 for (size_type j(0); etl::cmp_less(j, a.extent(1)); ++j) {
25 y(i) += a(i, j) * x(j);
26 }
27 }
28}
29
30} // namespace etl::linalg
31
32#endif // TETL_LINALG_BLAS2_MATRIX_VECTOR_PRODUCT_HPP
constexpr auto matrix_vector_product(InMat a, InVec x, OutVec y) noexcept -> void
Definition blas2_matrix_vector_product.hpp:15
Definition accessor_conjugate.hpp:13
Definition adjacent_find.hpp:9