OpenKalman
concat.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 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_COORDINATES_VIEWS_CONCAT_HPP
17 #define OPENKALMAN_COORDINATES_VIEWS_CONCAT_HPP
18 
23 
25 {
26  namespace detail
27  {
29  {
30  #ifdef __cpp_concepts
31  template<pattern...P>
32  #else
33  template<typename...P, std::enable_if_t<(... and pattern<P>), int> = 0>
34  #endif
35  constexpr auto
36  operator() (P&&...p) const
37  {
38  if constexpr ((... and euclidean_pattern<P>))
39  return Dimensions {values::operation([](auto...xs){ return (0 + ... + xs); }, get_dimension(p)...)};
40  else if constexpr ((... and descriptor<P>))
41  return std::make_tuple(std::forward<P>(p)...) | collections::views::all;
42  else
43  return collections::views::concat([](P&& p) {
44  if constexpr (descriptor<P>) return std::array {std::forward<P>(p)};
45  else return std::forward<P>(p);
46  }(std::forward<P>(p))...);
47  }
48  };
49 
50  }
51 
52 
56  inline constexpr detail::concat_adaptor concat;
57 
58 }
59 
60 
61 #endif
Definition for coordinates::euclidean_pattern.
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated collection objects.
Definition: concat.hpp:196
constexpr bool pattern
An object describing the set of coordinates associated with a tensor index.
Definition: pattern.hpp:31
Definition for coordinates::pattern.
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:54
constexpr detail::all_closure all
a std::ranges::range_adaptor_closure which returns a view to all members of its collection argument...
Definition: all.hpp:72
constexpr detail::concat_adaptor concat
a std::ranges::range_adaptor_closure for a set of concatenated pattern objects.
Definition: concat.hpp:56
Inclusion file for collections.
The namespace for views for coordinates::pattern object.
Definition: coordinates.hpp:51
Definition for coordinates::get_dimension.
A structure representing the dimensions associated with of a particular index.
Definition: Dimensions.hpp:42
constexpr auto operation(Operation &&op, Args &&...args)
A potentially constant-evaluated operation involving some number of values.
Definition: operation.hpp:98