OpenKalman
make_dense_object.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) 2022-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_DENSE_OBJECT_HPP
17 #define OPENKALMAN_MAKE_DENSE_OBJECT_HPP
18 
19 namespace OpenKalman
20 {
30 #ifdef __cpp_concepts
31  template<indexible T, data_layout layout = data_layout::none, values::number Scalar = scalar_type_of_t<T>, pattern_collection Descriptors>
32  requires (layout != data_layout::stride) and
33  interface::make_default_defined_for<T, layout, Scalar, decltype(internal::to_euclidean_pattern_collection(std::declval<Descriptors&&>()))>
34  constexpr writable auto
35 #else
36  template<typename T, data_layout layout = data_layout::none, typename Scalar = scalar_type_of_t<T>, typename Descriptors, std::enable_if_t<
37  indexible<T> and values::number<Scalar> and pattern_collection<D> and (layout != data_layout::stride) and
38  interface::make_default_defined_for<T, layout, Scalar, decltype(internal::to_euclidean_pattern_collection(std::declval<Descriptors&&>()))>, int> = 0>
39  constexpr auto
40 #endif
41  make_dense_object(Descriptors&& descriptors)
42  {
43  decltype(auto) d = coordinates::internal::strip_1D_tail(std::forward<Descriptors>(descriptors));
44  using D = decltype(d);
46  if constexpr (coordinates::euclidean_pattern_collection<D>)
47  {
48  return Traits::template make_default<layout, Scalar>(std::forward<D>(d));
49  }
50  else
51  {
52  auto ed = internal::to_euclidean_pattern_collection(d);
53  return attach_pattern(Traits::template make_default<layout, Scalar>(ed), std::forward<D>(d));
54  }
55  }
56 
57 
62 #ifdef __cpp_concepts
63  template<indexible T, data_layout layout = data_layout::none, values::number Scalar = scalar_type_of_t<T>, coordinates::pattern...Ds>
64  requires (layout != data_layout::stride) and
65  interface::make_default_defined_for<T, layout, Scalar, decltype(std::tuple {get_dimension(std::declval<Ds&&>())...})>
66  constexpr writable auto
67 #else
68  template<typename T, data_layout layout = data_layout::none, typename Scalar = scalar_type_of_t<T>, typename...Ds, std::enable_if_t<
69  indexible<T> and values::number<Scalar> and (... and coordinates::pattern<Ds>) and (layout != data_layout::stride) and
70  interface::make_default_defined_for<T, layout, Scalar, std::tuple<Ds&&...>>, int> = 0>
71  constexpr auto
72 #endif
73  make_dense_object(Ds&&...ds)
74  {
75  return make_dense_object<T, layout, Scalar>(std::tuple {std::forward<Ds>(ds)...});
76  }
77 
78 
79 }
80 
81 #endif
constexpr auto attach_pattern(Arg &&arg, P &&p)
Attach a pattern_collection to an indexible object.
Definition: attach_pattern.hpp:36
constexpr auto make_dense_object(Descriptors &&descriptors)
Make a default, dense, writable matrix with a set of coordinates::pattern objects defining the dimens...
Definition: make_dense_object.hpp:41
constexpr auto get_dimension(const Arg &arg)
Get the vector dimension of coordinates::pattern Arg.
Definition: get_dimension.hpp:54
The root namespace for OpenKalman.
Definition: basics.hpp:34
An interface to various routines from the linear algebra library associated with indexible object T...
Definition: library_interface.hpp:42