tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
blas1_copy.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_BLAS1_COPY_HPP
5#define TETL_LINALG_BLAS1_COPY_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_object InObj, out_object OutObj>
15 requires(InObj::rank() == OutObj::rank())
16constexpr auto copy(InObj x, OutObj y) -> void
17{
18 TETL_PRECONDITION(x.extents() == y.extents());
19
20 using size_type = detail::common_size_type_t<InObj, OutObj>;
21
22 if constexpr (InObj::rank() == 1) {
23 for (size_type i{0}; etl::cmp_less(i, x.extent(0)); ++i) {
24 y(i) = x(i);
25 }
26 } else {
27 static_assert(InObj::rank() == 2);
28 for (size_type i{0}; etl::cmp_less(i, x.extent(0)); ++i) {
29 for (size_type j{0}; etl::cmp_less(j, x.extent(1)); ++j) {
30 y(i, j) = x(i, j);
31 }
32 }
33 }
34}
35
36} // namespace etl::linalg
37
38#endif // TETL_LINALG_BLAS1_COPY_HPP
constexpr auto copy(InObj x, OutObj y) -> void
Definition blas1_copy.hpp:16
Definition accessor_conjugate.hpp:13
Definition adjacent_find.hpp:9