OpenKalman
to_diagonal.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) 2025-2026 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 
17 #ifndef OPENKALMAN_PATTERNS_TO_DIAGONAL_HPP
18 #define OPENKALMAN_PATTERNS_TO_DIAGONAL_HPP
19 
23 
25 {
26  namespace detail
27  {
33  {
34  constexpr to_diagonal_closure() = default;
35 
36 #ifdef __cpp_concepts
37  template<pattern_collection R>
38  constexpr pattern_collection decltype(auto)
39 #else
40  template<typename R, std::enable_if_t<pattern_collection<R>, int> = 0>
41  constexpr decltype(auto)
42 #endif
43  operator() (R&& r) const
44  {
46  return std::forward<R>(r);
47  else
48  return collections::views::concat(std::array{get_pattern<0>(r)}, std::forward<R>(r));
49  }
50  };
51 
52 
54  {
55  constexpr auto
56  operator() () const
57  {
58  return to_diagonal_closure {};
59  }
60 
61 
62 #ifdef __cpp_concepts
63  template<pattern_collection R>
64  constexpr pattern_collection decltype(auto)
65 #else
66  template<typename R, std::enable_if_t<pattern_collection<R>, int> = 0>
67  constexpr decltype(auto)
68 #endif
69  operator() (R&& r) const
70  {
71  return to_diagonal_closure{}(std::forward<R>(r));
72  }
73  };
74  }
75 
76 
82 
83 
84 }
85 
86 #endif
Definition for pattern_collection.
constexpr bool pattern_collection
An object describing a sized collection of /ref sized_pattern objects.
Definition: pattern_collection.hpp:66
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated collection objects.
Definition: concat.hpp:209
The namespace for views for patterns::pattern object.
Definition: patterns.hpp:51
Definition for patterns::get_pattern.
The size of a sized object (including a collection).
Definition: size_of.hpp:33
constexpr detail::to_diagonal_adapter to_diagonal
A RangeAdapterObject that converts one pattern_collection to another that is equivalent to duplicatin...
Definition: to_diagonal.hpp:81
Inclusion file for collections.
Definition: range_adaptor_closure.hpp:34
constexpr bool fixed_value_compares_with
T has a fixed value that compares with N in a particular way based on parameter comp.
Definition: fixed_value_compares_with.hpp:74