tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
conjugated.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_CONJUGATED_HPP
5#define TETL_LINALG_CONJUGATED_HPP
6
7#include <etl/_linalg/accessor_conjugate.hpp>
8#include <etl/_linalg/concepts.hpp>
9#include <etl/_type_traits/is_arithmetic.hpp>
10#include <etl/_type_traits/remove_cv.hpp>
11
12namespace etl::linalg {
13
14/// \ingroup linalg
15template <typename ElementType, typename Extents, typename Layout, typename Accessor>
16[[nodiscard]] constexpr auto conjugated(mdspan<ElementType, Extents, Layout, Accessor> a)
17{
18 if constexpr (is_arithmetic_v<remove_cv_t<ElementType>>) {
19 return mdspan<ElementType, Extents, Layout, Accessor>{
20 a.data_handle(),
21 a.mapping(),
22 a.accessor(),
23 };
24 } else {
25 using element_type = typename accessor_conjugate<Accessor>::element_type;
26 using accessor_type = accessor_conjugate<Accessor>;
27
28 return mdspan<element_type, Extents, Layout, accessor_type>{
29 a.data_handle(),
30 a.mapping(),
31 accessor_type(a.accessor()),
32 };
33 }
34}
35
36/// \ingroup linalg
37template <typename ElementType, typename Extents, typename Layout, typename NestedAccessor>
38[[nodiscard]] constexpr auto conjugated(mdspan<ElementType, Extents, Layout, accessor_conjugate<NestedAccessor>> a)
39{
40 using element_type = typename NestedAccessor::element_type;
41 using accessor_type = NestedAccessor;
42
43 return mdspan<element_type, Extents, Layout, accessor_type>{
44 a.data_handle(),
45 a.mapping(),
46 a.accessor().nested_accessor(),
47 };
48}
49
50} // namespace etl::linalg
51
52#endif // TETL_LINALG_CONJUGATED_HPP
constexpr auto conjugated(mdspan< ElementType, Extents, Layout, accessor_conjugate< NestedAccessor > > a)
Definition conjugated.hpp:38
constexpr auto conjugated(mdspan< ElementType, Extents, Layout, Accessor > a)
Definition conjugated.hpp:16
Definition accessor_conjugate.hpp:13
Definition adjacent_find.hpp:9
Definition accessor_conjugate.hpp:17
Definition mdspan.hpp:40