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/exposition.hpp>
9
10namespace etl::linalg {
11
12/// \ingroup linalg
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 index_type = detail::common_index_type_t<InMat, InVec, OutVec>;
20
21 for (index_type i{0}; i < static_cast<index_type>(a.extent(0)); ++i) {
22 y(i) = typename OutVec::element_type{};
23 for (index_type j{0}; j < static_cast<index_type>(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
constexpr auto matrix_vector_product(InMat a, InVec x, OutVec y) noexcept -> void
Definition blas2_matrix_vector_product.hpp:14
Definition accessor_conjugate.hpp:13
Definition adjacent_find.hpp:9