OpenKalman
make_diagonal_adapter.hpp
Go to the documentation of this file.
1 /* This file is part of OpenKalman, a header-only C++ library for
2  * Kalman filters and other recursive filters.
3  *
4  * Copyright (c) 2024 Christopher Lee Ogden <ogden@gatech.edu>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at https://mozilla.org/MPL/2.0/.
9  */
10 
16 #ifndef OPENKALMAN_MAKE_DIAGONAL_ADAPTER_HPP
17 #define OPENKALMAN_MAKE_DIAGONAL_ADAPTER_HPP
18 
19 namespace OpenKalman
20 {
27 #ifdef __cpp_concepts
28  template<indexible Arg, coordinates::pattern D0, coordinates::pattern D1> requires
29  (not fixed_pattern<D0> or not fixed_pattern<D1> or coordinates::compares_with<D0, D1, less_equal<>> or coordinates::compares_with<D1, D0, less_equal<>>) and
30  (dynamic_dimension<Arg, 0> or compares_with<vector_space_descriptor_of<Arg, 0>, D0, equal_to<>, Applicability::permitted> or compares_with<vector_space_descriptor_of<Arg, 0>, D1, equal_to<>, Applicability::permitted>)
31  constexpr diagonal_matrix auto
32 #else
33  template<typename Arg, typename D0, typename D1, std::enable_if_t<
34  indexible<Arg> and coordinates::pattern<D0> and coordinates::pattern<D1> and
35  (not fixed_pattern<D0> or not fixed_pattern<D1> or coordinates::compares_with<D0, D1, less_equal<>> or coordinates::compares_with<D1, D0, less_equal<>>) and
36  (dynamic_dimension<Arg, 0> or compares_with<vector_space_descriptor_of<Arg, 0>, D0, equal_to<>, Applicability::permitted> or compares_with<vector_space_descriptor_of<Arg, 0>, D1, equal_to<>, Applicability::permitted>), int> = 0>
37  constexpr auto
38 #endif
39  make_diagonal_adapter(Arg&& arg, D0&& d0, D1&& d1)
40  {
41  return DiagonalAdapter {std::forward<Arg>(arg), std::forward<D0>(d0), std::forward<D1>(d1)};
42  }
43 
44 
50 #ifdef __cpp_concepts
51  template<indexible Arg>
52  constexpr diagonal_matrix auto
53 #else
54  template<typename Arg, std::enable_if_t<indexible<Arg>, int> = 0>
55  constexpr auto
56 #endif
58  {
59  auto d = get_vector_space_descriptor<0>(arg);
60  return DiagonalAdapter {std::forward<Arg>(arg), d, d};
61  }
62 
63 } // namespace OpenKalman
64 
65 #endif //OPENKALMAN_MAKE_DIAGONAL_ADAPTER_HPP
constexpr bool diagonal_matrix
Specifies that a type is a diagonal matrix or tensor.
Definition: diagonal_matrix.hpp:32
The root namespace for OpenKalman.
Definition: basics.hpp:34
Applicability
The applicability of a concept, trait, or restraint.
Definition: global-definitions.hpp:93
constexpr bool dynamic_dimension
Specifies that T&#39;s index N has a dimension defined at run time.
Definition: dynamic_dimension.hpp:43
constexpr auto make_diagonal_adapter(Arg &&arg, D0 &&d0, D1 &&d1)
Make a diagonal_matrix, specifying the first two dimensions, which may not necessarily be the same...
Definition: make_diagonal_adapter.hpp:39
An adapter for creating a diagonal matrix or tensor.
Definition: DiagonalAdapter.hpp:27