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/exposition.hpp>
9
10namespace etl::linalg {
11
12/// \ingroup linalg
13template <in_object InObj, out_object OutObj>
14 requires(InObj::rank() == OutObj::rank())
15constexpr auto copy(InObj x, OutObj y) -> void
16{
17 TETL_PRECONDITION(x.extents() == y.extents());
18
19 using index_type = detail::common_index_type_t<InObj, OutObj>;
20
21 if constexpr (InObj::rank() == 1) {
22 static_assert(detail::compatible_static_extents<InObj, OutObj>(0, 0));
23 for (index_type i{0}; i < x.extent(0); ++i) {
24 y(i) = x(i);
25 }
26 } else {
27 static_assert(InObj::rank() == 2);
28 static_assert(detail::compatible_static_extents<InObj, OutObj>(0, 0));
29 static_assert(detail::compatible_static_extents<InObj, OutObj>(1, 1));
30
31 for (index_type i{0}; i < x.extent(0); ++i) {
32 for (index_type j{0}; j < x.extent(1); ++j) {
33 y(i, j) = x(i, j);
34 }
35 }
36 }
37}
38
39} // namespace etl::linalg
40
41#endif // TETL_LINALG_BLAS1_COPY_HPP
constexpr auto copy(InObj x, OutObj y) -> void
Definition blas1_copy.hpp:15
Definition accessor_conjugate.hpp:13
Definition adjacent_find.hpp:9